r174296 - DeclPrinter: fix CXXConstructExpr printing with implicit default argument

Dmitri Gribenko gribozavr at gmail.com
Sun Feb 3 15:02:48 PST 2013


Author: gribozavr
Date: Sun Feb  3 17:02:47 2013
New Revision: 174296

URL: http://llvm.org/viewvc/llvm-project?rev=174296&view=rev
Log:
DeclPrinter: fix CXXConstructExpr printing with implicit default argument

This is an improvement of r173630, that handles the following case:

  struct VirualDestrClass
  {
    VirualDestrClass(int arg);
    virtual ~VirualDestrClass();
  };

  struct ConstrWithCleanupsClass
  {
    ConstrWithCleanupsClass(const VirualDestrClass& cplx = VirualDestrClass(42));
  };

  ConstrWithCleanupsClass cwcNoArg;

That was printed as:

  ConstrWithCleanupsClass cwcNoArg();

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=174296&r1=174295&r2=174296&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Sun Feb  3 17:02:47 2013
@@ -649,7 +649,8 @@ void DeclPrinter::VisitVarDecl(VarDecl *
   Expr *Init = D->getInit();
   if (!Policy.SuppressInitializers && Init) {
     bool ImplicitInit = false;
-    if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init)) {
+    if (CXXConstructExpr *Construct =
+            dyn_cast<CXXConstructExpr>(Init->IgnoreImplicit())) {
       if (D->getInitStyle() == VarDecl::CallInit &&
           !Construct->isListInitialization()) {
         ImplicitInit = Construct->getNumArgs() == 0 ||

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=174296&r1=174295&r2=174296&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Sun Feb  3 17:02:47 2013
@@ -110,13 +110,30 @@ struct NoArgClass
   NoArgClass() {}
 };
 
+struct VirualDestrClass
+{
+  VirualDestrClass(int arg);
+  virtual ~VirualDestrClass();
+};
+
+struct ConstrWithCleanupsClass
+{
+  ConstrWithCleanupsClass(const VirualDestrClass& cplx = VirualDestrClass(42));
+};
+
 // CHECK: test12
 // CHECK-NEXT: DefaultArgClass useDefaultArg;
 // CHECK-NEXT: DefaultArgClass overrideDefaultArg(1);
 // CHECK-NEXT: NoArgClass noArg;
+// CHECK-NEXT: ConstrWithCleanupsClass cwcNoArg;
+// CHECK-NEXT: ConstrWithCleanupsClass cwcOverrideArg(48);
+// CHECK-NEXT: ConstrWithCleanupsClass cwcExplicitArg(VirualDestrClass(56));
 void test12() {
   DefaultArgClass useDefaultArg;
   DefaultArgClass overrideDefaultArg(1);
   NoArgClass noArg;
+  ConstrWithCleanupsClass cwcNoArg;
+  ConstrWithCleanupsClass cwcOverrideArg(48);
+  ConstrWithCleanupsClass cwcExplicitArg(VirualDestrClass(56));
 }
 





More information about the cfe-commits mailing list