Skip to content

Commit 805dd4c

Browse files
committed
When pretty-printing an anonymous tag type that is associated with a typedef, use the name of the typedef rather than <anonymous>
llvm-svn: 66559
1 parent 64613ac commit 805dd4c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clang/lib/AST/Type.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,8 +1388,15 @@ void TagType::getAsStringInternal(std::string &InnerString) const {
13881388
const char *ID;
13891389
if (const IdentifierInfo *II = getDecl()->getIdentifier())
13901390
ID = II->getName();
1391-
else
1391+
else if (TypedefDecl *Typedef = getDecl()->getTypedefForAnonDecl()) {
1392+
Kind = 0;
1393+
assert(Typedef->getIdentifier() && "Typedef without identifier?");
1394+
ID = Typedef->getIdentifier()->getName();
1395+
} else
13921396
ID = "<anonymous>";
13931397

1394-
InnerString = std::string(Kind) + " " + ID + InnerString;
1398+
if (Kind)
1399+
InnerString = std::string(Kind) + " " + ID + InnerString;
1400+
else
1401+
InnerString = ID + InnerString;
13951402
}

0 commit comments

Comments
 (0)