summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/block-capture.cpp
diff options
context:
space:
mode:
authorJF Bastien <jfb@google.com>2018-05-19 04:21:26 +0000
committerJF Bastien <jfb@google.com>2018-05-19 04:21:26 +0000
commit6b23972f07a1604bccb9cd8334355e54ebac85a4 (patch)
treee9c7b3f12d46c42273a004142cc33ffb9aad6c1c /clang/test/CodeGenCXX/block-capture.cpp
parentfcd50538c2ec8d2f62edb5a40a94ee354e8e5b42 (diff)
downloadbcm5719-llvm-6b23972f07a1604bccb9cd8334355e54ebac85a4.tar.gz
bcm5719-llvm-6b23972f07a1604bccb9cd8334355e54ebac85a4.zip
CodeGen: block capture shouldn't ICE
When a lambda capture captures a __block in the same statement, the compiler asserts out because isCapturedBy assumes that an Expr can only be a BlockExpr, StmtExpr, or if it's a Stmt then all the statement's children are expressions. That's wrong, we need to visit all sub-statements even if they're not expressions to see if they also capture. Fix this issue by pulling out the isCapturedBy logic to use RecursiveASTVisitor. <rdar://problem/39926584> llvm-svn: 332801
Diffstat (limited to 'clang/test/CodeGenCXX/block-capture.cpp')
-rw-r--r--clang/test/CodeGenCXX/block-capture.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/block-capture.cpp b/clang/test/CodeGenCXX/block-capture.cpp
new file mode 100644
index 00000000000..623838357a3
--- /dev/null
+++ b/clang/test/CodeGenCXX/block-capture.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fblocks -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: %struct.__block_byref_baz = type { i8*, %struct.__block_byref_baz*, i32, i32, i32 }
+// CHECK: [[baz:%[0-9a-z_]*]] = alloca %struct.__block_byref_baz
+// CHECK: [[bazref:%[0-9a-z_\.]*]] = getelementptr inbounds %struct.__block_byref_baz, %struct.__block_byref_baz* [[baz]], i32 0, i32 1
+// CHECK: store %struct.__block_byref_baz* [[baz]], %struct.__block_byref_baz** [[bazref]]
+// CHECK: [[disposable:%[0-9a-z_]*]] = bitcast %struct.__block_byref_baz* [[baz]] to i8*
+// CHECK: call void @_Block_object_dispose(i8* [[disposable]]
+
+int main() {
+ __block int baz = [&]() { return 0; }();
+ return 0;
+}
OpenPOWER on IntegriCloud