summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-03-29 01:14:25 +0000
committerAnders Carlsson <andersca@mac.com>2010-03-29 01:14:25 +0000
commit74d7dfcf8ea377a1efa095561db0f024dfe77ca8 (patch)
tree63696e924e6e291ec33ce3b86468ba79aefb4f9d /clang/lib/CodeGen/CGClass.cpp
parentc86256fa5dcf89ddf7bc22c1287824679c51b53f (diff)
downloadbcm5719-llvm-74d7dfcf8ea377a1efa095561db0f024dfe77ca8.tar.gz
bcm5719-llvm-74d7dfcf8ea377a1efa095561db0f024dfe77ca8.zip
When generating base ctors/dtors, we need to lookup virtual bases using the vtable.
llvm-svn: 99790
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 4b5cffae853..ba66c911452 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1595,11 +1595,22 @@ CodeGenFunction::InitializeVTablePointer(BaseSubobject Base,
}
// Compute where to store the address point.
- const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
- llvm::Value *VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
- VTableField =
- Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);
+ llvm::Value *VTableField;
+ if (UseNewVTableCode &&
+ CodeGenVTables::needsVTTParameter(CurGD) && BaseIsMorallyVirtual) {
+ // We need to use the virtual base offset offset because the virtual base
+ // might have a different offset in the most derived class.
+ VTableField = GetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD,
+ /*NullCheckValue=*/false);
+ } else {
+ const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
+
+ VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
+ VTableField =
+ Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);
+ }
+
// Finally, store the address point.
const llvm::Type *AddressPointPtrTy =
VTableAddressPoint->getType()->getPointerTo();
OpenPOWER on IntegriCloud