diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-05-30 06:03:20 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-05-30 06:03:20 +0000 |
commit | c8731be34d18955bec1b71e172c978197c8f4ad7 (patch) | |
tree | a206a768dff7cfbbacfb8b5ca8fc80fda294671c /clang/lib/CodeGen/CGExprConstant.cpp | |
parent | ad98fc9733cc4b89599f13727e7f4da9465933b2 (diff) | |
download | bcm5719-llvm-c8731be34d18955bec1b71e172c978197c8f4ad7.tar.gz bcm5719-llvm-c8731be34d18955bec1b71e172c978197c8f4ad7.zip |
Fix for PR7040: Don't try to compute the LLVM type for a function where it
isn't possible to compute.
This patch is mostly refactoring; the key change is the addition of the code
starting with the comment, "Check whether the function has a computable LLVM
signature." The solution here is essentially the same as the way the
vtable code handles such functions.
llvm-svn: 105151
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 978964d843a..21a2a605a43 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -443,30 +443,8 @@ public: CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType()); llvm::Constant *Values[2]; - - // Get the function pointer (or index if this is a virtual function). - 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 * PointerWidthInBytes) + 1); - } else { - const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); - const llvm::Type *Ty = - CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD), - FPT->isVariadic()); - - llvm::Constant *FuncPtr = CGM.GetAddrOfFunction(MD, Ty); - Values[0] = llvm::ConstantExpr::getPtrToInt(FuncPtr, PtrDiffTy); - } + Values[0] = CGM.GetCXXMemberFunctionPointerValue(MD); // The adjustment will always be 0. Values[1] = llvm::ConstantInt::get(PtrDiffTy, 0); |