When pretty-printing an anonymous tag type that is associated with a typedef, use the name of the typedef rather than <anonymous>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66559 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 412b0cf..f9cf847 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -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;
}