diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-12-05 22:19:06 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-12-05 22:19:06 +0000 |
commit | 65bcdabba34fddc303ab97f60dfea6079989306a (patch) | |
tree | 173c25e2dd1bbfb190a253f8d25409190d546f7a | |
parent | ca952281611205fbc36d0516a595f9751e071d36 (diff) |
In DeclPrint add printing of 'explicit'
constructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169435 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 5 | ||||
-rw-r--r-- | unittests/AST/DeclPrinterTest.cpp | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 95d56b69d7..a5e1378b46 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -397,6 +397,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { } 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 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { 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 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } } - 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(); diff --git a/unittests/AST/DeclPrinterTest.cpp b/unittests/AST/DeclPrinterTest.cpp index aeb49b0171..2cb3a3f748 100644 --- a/unittests/AST/DeclPrinterTest.cpp +++ b/unittests/AST/DeclPrinterTest.cpp @@ -457,8 +457,7 @@ TEST(DeclPrinter, TestCXXConstructorDecl6) { " 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) { |