diff options
author | Anders Carlsson <andersca@mac.com> | 2010-05-03 16:05:06 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-05-03 16:05:06 +0000 |
commit | 3572d4419033c6d8e31aa57848bd31473d1541a8 (patch) | |
tree | a261c21c4c87d3345e2ae9f602937078602260da /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | df9ae794ca166e3d0f76d1a0b219de521c9e0e34 (diff) | |
download | bcm5719-llvm-3572d4419033c6d8e31aa57848bd31473d1541a8.tar.gz bcm5719-llvm-3572d4419033c6d8e31aa57848bd31473d1541a8.zip |
When computing the address of a virtual member function pointer, use the pointer width instead of hardcoding for 64-bit.
llvm-svn: 102921
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index ab0805ee7cf..2595ff0060c 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -448,11 +448,16 @@ public: if (MD->isVirtual()) { uint64_t Index = CGM.getVTables().getMethodVTableIndex(MD); + // FIXME: We shouldn't use / 8 here. + uint64_t PointerWidthInBytes = + CGM.getContext().Target.getPointerWidth(0) / 8; + // Itanium C++ ABI 2.3: // For a non-virtual function, this field is a simple function pointer. // For a virtual function, it is 1 plus the virtual table offset // (in bytes) of the function, represented as a ptrdiff_t. - Values[0] = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); + Values[0] = llvm::ConstantInt::get(PtrDiffTy, + (Index * PointerWidthInBytes) + 1); } else { const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); const llvm::Type *Ty = |