diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-05-04 18:40:33 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-05-04 18:40:33 +0000 |
commit | 1cce6e15c1d4bb41d52072c85f47e70e4fb5ca92 (patch) | |
tree | 078cc434b6d918b6305b319db66ec5e0fe7607f3 /clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp | |
parent | cc9676a82111d28611e33e4f28cc0555575e863f (diff) | |
download | llvm-1cce6e15c1d4bb41d52072c85f47e70e4fb5ca92.zip llvm-1cce6e15c1d4bb41d52072c85f47e70e4fb5ca92.tar.gz llvm-1cce6e15c1d4bb41d52072c85f47e70e4fb5ca92.tar.bz2 |
[CodeGenObjCXX] Fix handling of blocks in lambda.
This fixes a crash that occurs when a block captures a reference that is
captured by its enclosing lambda.
rdar://problem/18586651
Differential Revision: http://reviews.llvm.org/D19536
llvm-svn: 268532
Diffstat (limited to 'clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp')
-rw-r--r-- | clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp b/clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp new file mode 100644 index 0000000..51b7abf --- /dev/null +++ b/clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s + +// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5 +// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0 +// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8 +// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8 +// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6 +// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1 +// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8 +// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8 + +void foo1(int &, int &); + +void block_in_lambda(int &s1, int &s2) { + auto lambda = [&s1, &s2]() { + auto block = ^{ + foo1(s1, s2); + }; + block(); + }; + + lambda(); +} |