summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2019-02-26 16:20:41 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2019-02-26 16:20:41 +0000
commitd83c74028db0e3991a7c33c890439a608822f69f (patch)
treea60073a23e07bc0c54bf23efd78019796c1d6b73 /clang
parent46c719ddcd17a483554c491ba1db817c11f01f28 (diff)
downloadbcm5719-llvm-d83c74028db0e3991a7c33c890439a608822f69f.tar.gz
bcm5719-llvm-d83c74028db0e3991a7c33c890439a608822f69f.zip
[OpenCL] Fix assertion due to blocks
A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a block is called. There is code Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee()); getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle BlockExpr and returns nullptr, which causes isa to assert. This patch fixes that. Differential Revision: https://reviews.llvm.org/D58658 llvm-svn: 354893
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Expr.cpp2
-rw-r--r--clang/test/CodeGenOpenCL/blocks.cl6
2 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index aef1eab8a2f..85690c76e03 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@ Decl *Expr::getReferencedDeclOfCallee() {
return DRE->getDecl();
if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
return ME->getMemberDecl();
+ if (auto *BE = dyn_cast<BlockExpr>(CEE))
+ return BE->getBlockDecl();
return nullptr;
}
diff --git a/clang/test/CodeGenOpenCL/blocks.cl b/clang/test/CodeGenOpenCL/blocks.cl
index ab5a2c643c4..c3e26855dfe 100644
--- a/clang/test/CodeGenOpenCL/blocks.cl
+++ b/clang/test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@ int get42() {
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"
OpenPOWER on IntegriCloud