In DeclPrint add printing of 'explicit'

constructors.

llvm-svn: 169435
This commit is contained in:
Fariborz Jahanian 2012-12-05 22:19:06 +00:00
parent c524ec4411
commit 69c403c5c9
2 changed files with 5 additions and 3 deletions

View File

@ -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();

View File

@ -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) {