]> granicus.if.org Git - clang/commitdiff
When pretty-printing an anonymous tag type that is associated with a typedef, use...
authorDouglas Gregor <dgregor@apple.com>
Tue, 10 Mar 2009 18:11:21 +0000 (18:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 10 Mar 2009 18:11:21 +0000 (18:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66559 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Type.cpp

index 412b0cf8341c5e49c68eedd2fa01bac88fbe0428..f9cf847ee9e01d80c85ddfa52393fe7177de5569 100644 (file)
@@ -1388,8 +1388,15 @@ void TagType::getAsStringInternal(std::string &InnerString) const {
   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;
 }