From: Chris Lattner Date: Wed, 6 Feb 2008 05:48:29 +0000 (+0000) Subject: only convert the type name once, not each type it is refined. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de0efb3b6eac36bdeae0e60f753a974cc4118a31;p=clang only convert the type name once, not each type it is refined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46807 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index 0651b67cca..a659003465 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -277,8 +277,25 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { assert(0 && "FIXME: add missing functionality here"); break; - case Type::Tagged: - return ConvertTagDeclType(T, cast(Ty).getDecl()); + case Type::Tagged: { + const TagDecl *TD = cast(Ty).getDecl(); + const llvm::Type *Res = ConvertTagDeclType(T, TD); + + std::string TypeName(TD->getKindName()); + TypeName += '.'; + + // Name the codegen type after the typedef name + // if there is no tag type name available + if (TD->getIdentifier()) + TypeName += TD->getName(); + else if (const TypedefType *TdT = dyn_cast(T)) + TypeName += TdT->getDecl()->getName(); + else + TypeName += "anon"; + + TheModule.addTypeName(TypeName, Res); + return Res; + } } // FIXME: implement. @@ -386,22 +403,6 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(QualType T, assert(0 && "FIXME: Unknown tag decl kind!"); } - std::string TypeName(TD->getKindName()); - TypeName += '.'; - - // Name the codegen type after the typedef name - // if there is no tag type name available - if (TD->getIdentifier() == 0) { - if (T->getTypeClass() == Type::TypeName) { - const TypedefType *TdT = cast(T); - TypeName += TdT->getDecl()->getName(); - } else - TypeName += "anon"; - } else { - TypeName += TD->getName(); - } - - TheModule.addTypeName(TypeName, ResultType); return ResultType; }