diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 18:09:28 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-07-28 18:09:28 +0000 |
commit | 6d0bdaa68989bee60c85274e82a8f9c982587f26 (patch) | |
tree | de66fdbba0b138e1f75f1b3f68bb38d96b87d655 /lib/CodeGen/CGCXX.cpp | |
parent | c2cc1d5e29596f2ee2f32ca9c06f9119904dd161 (diff) |
Some code cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index a0aaa82b4b..d82b976951 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -156,8 +156,8 @@ llvm::Value *CodeGenFunction::LoadCXXThis() { } llvm::Value *CodeGenFunction::AddressCXXOfBaseClass(llvm::Value *BaseValue, - CXXRecordDecl *ClassDecl, - CXXRecordDecl *BaseClassDecl) { + const CXXRecordDecl *ClassDecl, + const CXXRecordDecl *BaseClassDecl) { if (ClassDecl == BaseClassDecl) return BaseValue; @@ -184,7 +184,7 @@ llvm::Value *CodeGenFunction::AddressCXXOfBaseClass(llvm::Value *BaseValue, BaseValue = Builder.CreateGEP(BaseValue, OffsetVal, "add.ptr"); QualType BTy = getContext().getCanonicalType( - getContext().getTypeDeclType(BaseClassDecl)); + getContext().getTypeDeclType(const_cast<CXXRecordDecl*>(BaseClassDecl))); const llvm::Type *BasePtr = ConvertType(BTy); BasePtr = VMContext.getPointerTypeUnqual(BasePtr); BaseValue = Builder.CreateBitCast(BaseValue, BasePtr); @@ -458,33 +458,18 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) { const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(CD->getDeclContext()); assert(ClassDecl->vbases_begin() == ClassDecl->vbases_end() && "FIXME. virtual base initialization unsupported"); - const ASTRecordLayout &Layout = getContext().getASTRecordLayout(ClassDecl); - llvm::Type *I8Ptr = VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty); - unsigned FieldNo = 0; + for (CXXConstructorDecl::init_const_iterator B = CD->init_begin(), E = CD->init_end(); B != E; ++B) { CXXBaseOrMemberInitializer *Member = (*B); if (Member->isBaseInitializer()) { - uint64_t Offset = Layout.getFieldOffset(FieldNo++) / 8; - assert(Member->getConstructor() && - "EmitCtorPrologue - no constructor to initialize base class"); llvm::Value *LoadOfThis = LoadCXXThis(); - llvm::LLVMContext &VMContext = getLLVMContext(); - llvm::Value *V; - if (Offset > 0) { - llvm::Value *OffsetVal = llvm::ConstantInt::get(llvm::Type::Int32Ty, - Offset); - V = Builder.CreateBitCast(LoadOfThis, I8Ptr); - V = Builder.CreateGEP(V, OffsetVal, "add.ptr"); - } - else - V = Builder.CreateBitCast(LoadOfThis, I8Ptr); - - const llvm::Type *BasePtr = - ConvertType(QualType(Member->getBaseClass(), 0)); - BasePtr = VMContext.getPointerTypeUnqual(BasePtr); - V = Builder.CreateBitCast(V, BasePtr); + Type *BaseType = Member->getBaseClass(); + CXXRecordDecl *BaseClassDecl = + cast<CXXRecordDecl>(BaseType->getAsRecordType()->getDecl()); + llvm::Value *V = AddressCXXOfBaseClass(LoadOfThis, ClassDecl, + BaseClassDecl); EmitCXXConstructorCall(Member->getConstructor(), Ctor_Complete, V, Member->const_arg_begin(), |