diff options
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 33d1f6e206..ebc8442353 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -1237,10 +1237,7 @@ CodeGenFunction::GetVirtualBaseClassOffset(llvm::Value *This, const llvm::Type *Int8PtrTy = llvm::Type::getInt8Ty(VMContext)->getPointerTo(); - llvm::Value *VTablePtr = Builder.CreateBitCast(This, - Int8PtrTy->getPointerTo()); - VTablePtr = Builder.CreateLoad(VTablePtr, "vtable"); - + llvm::Value *VTablePtr = GetVTablePtr(This, Int8PtrTy); int64_t VBaseOffsetOffset = CGM.getVTables().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl); @@ -1393,3 +1390,9 @@ void CodeGenFunction::InitializeVTablePointers(const CXXRecordDecl *RD) { /*BaseIsNonVirtualPrimaryBase=*/false, VTable, RD, VBases); } + +llvm::Value *CodeGenFunction::GetVTablePtr(llvm::Value *This, + const llvm::Type *Ty) { + llvm::Value *VTablePtrSrc = Builder.CreateBitCast(This, Ty->getPointerTo()); + return Builder.CreateLoad(VTablePtrSrc, "vtable"); +} |