From: Rafael Espindola Date: Tue, 25 Feb 2014 17:39:16 +0000 (+0000) Subject: Revert "Pretty Printer: Fix printing of conversion operator decls and calls." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f219f057550b8faff4092ba114ecd00a74a242c;p=clang Revert "Pretty Printer: Fix printing of conversion operator decls and calls." This reverts commit r202167. It broke Analysis/auto-obj-dtors-cfg-output.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202173 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 05701a5b06..aa753887a2 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -385,7 +385,6 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { CXXConstructorDecl *CDecl = dyn_cast(D); - CXXConversionDecl *ConversionDecl = dyn_cast(D); if (!Policy.SuppressSpecifiers) { switch (D->getStorageClass()) { case SC_None: break; @@ -399,8 +398,7 @@ 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()) || - (ConversionDecl && ConversionDecl->isExplicit())) + if (CDecl && CDecl->isExplicitSpecified()) Out << "explicit "; } @@ -538,15 +536,15 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } Out << ")"; } - } else if (!ConversionDecl) { + if (!Proto.empty()) + Out << Proto; + } else { 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); } diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index f9041c043c..e5019ab8d9 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -191,7 +191,6 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) { return OS << *Rec->getDecl(); LangOptions LO; LO.CPlusPlus = true; - LO.Bool = true; return OS << Type.getAsString(PrintingPolicy(LO)); } case DeclarationName::CXXUsingDirective: @@ -547,7 +546,6 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const { OS << "operator "; LangOptions LO; LO.CPlusPlus = true; - LO.Bool = true; OS << TInfo->getType().getAsString(PrintingPolicy(LO)); } else OS << Name; diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index a9f49990ee..8ed2987e6d 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1296,12 +1296,6 @@ void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) { } void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) { - // If we have a conversion operator call only print the argument. - CXXMethodDecl *MD = Node->getMethodDecl(); - if (MD && isa(MD)) { - PrintExpr(Node->getImplicitObjectArgument()); - return; - } VisitCallExpr(cast(Node)); } diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp index 3d98fd8ef3..977ba7afa4 100644 --- a/test/SemaCXX/ast-print.cpp +++ b/test/SemaCXX/ast-print.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -ast-print %s -std=gnu++11 | FileCheck %s +// RUN: %clang_cc1 -ast-print %s | FileCheck %s // CHECK: r; // CHECK-NEXT: (r->method()); @@ -173,26 +173,3 @@ void test14() { float test15() { return __builtin_asinf(1.0F); } - -namespace PR18776 { -struct A { - operator void *(); - explicit operator bool(); - A operator&(A); -}; - -// CHECK: struct A -// CHECK-NEXT: {{^[ ]*operator}} void *(); -// CHECK-NEXT: {{^[ ]*explicit}} operator bool(); - -void bar(void *); - -void foo() { - A a, b; - bar(a & b); -// CHECK: bar(a & b); - if (a & b) -// CHECK: if (a & b) - return; -} -};