diff options
author | Mike Stump <mrs@apple.com> | 2009-11-14 14:25:18 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-11-14 14:25:18 +0000 |
commit | 2b1bf3134e31ff7513244f4932949597ec800e3f (patch) | |
tree | 89e4c08c94ce049c43c41a61315d9224c6090970 /lib/CodeGen/CGRtti.cpp | |
parent | d02e232c43b979758810794de24d3f5cde40fe93 (diff) |
Add the name to the rtti data structure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88792 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRtti.cpp')
-rw-r--r-- | lib/CodeGen/CGRtti.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/lib/CodeGen/CGRtti.cpp b/lib/CodeGen/CGRtti.cpp index 7af15f0a8c..8484e2d7da 100644 --- a/lib/CodeGen/CGRtti.cpp +++ b/lib/CodeGen/CGRtti.cpp @@ -15,7 +15,38 @@ using namespace clang; using namespace CodeGen; +class RttiBuilder { + CodeGenModule &CGM; // Per-module state. + llvm::LLVMContext &VMContext; + const llvm::Type *Int8PtrTy; +public: + RttiBuilder(CodeGenModule &cgm) + : CGM(cgm), VMContext(cgm.getModule().getContext()), + Int8PtrTy(llvm::Type::getInt8PtrTy(VMContext)) { } + + llvm::Constant *BuildName(const CXXRecordDecl *RD) { + llvm::SmallString<256> OutName; + llvm::raw_svector_ostream Out(OutName); + mangleCXXRttiName(CGM.getMangleContext(), + CGM.getContext().getTagDeclType(RD), Out); + + llvm::GlobalVariable::LinkageTypes linktype; + linktype = llvm::GlobalValue::LinkOnceODRLinkage; + + llvm::Constant *C; + C = llvm::ConstantArray::get(VMContext, Out.str().substr(4)); + + llvm::Constant *s = new llvm::GlobalVariable(CGM.getModule(), C->getType(), + true, linktype, C, + Out.str()); + s = llvm::ConstantExpr::getBitCast(s, Int8PtrTy); + return s; + }; +}; + llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) { + RttiBuilder b(*this); + const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext); if (!getContext().getLangOptions().Rtti) @@ -26,14 +57,14 @@ llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) { mangleCXXRtti(getMangleContext(), Context.getTagDeclType(RD), Out); llvm::GlobalVariable::LinkageTypes linktype; - linktype = llvm::GlobalValue::WeakAnyLinkage; + linktype = llvm::GlobalValue::LinkOnceODRLinkage; std::vector<llvm::Constant *> info; // assert(0 && "FIXME: implement rtti descriptor"); // FIXME: descriptor info.push_back(llvm::Constant::getNullValue(Int8PtrTy)); - // assert(0 && "FIXME: implement rtti ts"); - // FIXME: TS - info.push_back(llvm::Constant::getNullValue(Int8PtrTy)); + info.push_back(b.BuildName(RD)); + + // FIXME: rest of rtti bits llvm::Constant *C; llvm::ArrayType *type = llvm::ArrayType::get(Int8PtrTy, info.size()); |