aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-04-17 21:36:59 +0000
committerAnders Carlsson <andersca@mac.com>2011-04-17 21:36:59 +0000
commite9742b0f7281d0a21b79e661ec8879e01c4a02e4 (patch)
tree857749ac957c7162799d17f484bbf1defcd9934b /lib/CodeGen/CodeGenTypes.cpp
parent2786a81415c43cf3110d197b20987c352edbd0fe (diff)
Move code to add a type name to a TagDecl type out into a helper function. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 731114bcca..3ec43f2fd9 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -65,6 +65,36 @@ void CodeGenTypes::HandleLateResolvedPointers() {
}
}
+void CodeGenTypes::addTagTypeName(const TagDecl *TD, const llvm::Type *Ty,
+ llvm::StringRef suffix) {
+ llvm::SmallString<256> TypeName;
+ llvm::raw_svector_ostream OS(TypeName);
+ OS << TD->getKindName() << '.';
+
+ // Name the codegen type after the typedef name
+ // if there is no tag type name available
+ if (TD->getIdentifier()) {
+ // FIXME: We should not have to check for a null decl context here.
+ // Right now we do it because the implicit Obj-C decls don't have one.
+ if (TD->getDeclContext())
+ OS << TD->getQualifiedNameAsString();
+ else
+ TD->printName(OS);
+ } else if (const TypedefNameDecl *TDD = TD->getTypedefNameForAnonDecl()) {
+ // FIXME: We should not have to check for a null decl context here.
+ // Right now we do it because the implicit Obj-C decls don't have one.
+ if (TDD->getDeclContext())
+ OS << TDD->getQualifiedNameAsString();
+ else
+ TDD->printName(OS);
+ } else
+ OS << "anon";
+
+ if (!suffix.empty())
+ OS << suffix;
+
+ TheModule.addTypeName(OS.str(), Ty);
+}
/// ConvertType - Convert the specified type to its LLVM form.
const llvm::Type *CodeGenTypes::ConvertType(QualType T, bool IsRecursive) {
@@ -373,31 +403,8 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
case Type::Enum: {
const TagDecl *TD = cast<TagType>(Ty).getDecl();
const llvm::Type *Res = ConvertTagDeclType(TD);
-
- llvm::SmallString<256> TypeName;
- llvm::raw_svector_ostream OS(TypeName);
- OS << TD->getKindName() << '.';
-
- // Name the codegen type after the typedef name
- // if there is no tag type name available
- if (TD->getIdentifier()) {
- // FIXME: We should not have to check for a null decl context here.
- // Right now we do it because the implicit Obj-C decls don't have one.
- if (TD->getDeclContext())
- OS << TD->getQualifiedNameAsString();
- else
- TD->printName(OS);
- } else if (const TypedefNameDecl *TDD = TD->getTypedefNameForAnonDecl()) {
- // FIXME: We should not have to check for a null decl context here.
- // Right now we do it because the implicit Obj-C decls don't have one.
- if (TDD->getDeclContext())
- OS << TDD->getQualifiedNameAsString();
- else
- TDD->printName(OS);
- } else
- OS << "anon";
-
- TheModule.addTypeName(OS.str(), Res);
+
+ addTagTypeName(TD, Res, llvm::StringRef());
return Res;
}