diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-02-07 17:37:13 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-02-07 17:37:13 +0000 |
| commit | 6d0e5bd8f35e8152d5cf071da875eb873e8aec7b (patch) | |
| tree | 8d8df0514273de54a706fdb762e1fc8ce793b7c0 /clang/lib/CodeGen | |
| parent | 0e027fb32bab35376fb5370742efabd0ddf5cf23 (diff) | |
| download | bcm5719-llvm-6d0e5bd8f35e8152d5cf071da875eb873e8aec7b.tar.gz bcm5719-llvm-6d0e5bd8f35e8152d5cf071da875eb873e8aec7b.zip | |
Use the right type when taking the address of a non-virtual member function pointer. Fixes PR6258.
llvm-svn: 95524
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index bdeecb85be1..b6340dcbb92 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -333,8 +333,12 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { // (in bytes) of the function, represented as a ptrdiff_t. FuncPtr = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); } else { - FuncPtr = llvm::ConstantExpr::getPtrToInt(CGF.CGM.GetAddrOfFunction(MD), - PtrDiffTy); + const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); + const llvm::Type *Ty = + CGF.CGM.getTypes().GetFunctionType(CGF.CGM.getTypes().getFunctionInfo(MD), + FPT->isVariadic()); + llvm::Constant *Fn = CGF.CGM.GetAddrOfFunction(MD, Ty); + FuncPtr = llvm::ConstantExpr::getPtrToInt(Fn, PtrDiffTy); } Builder.CreateStore(FuncPtr, DstPtr, VolatileDest); diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index dca09feebc9..5800ce770c3 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -425,8 +425,12 @@ public: // (in bytes) of the function, represented as a ptrdiff_t. Values[0] = llvm::ConstantInt::get(PtrDiffTy, (Index * 8) + 1); } else { - llvm::Constant *FuncPtr = CGM.GetAddrOfFunction(MD); + 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); } |

