r227545 - Teach AST printing to not print whitespace inside {} and () for initialization,

Richard Smith richard-llvm at metafoo.co.uk
Thu Jan 29 18:04:27 PST 2015


Author: rsmith
Date: Thu Jan 29 20:04:26 2015
New Revision: 227545

URL: http://llvm.org/viewvc/llvm-project?rev=227545&view=rev
Log:
Teach AST printing to not print whitespace inside {} and () for initialization,
to match LLVM's preferred style.

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/test/PCH/cxx11-lambdas.mm
    cfe/trunk/test/PCH/cxx1y-lambdas.mm
    cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=227545&r1=227544&r2=227545&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Jan 29 20:04:26 2015
@@ -1373,24 +1373,24 @@ void StmtPrinter::VisitInitListExpr(Init
     return;
   }
 
-  OS << "{ ";
+  OS << "{";
   for (unsigned i = 0, e = Node->getNumInits(); i != e; ++i) {
     if (i) OS << ", ";
     if (Node->getInit(i))
       PrintExpr(Node->getInit(i));
     else
-      OS << "0";
+      OS << "{}";
   }
-  OS << " }";
+  OS << "}";
 }
 
 void StmtPrinter::VisitParenListExpr(ParenListExpr* Node) {
-  OS << "( ";
+  OS << "(";
   for (unsigned i = 0, e = Node->getNumExprs(); i != e; ++i) {
     if (i) OS << ", ";
     PrintExpr(Node->getExpr(i));
   }
-  OS << " )";
+  OS << ")";
 }
 
 void StmtPrinter::VisitDesignatedInitExpr(DesignatedInitExpr *Node) {
@@ -1877,7 +1877,7 @@ void StmtPrinter::VisitCXXPseudoDestruct
 
 void StmtPrinter::VisitCXXConstructExpr(CXXConstructExpr *E) {
   if (E->isListInitialization())
-    OS << "{ ";
+    OS << "{";
 
   for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
     if (isa<CXXDefaultArgExpr>(E->getArg(i))) {
@@ -1890,7 +1890,7 @@ void StmtPrinter::VisitCXXConstructExpr(
   }
 
   if (E->isListInitialization())
-    OS << " }";
+    OS << "}";
 }
 
 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {

Modified: cfe/trunk/test/PCH/cxx11-lambdas.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx11-lambdas.mm?rev=227545&r1=227544&r2=227545&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx11-lambdas.mm (original)
+++ cfe/trunk/test/PCH/cxx11-lambdas.mm Thu Jan 29 20:04:26 2015
@@ -52,6 +52,6 @@ int add(int x, int y) {
 // CHECK-PRINT: lambda = [&] (int z)
 
 // CHECK-PRINT: init_capture
-// CHECK-PRINT: [&, x( t )]
+// CHECK-PRINT: [&, x(t)]
 
 #endif

Modified: cfe/trunk/test/PCH/cxx1y-lambdas.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx1y-lambdas.mm?rev=227545&r1=227544&r2=227545&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx1y-lambdas.mm (original)
+++ cfe/trunk/test/PCH/cxx1y-lambdas.mm Thu Jan 29 20:04:26 2015
@@ -53,6 +53,6 @@ int add(int x, int y) {
 // CHECK-PRINT: lambda = [] (type-parameter-0-0 z
 
 // CHECK-PRINT: init_capture
-// CHECK-PRINT: [&, x( t )]
+// CHECK-PRINT: [&, x(t)]
 
 #endif

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=227545&r1=227544&r2=227545&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Thu Jan 29 20:04:26 2015
@@ -53,7 +53,7 @@ void test6() {
     test6fn((int&)y);
 }
 
-// CHECK: S s( 1, 2 );
+// CHECK: S s(1, 2);
 
 template <class S> void test7()
 {
@@ -214,7 +214,7 @@ namespace {
 struct [[gnu::visibility("hidden")]] S;
 }
 
-// CHECK: struct CXXFunctionalCastExprPrint fce = CXXFunctionalCastExprPrint{ };
+// CHECK: struct CXXFunctionalCastExprPrint fce = CXXFunctionalCastExprPrint{};
 struct CXXFunctionalCastExprPrint {} fce = CXXFunctionalCastExprPrint{};
 
 // CHECK: struct CXXTemporaryObjectExprPrint toe = CXXTemporaryObjectExprPrint{};





More information about the cfe-commits mailing list