[cfe-commits] r66559 - /cfe/trunk/lib/AST/Type.cpp

Douglas Gregor dgregor at apple.com
Tue Mar 10 11:11:21 PDT 2009


Author: dgregor
Date: Tue Mar 10 13:11:21 2009
New Revision: 66559

URL: http://llvm.org/viewvc/llvm-project?rev=66559&view=rev
Log:
When pretty-printing an anonymous tag type that is associated with a typedef, use the name of the typedef rather than <anonymous>

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

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=66559&r1=66558&r2=66559&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Mar 10 13:11:21 2009
@@ -1388,8 +1388,15 @@
   const char *ID;
   if (const IdentifierInfo *II = getDecl()->getIdentifier())
     ID = II->getName();
-  else
+  else if (TypedefDecl *Typedef = getDecl()->getTypedefForAnonDecl()) {
+    Kind = 0;
+    assert(Typedef->getIdentifier() && "Typedef without identifier?");
+    ID = Typedef->getIdentifier()->getName();
+  } else
     ID = "<anonymous>";
 
-  InnerString = std::string(Kind) + " " + ID + InnerString;
+  if (Kind)
+    InnerString = std::string(Kind) + " " + ID + InnerString;
+  else
+    InnerString = ID + InnerString;
 }





More information about the cfe-commits mailing list