return UniqueMangledName(Name.begin(), Name.end());
}
-llvm::Constant *CodeGenFunction::GenerateRtti(const CXXRecordDecl *RD) {
+llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) {
llvm::Type *Ptr8Ty;
Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
llvm::Constant *Rtti = llvm::Constant::getNullValue(Ptr8Ty);
llvm::Constant *C;
llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, info.size());
C = llvm::ConstantArray::get(type, info);
- Rtti = new llvm::GlobalVariable(CGM.getModule(), type, true, linktype, C,
+ Rtti = new llvm::GlobalVariable(getModule(), type, true, linktype, C,
Name);
Rtti = llvm::ConstantExpr::getBitCast(Rtti, Ptr8Ty);
return Rtti;
class ABIBuilder {
std::vector<llvm::Constant *> &methods;
llvm::Type *Ptr8Ty;
+ const CXXRecordDecl *Class;
+ llvm::Constant *rtti;
llvm::LLVMContext &VMContext;
CodeGenModule &CGM; // Per-module state.
public:
ABIBuilder(std::vector<llvm::Constant *> &meth,
+ const CXXRecordDecl *c,
CodeGenModule &cgm)
- : methods(meth), VMContext(cgm.getModule().getContext()), CGM(cgm) {
+ : methods(meth), Class(c), rtti(cgm.GenerateRtti(c)),
+ VMContext(cgm.getModule().getContext()), CGM(cgm) {
Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
}
+
void GenerateVcalls(const CXXRecordDecl *RD) {
typedef CXXRecordDecl::method_iterator meth_iter;
llvm::Constant *m;
bool forPrimary,
int64_t Offset,
const CXXRecordDecl *Class,
- llvm::Constant *rtti,
bool ForVirtualBase,
llvm::SmallSet<const CXXRecordDecl *, 32> &IndirectPrimary) {
llvm::Constant *m = llvm::Constant::getNullValue(Ptr8Ty);
if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase);
Top = false;
- GenerateVtableForBase(PrimaryBase, true, Offset, Class, rtti,
+ GenerateVtableForBase(PrimaryBase, true, Offset, Class,
PrimaryBaseWasVirtual, IndirectPrimary);
}
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base != PrimaryBase || PrimaryBaseWasVirtual) {
uint64_t o = Offset + Layout.getBaseClassOffset(Base);
- GenerateVtableForBase(Base, true, o, Class, rtti, false,
- IndirectPrimary);
+ GenerateVtableForBase(Base, true, o, Class, false, IndirectPrimary);
}
}
}
void GenerateVtableForVBases(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
- llvm::Constant *rtti,
llvm::SmallSet<const CXXRecordDecl *, 32> &IndirectPrimary) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
if (i->isVirtual() && !IndirectPrimary.count(Base)) {
// Mark it so we don't output it twice.
IndirectPrimary.insert(Base);
- GenerateVtableForBase(Base, true, 0, Class, rtti, true, IndirectPrimary);
+ GenerateVtableForBase(Base, true, 0, Class, true, IndirectPrimary);
}
if (Base->getNumVBases())
- GenerateVtableForVBases(Base, Class, rtti, IndirectPrimary);
+ GenerateVtableForVBases(Base, Class, IndirectPrimary);
}
}
std::vector<llvm::Constant *> methods;
llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
int64_t Offset = 0;
- llvm::Constant *rtti = GenerateRtti(RD);
Offset += LLVMPointerWidth;
Offset += LLVMPointerWidth;
llvm::SmallSet<const CXXRecordDecl *, 32> IndirectPrimary;
- ABIBuilder b(methods, CGM);
+ ABIBuilder b(methods, RD, CGM);
// First comes the vtables for all the non-virtual bases...
- b.GenerateVtableForBase(RD, true, 0, RD, rtti, false, IndirectPrimary);
+ b.GenerateVtableForBase(RD, true, 0, RD, false, IndirectPrimary);
// then the vtables for all the virtual bases.
- b.GenerateVtableForVBases(RD, RD, rtti, IndirectPrimary);
+ b.GenerateVtableForVBases(RD, RD, IndirectPrimary);
llvm::Constant *C;
llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, methods.size());