When generating the CodeGen type name of a struct, union, enum use the typedef

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."

llvm-svn: 44489
This commit is contained in:
Christopher Lamb 2007-12-01 09:08:41 +00:00
parent 34f92ace1f
commit b0e6094a22
1 changed files with 8 additions and 1 deletions

View File

@ -310,7 +310,14 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
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;