| 1 | // RUN: %clang_cc1 %s -std=c++11 -emit-llvm -triple %itanium_abi_triple -o - -fblocks -fexceptions | FileCheck %s |
| 2 | // rdar://8594790 |
| 3 | |
| 4 | struct A { |
| 5 | int x; |
| 6 | A(const A &); |
| 7 | A(); |
| 8 | ~A() noexcept(false); |
| 9 | }; |
| 10 | |
| 11 | struct B { |
| 12 | int x; |
| 13 | B(const B &); |
| 14 | B(); |
| 15 | ~B(); |
| 16 | }; |
| 17 | |
| 18 | int testA() { |
| 19 | __block A a0, a1; |
| 20 | ^{ a0.x = 1234; a1.x = 5678; }; |
| 21 | return 0; |
| 22 | } |
| 23 | |
| 24 | // CHECK-LABEL: define internal void @__Block_byref_object_copy_ |
| 25 | // CHECK: call {{.*}} @_ZN1AC1ERKS_ |
| 26 | // CHECK-LABEL: define internal void @__Block_byref_object_dispose_ |
| 27 | // CHECK: call {{.*}} @_ZN1AD1Ev |
| 28 | |
| 29 | // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_e{{4|8}}_{{20|32}}rc{{24|40}}rc( |
| 30 | // CHECK: call void @_Block_object_assign( |
| 31 | // CHECK: invoke void @_Block_object_assign( |
| 32 | // CHECK: call void @_Block_object_dispose({{.*}}) #[[NOUNWIND_ATTR:[0-9]+]] |
| 33 | |
| 34 | // CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_e{{4|8}}_{{20|32}}rd{{24|40}}rd( |
| 35 | // CHECK: invoke void @_Block_object_dispose( |
| 36 | // CHECK: call void @_Block_object_dispose( |
| 37 | // CHECK: invoke void @_Block_object_dispose( |
| 38 | |
| 39 | int testB() { |
| 40 | __block B b0, b1; |
| 41 | ^{ b0.x = 1234; b1.x = 5678; }; |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | // CHECK-LABEL: define internal void @__Block_byref_object_copy_ |
| 46 | // CHECK: call {{.*}} @_ZN1BC1ERKS_ |
| 47 | // CHECK-LABEL: define internal void @__Block_byref_object_dispose_ |
| 48 | // CHECK: call {{.*}} @_ZN1BD1Ev |
| 49 | |
| 50 | // CHECK-NOT: define{{.*}}@__copy_helper_block |
| 51 | // CHECK: define linkonce_odr hidden void @__destroy_helper_block_e{{4|8}}_{{20|32}}r{{24|40}}r( |
| 52 | |
| 53 | // CHECK: attributes #[[NOUNWIND_ATTR]] = {{{.*}}nounwind{{.*}}} |
| 54 | |
| 55 | // rdar://problem/11135650 |
| 56 | namespace test1 { |
| 57 | struct A { int x; A(); ~A(); }; |
| 58 | |
| 59 | void test() { |
| 60 | return; |
| 61 | __block A a; |
| 62 | } |
| 63 | } |
| 64 | |