forked from OSchip/llvm-project
Move code to add a type name to a TagDecl type out into a helper function. No functionality change.
llvm-svn: 129669
This commit is contained in:
parent
4604bddc07
commit
c58f8cb7fc
|
@ -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.
|
/// ConvertType - Convert the specified type to its LLVM form.
|
||||||
const llvm::Type *CodeGenTypes::ConvertType(QualType T, bool IsRecursive) {
|
const llvm::Type *CodeGenTypes::ConvertType(QualType T, bool IsRecursive) {
|
||||||
|
@ -374,30 +404,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
|
||||||
const TagDecl *TD = cast<TagType>(Ty).getDecl();
|
const TagDecl *TD = cast<TagType>(Ty).getDecl();
|
||||||
const llvm::Type *Res = ConvertTagDeclType(TD);
|
const llvm::Type *Res = ConvertTagDeclType(TD);
|
||||||
|
|
||||||
llvm::SmallString<256> TypeName;
|
addTagTypeName(TD, Res, llvm::StringRef());
|
||||||
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);
|
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,11 @@ private:
|
||||||
/// used to handle cyclic structures properly.
|
/// used to handle cyclic structures properly.
|
||||||
void HandleLateResolvedPointers();
|
void HandleLateResolvedPointers();
|
||||||
|
|
||||||
|
/// addTagTypeName - Compute a name from the given tag decl with an optional
|
||||||
|
/// suffix and name the given LLVM type using it.
|
||||||
|
void addTagTypeName(const TagDecl *TD, const llvm::Type *Ty,
|
||||||
|
llvm::StringRef suffix);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CodeGenTypes(ASTContext &Ctx, llvm::Module &M, const llvm::TargetData &TD,
|
CodeGenTypes(ASTContext &Ctx, llvm::Module &M, const llvm::TargetData &TD,
|
||||||
const ABIInfo &Info, CGCXXABI &CXXABI);
|
const ABIInfo &Info, CGCXXABI &CXXABI);
|
||||||
|
|
Loading…
Reference in New Issue