summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-12-05 22:19:06 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-12-05 22:19:06 +0000
commit69c403c5c9e4d18ba79a36f04e107a228f0d2de7 (patch)
tree6f79a18122f02a73645d6d1a719f30a6e53edfaf
parentc524ec4411503494c5f684a6caaf8003aa48d142 (diff)
downloadbcm5719-llvm-69c403c5c9e4d18ba79a36f04e107a228f0d2de7.tar.gz
bcm5719-llvm-69c403c5c9e4d18ba79a36f04e107a228f0d2de7.zip
In DeclPrint add printing of 'explicit'
constructors. llvm-svn: 169435
-rw-r--r--clang/lib/AST/DeclPrinter.cpp5
-rw-r--r--clang/unittests/AST/DeclPrinterTest.cpp3
2 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 95d56b69d7b..a5e1378b465 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/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/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index aeb49b01710..2cb3a3f748c 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud