From: Rafael Espindola Date: Fri, 24 May 2013 16:11:44 +0000 (+0000) Subject: Fix printing CXXTemporaryObjectExpr with default args. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3bb9ffb9aa3c78ac9b525f5c8071c5a7c5309d4;p=clang Fix printing CXXTemporaryObjectExpr with default args. Patch by Will Wilson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182651 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 2edb078442..467413bfb2 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1339,6 +1339,8 @@ void StmtPrinter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *Node) { 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); diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 921f7d8baa..8e945bde7d 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -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);