r182651 - Fix printing CXXTemporaryObjectExpr with default args.

Rafael Espindola rafael.espindola at gmail.com
Fri May 24 09:11:44 PDT 2013


Author: rafael
Date: Fri May 24 11:11:44 2013
New Revision: 182651

URL: http://llvm.org/viewvc/llvm-project?rev=182651&view=rev
Log:
Fix printing CXXTemporaryObjectExpr with default args.

Patch by Will Wilson.

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp
    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=182651&r1=182650&r2=182651&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Fri May 24 11:11:44 2013
@@ -1339,6 +1339,8 @@ void StmtPrinter::VisitCXXTemporaryObjec
   for (CXXTemporaryObjectExpr::arg_iterator Arg = Node->arg_begin(),
                                          ArgEnd = Node->arg_end();
        Arg != ArgEnd; ++Arg) {
+    if (Arg->isDefaultArgument())
+      break;
     if (Arg != Node->arg_begin())
       OS << ", ";
     PrintExpr(*Arg);

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=182651&r1=182650&r2=182651&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Fri May 24 11:11:44 2013
@@ -103,6 +103,7 @@ int test11() {
 struct DefaultArgClass
 {
   DefaultArgClass(int a = 1) {}
+  DefaultArgClass(int a, int b, int c = 1) {}
 };
 
 struct NoArgClass
@@ -124,6 +125,8 @@ struct ConstrWithCleanupsClass
 // CHECK: test12
 // CHECK-NEXT: DefaultArgClass useDefaultArg;
 // CHECK-NEXT: DefaultArgClass overrideDefaultArg(1);
+// CHECK-NEXT: DefaultArgClass(1, 2);
+// CHECK-NEXT: DefaultArgClass(1, 2, 3);
 // CHECK-NEXT: NoArgClass noArg;
 // CHECK-NEXT: ConstrWithCleanupsClass cwcNoArg;
 // CHECK-NEXT: ConstrWithCleanupsClass cwcOverrideArg(48);
@@ -131,6 +134,8 @@ struct ConstrWithCleanupsClass
 void test12() {
   DefaultArgClass useDefaultArg;
   DefaultArgClass overrideDefaultArg(1);
+  DefaultArgClass tempWithDefaultArg = DefaultArgClass(1, 2);
+  DefaultArgClass tempWithExplictArg = DefaultArgClass(1, 2, 3);
   NoArgClass noArg;
   ConstrWithCleanupsClass cwcNoArg;
   ConstrWithCleanupsClass cwcOverrideArg(48);





More information about the cfe-commits mailing list