Index: lib/AST/Expr.cpp =================================================================== --- lib/AST/Expr.cpp +++ lib/AST/Expr.cpp @@ -1358,6 +1358,8 @@ return DRE->getDecl(); if (MemberExpr *ME = dyn_cast(CEE)) return ME->getMemberDecl(); + if (auto *BE = dyn_cast(CEE)) + return BE->getBlockDecl(); return nullptr; } Index: test/CodeGenOpenCL/blocks.cl =================================================================== --- test/CodeGenOpenCL/blocks.cl +++ test/CodeGenOpenCL/blocks.cl @@ -90,6 +90,12 @@ return blockArgFunc(^{return 42;}); } +// COMMON-LABEL: define {{.*}}@call_block +// call {{.*}}@__call_block_block_invoke +int call_block() { + return ^int(int num) { return num; } (11); +} + // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size" // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"