]> granicus.if.org Git - clang/commitdiff
When generating the CodeGen type name of a struct, union, enum use the typedef
authorChristopher Lamb <christopher.lamb@gmail.com>
Sat, 1 Dec 2007 09:08:41 +0000 (09:08 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Sat, 1 Dec 2007 09:08:41 +0000 (09:08 +0000)
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

CodeGen/CodeGenTypes.cpp

index e953d59f1d81667b20c793039142153f135ae1e3..7b8a73c100f8f4a47d5ff7a2bf40cf53e5fb5b31 100644 (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;