Teach AST printing to not print whitespace inside {} and () for initialization,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 30 Jan 2015 02:04:26 +0000 (02:04 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 30 Jan 2015 02:04:26 +0000 (02:04 +0000)
to match LLVM's preferred style.

llvm-svn: 227545

clang/lib/AST/StmtPrinter.cpp
clang/test/PCH/cxx11-lambdas.mm
clang/test/PCH/cxx1y-lambdas.mm
clang/test/SemaCXX/ast-print.cpp

index 8a86f2a..621c7a5 100644 (file)
@@ -1373,24 +1373,24 @@ void StmtPrinter::VisitInitListExpr(InitListExpr* Node) {
     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::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
 
 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(CXXConstructExpr *E) {
   }
 
   if (E->isListInitialization())
-    OS << " }";
+    OS << "}";
 }
 
 void StmtPrinter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
index c455051..5d3323a 100644 (file)
@@ -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
index becf6cb..1cd2706 100644 (file)
@@ -53,6 +53,6 @@ int add(int x, int y) {
 // CHECK-PRINT: lambda = [] (type-parameter-0-0 z\r
 \r
 // CHECK-PRINT: init_capture\r
-// CHECK-PRINT: [&, x( t )]\r
+// CHECK-PRINT: [&, x(t)]\r
 \r
 #endif\r
index b0bf245..1b57406 100644 (file)
@@ -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{};