[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / block-helpers.cpp
blob89d3967566168ffd8ad1c4822814e3cb60a658c5
1 // RUN: %clang_cc1 -x c++-header -triple x86_64-apple-darwin11 -emit-pch -fblocks -fexceptions -o %t %S/block-helpers.h
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -include-pch %t -emit-llvm -fblocks -fexceptions -o - %s | FileCheck %s
4 // CHECK: %[[STRUCT_BLOCK_BYREF_X:.*]] = type { ptr, ptr, i32, i32, ptr, ptr, %[[STRUCT_S0:.*]] }
5 // CHECK: %[[STRUCT_S0]] = type { i32 }
6 // CHECK: %[[STRUCT_BLOCK_BYREF_Y:.*]] = type { ptr, ptr, i32, i32, ptr, ptr, %[[STRUCT_S0]] }
8 // Check that byref structs are allocated for x and y.
10 // CHECK-LABEL: define linkonce_odr void @_ZN1S1mEv(
11 // CHECK: %[[X:.*]] = alloca %[[STRUCT_BLOCK_BYREF_X]], align 8
12 // CHECK: %[[Y:.*]] = alloca %[[STRUCT_BLOCK_BYREF_Y]], align 8
13 // CHECK: %[[BLOCK:.*]] = alloca <{ ptr, i32, i32, ptr, ptr, ptr, ptr }>, align 8
14 // CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds nuw <{ ptr, i32, i32, ptr, ptr, ptr, ptr }>, ptr %[[BLOCK]], i32 0, i32 5
15 // CHECK: store ptr %[[X]], ptr %[[BLOCK_CAPTURED]], align 8
16 // CHECK: %[[BLOCK_CAPTURED10:.*]] = getelementptr inbounds nuw <{ ptr, i32, i32, ptr, ptr, ptr, ptr }>, ptr %[[BLOCK]], i32 0, i32 6
17 // CHECK: store ptr %[[Y]], ptr %[[BLOCK_CAPTURED10]], align 8
19 // CHECK-LABEL: define internal void @___ZN1S1mEv_block_invoke(
21 // The second call to block_object_assign should be an invoke.
23 // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e8_32rc40rc(
24 // CHECK: call void @_Block_object_assign(
25 // CHECK: invoke void @_Block_object_assign(
26 // CHECK: call void @_Block_object_dispose(
28 // CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e8_32r40r(
29 void test() {
30 S s;
31 s.m();