Don't assume that a block always has a FunctionProtoType. Fixes rdar://6768379.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68583 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index c8d9655..74b6af1 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -444,13 +444,15 @@
// 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);