xref: /aosp_15_r20/external/clang/test/CodeGenObjCXX/block-nested-in-lambda.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // 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
4*67e74705SXin Li // CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
5*67e74705SXin Li // CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
6*67e74705SXin Li // CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
7*67e74705SXin Li // 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
8*67e74705SXin Li // CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
9*67e74705SXin Li // CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
10*67e74705SXin Li // CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
11*67e74705SXin Li 
12*67e74705SXin Li void foo1(int &, int &);
13*67e74705SXin Li 
block_in_lambda(int & s1,int & s2)14*67e74705SXin Li void block_in_lambda(int &s1, int &s2) {
15*67e74705SXin Li   auto lambda = [&s1, &s2]() {
16*67e74705SXin Li     auto block = ^{
17*67e74705SXin Li       foo1(s1, s2);
18*67e74705SXin Li     };
19*67e74705SXin Li     block();
20*67e74705SXin Li   };
21*67e74705SXin Li 
22*67e74705SXin Li   lambda();
23*67e74705SXin Li }
24