[cfe-commits] r113085 - /cfe/trunk/lib/AST/ASTDiagnostic.cpp

Chris Lattner sabre at nondot.org
Sat Sep 4 16:16:01 PDT 2010


Author: lattner
Date: Sat Sep  4 18:16:01 2010
New Revision: 113085

URL: http://llvm.org/viewvc/llvm-project?rev=113085&view=rev
Log:
revise r112365 to fix the actual problem: the isa<TagType>(Underlying)
check in the "typedef for anonymous type" check should have been a
getAs.

Modified:
    cfe/trunk/lib/AST/ASTDiagnostic.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=113085&r1=113084&r2=113085&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Sat Sep  4 18:16:01 2010
@@ -81,10 +81,10 @@
       break;
 
     // Don't desugar through the primary typedef of an anonymous type.
-    if (isa<TagType>(Underlying) && isa<TypedefType>(QT))
-      if (cast<TagType>(Underlying)->getDecl()->getTypedefForAnonDecl() ==
-          cast<TypedefType>(QT)->getDecl())
-        break;
+    if (const TagType *UTT = Underlying->getAs<TagType>())
+      if (const TypedefType *QTT = dyn_cast<TypedefType>(QT))
+        if (UTT->getDecl()->getTypedefForAnonDecl() == QTT->getDecl())
+          break;
 
     // Record that we actually looked through an opaque type here.
     ShouldAKA = true;
@@ -94,11 +94,11 @@
   // If we have a pointer-like type, desugar the pointee as well.
   // FIXME: Handle other pointer-like types.
   if (const PointerType *Ty = QT->getAs<PointerType>()) {
-      QT = Context.getPointerType(Desugar(Context, Ty->getPointeeType(),
-                                          ShouldAKA));
+    QT = Context.getPointerType(Desugar(Context, Ty->getPointeeType(),
+                                        ShouldAKA));
   } else if (const LValueReferenceType *Ty = QT->getAs<LValueReferenceType>()) {
-      QT = Context.getLValueReferenceType(Desugar(Context, Ty->getPointeeType(),
-                                                  ShouldAKA));
+    QT = Context.getLValueReferenceType(Desugar(Context, Ty->getPointeeType(),
+                                                ShouldAKA));
   }
 
   return QC.apply(QT);
@@ -151,13 +151,10 @@
     bool ShouldAKA = false;
     QualType DesugaredTy = Desugar(Context, Ty, ShouldAKA);
     if (ShouldAKA) {
-      std::string D = DesugaredTy.getAsString(Context.PrintingPolicy);
-      if (D != S) {
-        S = "'" + S + "' (aka '";
-        S += D;
-        S += "')";
-        return S;
-      }
+      S = "'" + S + "' (aka '";
+      S += DesugaredTy.getAsString(Context.PrintingPolicy);
+      S += "')";
+      return S;
     }
   }
 





More information about the cfe-commits mailing list