1// RUN: %clang_cc1 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s 2 3struct ObjCMember { 4 id member; 5}; 6 7struct ObjCArrayMember { 8 id member[2][3]; 9}; 10 11struct ObjCBlockMember { 12 int (^bp)(int); 13}; 14 15// CHECK: define void @_Z42test_ObjCMember_default_construct_destructv( 16void test_ObjCMember_default_construct_destruct() { 17 // CHECK: call void @_ZN10ObjCMemberC1Ev 18 // CHECK: call void @_ZN10ObjCMemberD1Ev 19 ObjCMember m1; 20} 21 22// CHECK: define void @_Z39test_ObjCMember_copy_construct_destruct10ObjCMember 23void test_ObjCMember_copy_construct_destruct(ObjCMember m1) { 24 // CHECK: call void @_ZN10ObjCMemberC1ERKS_ 25 // CHECK: call void @_ZN10ObjCMemberD1Ev 26 ObjCMember m2 = m1; 27 // CHECK: ret void 28} 29 30// CHECK: define void @_Z27test_ObjCMember_copy_assign10ObjCMemberS_ 31void test_ObjCMember_copy_assign(ObjCMember m1, ObjCMember m2) { 32 // CHECK: {{call.*_ZN10ObjCMemberaSERKS_}} 33 m1 = m2; 34 // CHECK-NEXT: ret void 35} 36 37// Implicitly-generated copy assignment operator for ObjCMember 38// CHECK: {{define linkonce_odr.*@_ZN10ObjCMemberaSERKS_}} 39// CHECK: call void @objc_storeStrong 40// CHECK: ret 41 42// CHECK: define void @_Z47test_ObjCArrayMember_default_construct_destructv 43void test_ObjCArrayMember_default_construct_destruct() { 44 // CHECK: call void @_ZN15ObjCArrayMemberC1Ev 45 ObjCArrayMember m1; 46 // CHECK: call void @_ZN15ObjCArrayMemberD1Ev 47 // CHECK: ret void 48} 49 50// CHECK: define void @_Z44test_ObjCArrayMember_copy_construct_destruct15ObjCArrayMember 51void test_ObjCArrayMember_copy_construct_destruct(ObjCArrayMember m1) { 52 // CHECK: call void @_ZN15ObjCArrayMemberC1ERKS_ 53 ObjCArrayMember m2 = m1; 54 // CHECK: call void @_ZN15ObjCArrayMemberD1Ev 55 // CHECK: ret void 56} 57 58void test_ObjCArrayMember_copy_assign(ObjCArrayMember m1, ObjCArrayMember m2) { 59 // CHECK: {{call.*@_ZN15ObjCArrayMemberaSERKS_}} 60 m1 = m2; 61 // CHECK-NEXT: ret void 62} 63 64// Implicitly-generated copy assignment operator for ObjCArrayMember 65// CHECK: {{define linkonce_odr.*@_ZN15ObjCArrayMemberaSERKS_}} 66// CHECK: call void @objc_storeStrong 67// CHECK-NEXT: br label 68// CHECK: ret 69 70// CHECK: define void @_Z47test_ObjCBlockMember_default_construct_destructv 71void test_ObjCBlockMember_default_construct_destruct() { 72 // CHECK: call void @_ZN15ObjCBlockMemberC1Ev 73 ObjCBlockMember m; 74 // CHECK-NEXT: call void @_ZN15ObjCBlockMemberD1Ev 75 // CHECK-NEXT: ret void 76} 77 78// CHECK: define void @_Z44test_ObjCBlockMember_copy_construct_destruct15ObjCBlockMember 79void test_ObjCBlockMember_copy_construct_destruct(ObjCBlockMember m1) { 80 // CHECK: call void @_ZN15ObjCBlockMemberC1ERKS_ 81 ObjCBlockMember m2 = m1; 82 // CHECK-NEXT: call void @_ZN15ObjCBlockMemberD1Ev 83 // CHECK-NEXT: ret void 84} 85 86// CHECK: define void @_Z32test_ObjCBlockMember_copy_assign15ObjCBlockMemberS_ 87void test_ObjCBlockMember_copy_assign(ObjCBlockMember m1, ObjCBlockMember m2) { 88 // CHECK: {{call.*_ZN15ObjCBlockMemberaSERKS_}} 89 m1 = m2; 90 // CHECK-NEXT: ret void 91} 92 93// Implicitly-generated copy assignment operator for ObjCBlockMember 94// CHECK: define linkonce_odr {{%.*}}* @_ZN15ObjCBlockMemberaSERKS_( 95// CHECK: [[T0:%.*]] = getelementptr inbounds [[T:%.*]]* {{%.*}}, i32 0, i32 0 96// CHECK-NEXT: [[T1:%.*]] = load i32 (i32)** [[T0]], align 8 97// CHECK-NEXT: [[T2:%.*]] = bitcast i32 (i32)* [[T1]] to i8* 98// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retainBlock(i8* [[T2]]) 99// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i32 (i32)* 100// CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[T]]* {{%.*}}, i32 0, i32 0 101// CHECK-NEXT: [[T6:%.*]] = load i32 (i32)** [[T5]], align 8 102// CHECK-NEXT: store i32 (i32)* [[T4]], i32 (i32)** [[T5]] 103// CHECK-NEXT: [[T7:%.*]] = bitcast i32 (i32)* [[T6]] to i8* 104// CHECK-NEXT: call void @objc_release(i8* [[T7]]) 105// CHECK-NEXT: ret 106 107// Implicitly-generated copy constructor for ObjCBlockMember 108// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2ERKS_ 109// CHECK: call i8* @objc_retainBlock 110// CHECK: ret 111 112// Implicitly-generated destructor for ObjCBlockMember 113// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberD2Ev 114// CHECK: call void @objc_storeStrong(i8* 115// CHECK: ret 116 117// Implicitly-generated default constructor for ObjCBlockMember 118// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2Ev 119// CHECK: store {{.*}} null, 120// CHECK-NEXT: ret void 121 122// Implicitly-generated copy constructor for ObjCArrayMember 123// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2ERKS_ 124// CHECK: br i1 125// CHECK: call i8* @objc_retain 126// CHECK-NEXT: store i8* 127// CHECK-NEXT: br label 128// CHECK: ret 129 130// Implicitly-generated destructor for ObjCArrayMember 131// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberD2Ev 132// CHECK: [[BEGIN:%.*]] = getelementptr inbounds [2 x [3 x i8*]]* 133// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 6 134// CHECK-NEXT: br label 135// CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ] 136// CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1 137// CHECK-NEXT: call void @objc_storeStrong(i8** [[CUR]], i8* null) 138// CHECK-NEXT: [[T1:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]] 139// CHECK-NEXT: br i1 [[T1]], 140// CHECK: ret void 141 142// Implicitly-generated default constructor for ObjCArrayMember 143// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2Ev 144// CHECK: call void @llvm.memset.p0i8.i64 145// CHECK: ret 146 147// Implicitly-generated copy constructor for ObjCMember 148// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2ERKS_ 149// CHECK-NOT: objc_release 150// CHECK: call i8* @objc_retain 151// CHECK-NEXT: store i8* 152// CHECK-NEXT: ret void 153 154// Implicitly-generated destructor for ObjCMember 155// CHECK: define linkonce_odr void @_ZN10ObjCMemberD2Ev 156// CHECK: call void @objc_storeStrong 157// CHECK: ret void 158 159// Implicitly-generated default constructor for ObjCMember 160// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2Ev 161// CHECK-NOT: objc_release 162// CHECK: store i8* null 163// CHECK-NEXT: ret void 164 165