summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-06-14 22:39:26 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-06-14 22:39:26 +0000
commit1cf2536d6ca5c2675c6fd144832184cfbb266465 (patch)
tree0e3bce520fdc52cb831069eb85f3ea24a0b65c59
parent9b4c85ff62486d9d65a55f067f105bd0fd84b093 (diff)
downloadbcm5719-llvm-1cf2536d6ca5c2675c6fd144832184cfbb266465.tar.gz
bcm5719-llvm-1cf2536d6ca5c2675c6fd144832184cfbb266465.zip
PR4391: Tweak -ast-print output to generate valid output for edge cases
like "int x = + +3;". llvm-svn: 73356
-rw-r--r--clang/lib/AST/StmtPrinter.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 710da638613..b300940824d 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/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());
OpenPOWER on IntegriCloud