[cfe-commits] r73356 - /cfe/trunk/lib/AST/StmtPrinter.cpp

Eli Friedman eli.friedman at gmail.com
Sun Jun 14 15:39:26 PDT 2009


Author: efriedma
Date: Sun Jun 14 17:39:26 2009
New Revision: 73356

URL: http://llvm.org/viewvc/llvm-project?rev=73356&view=rev
Log:
PR4391: Tweak -ast-print output to generate valid output for edge cases 
like "int x = + +3;".


Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=73356&r1=73355&r2=73356&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Sun Jun 14 17:39:26 2009
@@ -643,7 +643,8 @@
   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 @@
     case UnaryOperator::Extension:
       OS << ' ';
       break;
+    case UnaryOperator::Plus:
+    case UnaryOperator::Minus:
+      if (isa<UnaryOperator>(Node->getSubExpr()))
+        OS << ' ';
+      break;
     }
   }
   PrintExpr(Node->getSubExpr());





More information about the cfe-commits mailing list