diff options
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index d0475dd8df..54e3fa4744 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -413,9 +413,10 @@ public: // Get the function pointer (or index if this is a virtual function). if (MD->isVirtual()) { - int64_t Index = CGM.getVtableInfo().getMethodVtableIndex(MD); + uint64_t Index = CGM.getVtableInfo().getMethodVtableIndex(MD); - Values[0] = llvm::ConstantInt::get(PtrDiffTy, Index + 1); + // The pointer is 1 + the virtual table offset in bytes. + Values[0] = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); } else { llvm::Constant *FuncPtr = CGM.GetAddrOfFunction(MD); |