blob: d88a2bd62ffc6b823f5cbde7b38417854197167b [file] [log] [blame]
John McCallf85e1932011-06-15 23:02:42 +00001// RUN: %clang_cc1 -fobjc-nonfragile-abi -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:%.*]] = call i8* @objc_retainBlock(
96// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to i32 (i32)*
Chris Lattnerf0a86792011-07-10 03:47:27 +000097// CHECK-NEXT: [[T2:%.*]] = load {{.*}} [[SLOT:%.*]],
98// CHECK: store
99// CHECK-NEXT: [[T3:%.*]] = bitcast
John McCallf85e1932011-06-15 23:02:42 +0000100// CHECK-NEXT: call void @objc_release(i8* [[T3]])
101// CHECK-NEXT: ret
102
103// Implicitly-generated copy constructor for ObjCBlockMember
104// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2ERKS_
105// CHECK: call i8* @objc_retainBlock
106// CHECK: ret
107
108// Implicitly-generated destructor for ObjCBlockMember
109// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberD2Ev
110// CHECK: call void @objc_release(i8*
111// CHECK: ret
112
113// Implicitly-generated default constructor for ObjCBlockMember
114// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2Ev
Chris Lattnerf0a86792011-07-10 03:47:27 +0000115// CHECK: store {{.*}} null,
John McCallf85e1932011-06-15 23:02:42 +0000116// CHECK-NEXT: ret void
117
118// Implicitly-generated copy constructor for ObjCArrayMember
119// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2ERKS_
120// CHECK: br i1
121// CHECK: call i8* @objc_retain
122// CHECK-NEXT: store i8*
123// CHECK-NEXT: br label
124// CHECK: ret
125
126// Implicitly-generated destructor for ObjCArrayMember
John McCall9928c482011-07-12 16:41:08 +0000127// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberD2Ev
128// CHECK: [[BEGIN:%.*]] = getelementptr inbounds [2 x [3 x i8*]]*
129// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 6
130// CHECK-NEXT: br label
131// CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
132// CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1
133// CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
134// CHECK-NEXT: call void @objc_release(i8* [[T0]])
135// CHECK-NEXT: [[T1:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
136// CHECK-NEXT: br i1 [[T1]],
137// CHECK: ret void
John McCallf85e1932011-06-15 23:02:42 +0000138
139// Implicitly-generated default constructor for ObjCArrayMember
140// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2Ev
141// CHECK: call void @llvm.memset.p0i8.i64
142// CHECK: ret
143
144// Implicitly-generated copy constructor for ObjCMember
145// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2ERKS_
146// CHECK-NOT: objc_release
147// CHECK: call i8* @objc_retain
148// CHECK-NEXT: store i8*
149// CHECK-NEXT: ret void
150
151// Implicitly-generated destructor for ObjCMember
152// CHECK: define linkonce_odr void @_ZN10ObjCMemberD2Ev
153// CHECK: call void @objc_release
154// CHECK: ret void
155
156// Implicitly-generated default constructor for ObjCMember
157// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2Ev
158// CHECK-NOT: objc_release
159// CHECK: store i8* null
160// CHECK-NEXT: ret void
161