This is an archive of the discontinued LLVM Phabricator instance.

Make output of -ast-print a valid C++ code.
ClosedPublic

Authored by sepavloff on Nov 9 2016, 8:27 AM.

Details

Summary

Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

The change affects many test files but the changes are mostly
mechanical. Two main reasons why the test files require update are:

  • change in form of template specialization output,
  • template now is printed before its specializations.

Event Timeline

sepavloff updated this revision to Diff 77354.Nov 9 2016, 8:27 AM
sepavloff retitled this revision from to Make output of -ast-print a valid C++ code..
sepavloff updated this object.
sepavloff added reviewers: ABataev, gribozavr, rtrieu.
sepavloff added a subscriber: cfe-commits.
rsmith accepted this revision.Nov 9 2016, 4:33 PM
rsmith added a reviewer: rsmith.
rsmith added a subscriber: rsmith.

I've not looked at all of the test changes in detail, but this looks fine to me.

This revision is now accepted and ready to land.Nov 9 2016, 4:33 PM
This revision was automatically updated to reflect the committed changes.