[cfe-commits] r169435 - in /cfe/trunk: lib/AST/DeclPrinter.cpp unittests/AST/DeclPrinterTest.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Dec 5 14:19:06 PST 2012


Author: fjahanian
Date: Wed Dec  5 16:19:06 2012
New Revision: 169435

URL: http://llvm.org/viewvc/llvm-project?rev=169435&view=rev
Log:
In DeclPrint add printing of 'explicit'
constructors.

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=169435&r1=169434&r2=169435&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed Dec  5 16:19:06 2012
@@ -397,6 +397,7 @@
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+  CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D);
   if (!Policy.SuppressSpecifiers) {
     switch (D->getStorageClassAsWritten()) {
     case SC_None: break;
@@ -410,6 +411,8 @@
     if (D->isInlineSpecified())  Out << "inline ";
     if (D->isVirtualAsWritten()) Out << "virtual ";
     if (D->isModulePrivate())    Out << "__module_private__ ";
+    if (CDecl && CDecl->isExplicitSpecified())
+      Out << "explicit ";
   }
 
   PrintingPolicy SubPolicy(Policy);
@@ -485,7 +488,7 @@
       }
     }
 
-    if (CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D)) {
+    if (CDecl) {
       bool HasInitializerList = false;
       for (CXXConstructorDecl::init_const_iterator B = CDecl->init_begin(),
            E = CDecl->init_end();

Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=169435&r1=169434&r2=169435&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Wed Dec  5 16:19:06 2012
@@ -457,8 +457,7 @@
     "  explicit A(int a);"
     "};",
     constructorDecl(ofClass(hasName("A"))).bind("id"),
-    "A(int a)"));
-    // WRONG; Should be: "explicit A(int a);"
+    "explicit A(int a)"));
 }
 
 TEST(DeclPrinter, TestCXXConstructorDecl7) {





More information about the cfe-commits mailing list