diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-06-14 22:39:26 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-06-14 22:39:26 +0000 |
commit | 7df71ac778e5918883c826fdb3fff7d0feffc677 (patch) | |
tree | 50a527c31e955fc195764822ef45909ecfb6bce2 /lib/AST/StmtPrinter.cpp | |
parent | 4c4c527dc1877999dd2bdae74ae9ffbddedaf819 (diff) |
PR4391: Tweak -ast-print output to generate valid output for edge cases
like "int x = + +3;".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/StmtPrinter.cpp')
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 710da63861..b300940824 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -643,7 +643,8 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) { if (!Node->isPostfix()) { OS << UnaryOperator::getOpcodeStr(Node->getOpcode()); - // Print a space if this is an "identifier operator" like __real. + // Print a space if this is an "identifier operator" like __real, or if + // it might be concatenated incorrectly like '+'. switch (Node->getOpcode()) { default: break; case UnaryOperator::Real: @@ -651,6 +652,11 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) { case UnaryOperator::Extension: OS << ' '; break; + case UnaryOperator::Plus: + case UnaryOperator::Minus: + if (isa<UnaryOperator>(Node->getSubExpr())) + OS << ' '; + break; } } PrintExpr(Node->getSubExpr()); |