name if a tag type name is not available for the type. This matches how llvm-gcc
chooses CodeGen type names.
This means that "typedef struct {...} foo" now results in a CodeGen name of
"struct.foo" rather than "struct."
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44489
91177308-0d34-0410-b5e6-
96231b3b80d8
std::string TypeName(TD->getKindName());
TypeName += '.';
- TypeName += TD->getName();
+
+ // Name the codegen type after the typedef name
+ // if there is no tag type name available
+ if (TD->getName() == "" && T->getTypeClass() == Type::TypeName) {
+ const TypedefType *TdT = cast<TypedefType>(T);
+ TypeName += TdT->getDecl()->getName();
+ } else
+ TypeName += TD->getName();
TheModule.addTypeName(TypeName, ResultType);
return ResultType;