diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-25 17:26:26 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-02-25 17:26:26 +0000 |
commit | 48f52e926d6e8273587f5befc997fc784b04855b (patch) | |
tree | 7bb39b8f7dfcf67771391b649b7f19e27101d503 /clang/lib/AST/DeclPrinter.cpp | |
parent | a3283443675143ad384cdab710b1c04945f9f368 (diff) | |
download | bcm5719-llvm-48f52e926d6e8273587f5befc997fc784b04855b.tar.gz bcm5719-llvm-48f52e926d6e8273587f5befc997fc784b04855b.zip |
Pretty Printer: Fix printing of conversion operator decls and calls.
- Don't emit anything when we encounter a call to a conversion operator.
"bar(a & b)" instead of "bar(a & b.operator int())"
This preserves the semantics and is still idempotent if we print the AST multiple times.
- Properly print declarations of conversion operators.
"explicit operator bool();" instead of "bool operator _Bool();"
PR18776.
llvm-svn: 202167
Diffstat (limited to 'clang/lib/AST/DeclPrinter.cpp')
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index aa753887a21..05701a5b061 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -385,6 +385,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(D); + CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D); if (!Policy.SuppressSpecifiers) { switch (D->getStorageClass()) { case SC_None: break; @@ -398,7 +399,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()) + if ((CDecl && CDecl->isExplicitSpecified()) || + (ConversionDecl && ConversionDecl->isExplicit())) Out << "explicit "; } @@ -536,15 +538,15 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } Out << ")"; } - if (!Proto.empty()) - Out << Proto; - } else { + } else if (!ConversionDecl) { if (FT && FT->hasTrailingReturn()) { Out << "auto " << Proto << " -> "; Proto.clear(); } AFT->getReturnType().print(Out, Policy, Proto); + Proto.clear(); } + Out << Proto; } else { Ty.print(Out, Policy, Proto); } |