diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-10 22:48:10 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-10 22:48:10 +0000 |
commit | 4a5dc242545222aef6313cc4297708f524e10c6f (patch) | |
tree | c9ec8c29e098eac40ec9fe666129c57cb3dc2a2f /lib/CodeGen/CGCXXClass.cpp | |
parent | db380b4f40889f981b6f3f9f82730f91976f5fdf (diff) |
Revert r86741; it doesn't handle virtual bases correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86745 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXXClass.cpp')
-rw-r--r-- | lib/CodeGen/CGCXXClass.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/CodeGen/CGCXXClass.cpp b/lib/CodeGen/CGCXXClass.cpp index 668139ffb5..56a28fc9a0 100644 --- a/lib/CodeGen/CGCXXClass.cpp +++ b/lib/CodeGen/CGCXXClass.cpp @@ -127,14 +127,7 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue, // Just cast back. return Builder.CreateBitCast(BaseValue, BasePtrTy); } - - llvm::Value *Offset = - GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl); - - // If there is no offset, simply cast the pointer and return it. - if (!Offset) - return Builder.CreateBitCast(BaseValue, BasePtrTy); - + llvm::BasicBlock *CastNull = 0; llvm::BasicBlock *CastNotNull = 0; llvm::BasicBlock *CastEnd = 0; @@ -152,10 +145,15 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue, } const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext); + + llvm::Value *Offset = + GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl); - // Apply the offset. - BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy); - BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr"); + if (Offset) { + // Apply the offset. + BaseValue = Builder.CreateBitCast(BaseValue, Int8PtrTy); + BaseValue = Builder.CreateGEP(BaseValue, Offset, "add.ptr"); + } // Cast back. BaseValue = Builder.CreateBitCast(BaseValue, BasePtrTy); |