summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-12-01 09:08:41 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-12-01 09:08:41 +0000
commitb0e6094a221faa1ab13a8030421c670fbfa8d6f1 (patch)
tree295479166c0264a8b7ac18d313a8ed782edca6a0 /clang/CodeGen/CodeGenTypes.cpp
parent34f92ace1ffbf2e28f93e3d8a075371da7feafd9 (diff)
downloadbcm5719-llvm-b0e6094a221faa1ab13a8030421c670fbfa8d6f1.tar.gz
bcm5719-llvm-b0e6094a221faa1ab13a8030421c670fbfa8d6f1.zip
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
Diffstat (limited to 'clang/CodeGen/CodeGenTypes.cpp')
-rw-r--r--clang/CodeGen/CodeGenTypes.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/CodeGen/CodeGenTypes.cpp b/clang/CodeGen/CodeGenTypes.cpp
index e953d59f1d8..7b8a73c100f 100644
--- a/clang/CodeGen/CodeGenTypes.cpp
+++ b/clang/CodeGen/CodeGenTypes.cpp
@@ -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;
OpenPOWER on IntegriCloud