diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-28 22:06:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-01-28 22:06:01 +0000 |
commit | 1ae689c2b8759e4cb5bc9ff334b02c58752f2717 (patch) | |
tree | 27052790b91041b39277fa060bb46918de0e98fd /clang/lib/AST/StmtPrinter.cpp | |
parent | 80bd3c9e5fb2b5080435a7288267ab18d21a57ac (diff) | |
download | bcm5719-llvm-1ae689c2b8759e4cb5bc9ff334b02c58752f2717.tar.gz bcm5719-llvm-1ae689c2b8759e4cb5bc9ff334b02c58752f2717.zip |
PR22367: Don't forget to create a CXXFunctionalCastExpr around
list-initialization that gets converted to some form other than an
InitListExpr. CXXTemporaryObjectExpr is a special case here, because it
represents a fused CXXFunctionalCastExpr + CXXConstructExpr. That, in
itself, is probably a design error...
llvm-svn: 227377
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 927a679244b..8a86f2a5748 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1679,9 +1679,13 @@ void StmtPrinter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Node) { void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) { Node->getType().print(OS, Policy); - OS << "("; + // If there are no parens, this is list-initialization, and the braces are + // part of the syntax of the inner construct. + if (Node->getLParenLoc().isValid()) + OS << "("; PrintExpr(Node->getSubExpr()); - OS << ")"; + if (Node->getLParenLoc().isValid()) + OS << ")"; } void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) { @@ -1690,7 +1694,10 @@ void StmtPrinter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *Node) { void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) { Node->getType().print(OS, Policy); - OS << "("; + if (Node->isListInitialization()) + OS << "{"; + else + OS << "("; for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(), ArgEnd = Node->arg_end(); Arg != ArgEnd; ++Arg) { @@ -1700,7 +1707,10 @@ void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) { OS << ", "; PrintExpr(*Arg); } - OS << ")"; + if (Node->isListInitialization()) + OS << "}"; + else + OS << ")"; } void StmtPrinter::VisitLambdaExpr(LambdaExpr *Node) { |