r202173 - Revert "Pretty Printer: Fix printing of conversion operator decls and calls."

Rafael Espindola rafael.espindola at gmail.com
Tue Feb 25 09:39:16 PST 2014


Author: rafael
Date: Tue Feb 25 11:39:16 2014
New Revision: 202173

URL: http://llvm.org/viewvc/llvm-project?rev=202173&view=rev
Log:
Revert "Pretty Printer: Fix printing of conversion operator decls and calls."

This reverts commit r202167.

It broke Analysis/auto-obj-dtors-cfg-output.cpp

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/lib/AST/DeclarationName.cpp
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/test/SemaCXX/ast-print.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=202173&r1=202172&r2=202173&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Feb 25 11:39:16 2014
@@ -385,7 +385,6 @@ void DeclPrinter::VisitEnumConstantDecl(
 
 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;
@@ -399,8 +398,7 @@ void DeclPrinter::VisitFunctionDecl(Func
     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(Func
         }
         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);
   }

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=202173&r1=202172&r2=202173&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Tue Feb 25 11:39:16 2014
@@ -191,7 +191,6 @@ raw_ostream &operator<<(raw_ostream &OS,
       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_
         OS << "operator ";
       LangOptions LO;
       LO.CPlusPlus = true;
-      LO.Bool = true;
       OS << TInfo->getType().getAsString(PrintingPolicy(LO));
     } else
       OS << Name;

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=202173&r1=202172&r2=202173&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue Feb 25 11:39:16 2014
@@ -1296,12 +1296,6 @@ void StmtPrinter::VisitCXXOperatorCallEx
 }
 
 void StmtPrinter::VisitCXXMemberCallExpr(CXXMemberCallExpr *Node) {
-  // If we have a conversion operator call only print the argument.
-  CXXMethodDecl *MD = Node->getMethodDecl();
-  if (MD && isa<CXXConversionDecl>(MD)) {
-    PrintExpr(Node->getImplicitObjectArgument());
-    return;
-  }
   VisitCallExpr(cast<CallExpr>(Node));
 }
 

Modified: cfe/trunk/test/SemaCXX/ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ast-print.cpp?rev=202173&r1=202172&r2=202173&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/ast-print.cpp Tue Feb 25 11:39:16 2014
@@ -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;
-}
-};





More information about the cfe-commits mailing list