[cfe-commits] r90017 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CGExprConstant.cpp CGVtable.cpp CGVtable.h

Eli Friedman eli.friedman at gmail.com
Fri Nov 27 15:10:21 PST 2009


On Fri, Nov 27, 2009 at 12:47 PM, Anders Carlsson <andersca at mac.com> wrote:
> --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Nov 27 14:47:55 2009
> @@ -413,9 +413,10 @@
>
>     // 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);

The constant 8 looks suspicious here.  Perhaps you're looking for
something more like "LLVMPointerWidth/8"?

-Eli




More information about the cfe-commits mailing list