Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.

llvm-svn: 68583
This commit is contained in:
Anders Carlsson
2009-04-08 02:55:55 +00:00
parent 9d54bd77c0
commit a60cbcdfe6
4 changed files with 11 additions and 19 deletions

View File

@@ -444,13 +444,15 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
// Load the function.
llvm::Value *Func = Builder.CreateLoad(FuncPtr, false, "tmp");
const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(BPT);
bool IsVariadic =
BPT->getPointeeType()->getAsFunctionProtoType()->isVariadic();
QualType FnType = BPT->getPointeeType();
QualType ResultType = FnType->getAsFunctionType()->getResultType();
const CGFunctionInfo &FnInfo =
CGM.getTypes().getFunctionInfo(ResultType, Args);
// Cast the function pointer to the right type.
const llvm::Type *BlockFTy =
CGM.getTypes().GetFunctionType(FnInfo, IsVariadic);
CGM.getTypes().GetFunctionType(FnInfo, false);
const llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
Func = Builder.CreateBitCast(Func, BlockFTyPtr);