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-LABEL: 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-LABEL: 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-LABEL: 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-LABEL: 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-LABEL: 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-LABEL: 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-LABEL: 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-LABEL: 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 dereferenceable({{[0-9]+}}) {{%.*}}* @_ZN15ObjCBlockMemberaSERKS_( 95// CHECK: [[T0:%.*]] = getelementptr inbounds [[T:%.*]], [[T:%.*]]* {{%.*}}, i32 0, i32 0 96// CHECK-NEXT: [[T1:%.*]] = load i32 (i32)*, 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]], [[T]]* {{%.*}}, i32 0, i32 0 101// CHECK-NEXT: [[T6:%.*]] = load i32 (i32)*, 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 default constructor for ObjCMember 108// CHECK-LABEL: define linkonce_odr void @_ZN10ObjCMemberC2Ev 109// CHECK-NOT: objc_release 110// CHECK: store i8* null 111// CHECK-NEXT: ret void 112 113// Implicitly-generated destructor for ObjCMember 114// CHECK-LABEL: define linkonce_odr void @_ZN10ObjCMemberD2Ev 115// CHECK: call void @objc_storeStrong 116// CHECK: ret void 117 118// Implicitly-generated copy constructor for ObjCMember 119// CHECK-LABEL: define linkonce_odr void @_ZN10ObjCMemberC2ERKS_ 120// CHECK-NOT: objc_release 121// CHECK: call i8* @objc_retain 122// CHECK-NEXT: store i8* 123// CHECK-NEXT: ret void 124 125// Implicitly-generated default constructor for ObjCArrayMember 126// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCArrayMemberC2Ev 127// CHECK: call void @llvm.memset.p0i8.i64 128// CHECK: ret 129 130// Implicitly-generated destructor for ObjCArrayMember 131// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCArrayMemberD2Ev 132// CHECK: [[BEGIN:%.*]] = getelementptr inbounds [2 x [3 x i8*]], [2 x [3 x i8*]]* 133// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[BEGIN]], i64 6 134// CHECK-NEXT: br label 135// CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ] 136// CHECK-NEXT: [[CUR]] = getelementptr inbounds i8*, 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 copy constructor for ObjCArrayMember 143// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCArrayMemberC2ERKS_ 144// CHECK: br i1 145// CHECK: call i8* @objc_retain 146// CHECK-NEXT: store i8* 147// CHECK-NEXT: br label 148// CHECK: ret 149 150// Implicitly-generated default constructor for ObjCBlockMember 151// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCBlockMemberC2Ev 152// CHECK: store {{.*}} null, 153// CHECK-NEXT: ret void 154 155// Implicitly-generated destructor for ObjCBlockMember 156// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCBlockMemberD2Ev 157// CHECK: call void @objc_storeStrong(i8* 158// CHECK: ret 159 160// Implicitly-generated copy constructor for ObjCBlockMember 161// CHECK-LABEL: define linkonce_odr void @_ZN15ObjCBlockMemberC2ERKS_ 162// CHECK: call i8* @objc_retainBlock 163// CHECK: ret 164 165