aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-04-01 01:17:39 +0000
committerMike Stump <mrs@apple.com>2009-04-01 01:17:39 +0000
commitaab0f7a749e939d1d485a436f57ae56d14ba3016 (patch)
tree2731e576b71bec362f9b97e3ea98db584432e72a /lib/CodeGen/CGBlocks.cpp
parent984e06874685396ca2cb51f0008cfff7c9b3d9c6 (diff)
Fix block comparisons. Radar 6732116.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBlocks.cpp')
-rw-r--r--lib/CodeGen/CGBlocks.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 16e926ba64..c05d3235dd 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -412,18 +412,19 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() {
/// function type for the block, including the first block literal argument.
static QualType getBlockFunctionType(ASTContext &Ctx,
const BlockPointerType *BPT) {
- const FunctionProtoType *FTy = cast<FunctionProtoType>(BPT->getPointeeType());
+ const FunctionProtoType *FTy = dyn_cast<FunctionProtoType>(BPT->getPointeeType());
+ const clang::QualType ResType = BPT->getPointeeType()->getAsFunctionType()->getResultType();
llvm::SmallVector<QualType, 8> Types;
Types.push_back(Ctx.getPointerType(Ctx.VoidTy));
- for (FunctionProtoType::arg_type_iterator i = FTy->arg_type_begin(),
- e = FTy->arg_type_end(); i != e; ++i)
- Types.push_back(*i);
+ if (FTy)
+ for (FunctionProtoType::arg_type_iterator i = FTy->arg_type_begin(),
+ e = FTy->arg_type_end(); i != e; ++i)
+ Types.push_back(*i);
- return Ctx.getFunctionType(FTy->getResultType(),
- &Types[0], Types.size(),
- FTy->isVariadic(), 0);
+ return Ctx.getFunctionType(ResType, &Types[0], Types.size(),
+ FTy && FTy->isVariadic(), 0);
}
RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {