Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / clang / test / Index / Core / index-source.m
blob07c7d207607cbd829c004904ee18ec34860a1bfb
1 // RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s
2 // RUN: c-index-test core -print-source-symbols -include-locals -- %s -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=LOCAL %s
4 @interface Base
5 // CHECK: [[@LINE-1]]:12 | class/ObjC | Base | [[BASE_USR:.*]] | _OBJC_CLASS_$_Base | Decl | rel: 0
6 -(void)meth;
7 // CHECK: [[@LINE-1]]:8 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Decl,Dyn,RelChild | rel: 1
8 // CHECK-NEXT: RelChild | Base | c:objc(cs)Base
9 +(Base*)class_meth;
10 // CHECK: [[@LINE-1]]:9 | class-method/ObjC | class_meth | c:objc(cs)Base(cm)class_meth | +[Base class_meth] | Decl,Dyn,RelChild | rel: 1
11 // CHECK: [[@LINE-2]]:3 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
12 // CHECK-NEXT: RelCont | class_meth | c:objc(cs)Base(cm)class_meth
14 @end
16 void foo();
17 // CHECK: [[@LINE+6]]:6 | function/C | goo | c:@F@goo | _goo | Def | rel: 0
18 // CHECK: [[@LINE+5]]:10 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
19 // CHECK-NEXT: RelCont | goo | c:@F@goo
20 // CHECK-NOT: [[@LINE+3]]:16 | param
21 // LOCAL: [[@LINE+2]]:16 | param(local)/C | b | [[b_USR:c:.*]] | _b | Def,RelChild | rel: 1
22 // LOCAL-NEXT: RelChild | goo | c:@F@goo
23 void goo(Base *b) {
24   // CHECK-NOT: [[@LINE+6]]:7 | variable
25   // LOCAL: [[@LINE+5]]:7 | variable(local)/C | x | [[x_USR:c:.*]] | _x | Def,RelCont | rel: 1
26   // LOCAL-NEXT: RelCont | goo | c:@F@goo
27   // CHECK-NOT: [[@LINE+3]]:11 | param
28   // LOCAL: [[@LINE+2]]:11 | param(local)/C | b | [[b_USR]] | _b | Ref,Read,RelCont | rel: 1
29   // LOCAL-NEXT: RelCont | x | [[x_USR]]
30   int x = b;
31   // CHECK-NOT: [[@LINE+5]]:7 | variable
32   // LOCAL: [[@LINE+4]]:7 | variable(local)/C | y | [[y_USR:c:.*]] | _y | Def,RelCont | rel: 1
33   // CHECK-NOT: [[@LINE+3]]:11 | variable
34   // LOCAL: [[@LINE+2]]:11 | variable(local)/C | x | [[x_USR]] | _x | Ref,Read,RelCont | rel: 1
35   // LOCAL-NEXT: RelCont | y | [[y_USR]]
36   int y = x;
38   // CHECK-NOT: [[@LINE+1]]:10 | struct
39   // LOCAL: [[@LINE+1]]:10 | struct(local)/C | Foo | c:{{.*}} | <no-cgname> | Def,RelCont | rel: 1
40   struct Foo {
41     int i;
42   };
44   // CHECK: [[@LINE+2]]:3 | function/C | foo | c:@F@foo | _foo | Ref,Call,RelCall,RelCont | rel: 1
45   // CHECK-NEXT: RelCall,RelCont | goo | c:@F@goo
46   foo();
47   // CHECK: [[@LINE+3]]:6 | instance-method/ObjC | meth | c:objc(cs)Base(im)meth | -[Base meth] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
48   // CHECK-NEXT: RelCall,RelCont | goo | c:@F@goo
49   // CHECK-NEXT: RelRec | Base | c:objc(cs)Base
50   [b meth];
52   // CHECK: [[@LINE+2]]:4 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
53   // CHECK-NEXT: RelCont | goo | c:@F@goo
54   [Base class_meth];
56   // CHECK: [[@LINE+4]]:3 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
57   // CHECK-NEXT: RelCont | goo | c:@F@goo
58   // CHECK: [[@LINE+2]]:14 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
59   // CHECK-NEXT: RelCont | goo | c:@F@goo
60   Base *f = (Base *) 2;
63 // CHECK: [[@LINE+1]]:11 | protocol/ObjC | Prot1 | [[PROT1_USR:.*]] | <no-cgname> | Decl | rel: 0
64 @protocol Prot1
65 @end
67 // CHECK: [[@LINE+3]]:11 | protocol/ObjC | Prot2 | c:objc(pl)Prot2 | <no-cgname> | Decl | rel: 0
68 // CHECK: [[@LINE+2]]:17 | protocol/ObjC | Prot1 | c:objc(pl)Prot1 | <no-cgname> | Ref,RelBase,RelCont | rel: 1
69 // CHECK-NEXT: RelBase,RelCont | Prot2 | c:objc(pl)Prot2
70 @protocol Prot2<Prot1>
71 @end
73 // CHECK: [[@LINE+7]]:12 | class/ObjC | Sub | c:objc(cs)Sub | _OBJC_CLASS_$_Sub | Decl | rel: 0
74 // CHECK: [[@LINE+6]]:18 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelBase,RelCont | rel: 1
75 // CHECK-NEXT: RelBase,RelCont | Sub | c:objc(cs)Sub
76 // CHECK: [[@LINE+4]]:23 | protocol/ObjC | Prot2 | c:objc(pl)Prot2 | <no-cgname> | Ref,RelBase,RelCont | rel: 1
77 // CHECK-NEXT: RelBase,RelCont | Sub | c:objc(cs)Sub
78 // CHECK: [[@LINE+2]]:30 | protocol/ObjC | Prot1 | c:objc(pl)Prot1 | <no-cgname> | Ref,RelBase,RelCont | rel: 1
79 // CHECK-NEXT: RelBase,RelCont | Sub | c:objc(cs)Sub
80 @interface Sub : Base<Prot2, Prot1>
81 @end
83 @interface NSArray<ObjectType> : Base
84 // CHECK-NOT: ObjectType
85 -(ObjectType)getit;
86 @end
88 // CHECK: [[@LINE+1]]:6 | function/C | over_func | c:@F@over_func#I# | __Z9over_funci | Decl | rel: 0
89 void over_func(int x) __attribute__((overloadable));
90 // CHECK: [[@LINE+1]]:6 | function/C | over_func | c:@F@over_func#f# | __Z9over_funcf | Decl | rel: 0
91 void over_func(float x) __attribute__((overloadable));
93 // CHECK: [[@LINE+1]]:6 | enum/C | MyEnum | c:@E@MyEnum | <no-cgname> | Def | rel: 0
94 enum MyEnum {
95   // CHECK: [[@LINE+2]]:3 | enumerator/C | EnumeratorInNamed | c:@E@MyEnum@EnumeratorInNamed | <no-cgname> | Def,RelChild | rel: 1
96   // CHECK-NEXT: RelChild | MyEnum | c:@E@MyEnum
97   EnumeratorInNamed
100 // CHECK: [[@LINE+1]]:1 | enum/C | <no-name> | c:@Ea@One | <no-cgname> | Def | rel: 0
101 enum {
102   // CHECK: [[@LINE+2]]:3 | enumerator/C | One | c:@Ea@One@One | <no-cgname> | Def,RelChild | rel: 1
103   // CHECK-NEXT: RelChild | <no-name> | c:@Ea@One
104   One,
105   // CHECK: [[@LINE+2]]:3 | enumerator/C | Two | c:@Ea@One@Two | <no-cgname> | Def,RelChild | rel: 1
106   // CHECK-NEXT: RelChild | <no-name> | c:@Ea@One
107   Two,
110 // CHECK: [[@LINE+1]]:13 | type-alias/C | jmp_buf | c:index-source.m@T@jmp_buf | <no-cgname> | Def | rel: 0
111 typedef int jmp_buf[(18)];
112 // CHECK: [[@LINE+3]]:12 | function/C | setjmp | c:@F@setjmp | _setjmp | Decl | rel: 0
113 // CHECK: [[@LINE+2]]:19 | type-alias/C | jmp_buf | c:index-source.m@T@jmp_buf | <no-cgname> | Ref,RelCont | rel: 1
114 // CHECK-NEXT: RelCont | setjmp | c:@F@setjmp
115 extern int setjmp(jmp_buf);
117 @class I1;
118 @interface I1
119 // CHECK: [[@LINE+1]]:8 | instance-method/ObjC | meth | c:objc(cs)I1(im)meth | -[I1 meth] | Decl,Dyn,RelChild | rel: 1
120 -(void)meth;
121 @end
123 @interface I2
124 // CHECK: [[@LINE-1]]:12 | class/ObjC | I2 | [[I2_USR:.*]] | {{.*}} | Decl | rel: 0
126 @property (readwrite) id prop;
127 // CHECK: [[@LINE-1]]:26 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR:.*]] | -[I2 prop] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
128 // CHECK: [[@LINE-2]]:26 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR:.*]] | -[I2 setProp:] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
129 // CHECK: [[@LINE-3]]:26 | instance-property/ObjC | prop | [[I2_prop_USR:.*]] | <no-cgname> | Decl,RelChild | rel: 1
131 @property (readwrite, getter=customGet, setter=customSet:) id unrelated;
132 // CHECK: [[@LINE-1]]:30 | instance-method/acc-get/ObjC | customGet | {{.*}} | -[I2 customGet] | Decl,Dyn,RelChild,RelAcc | rel: 2
133 // CHECK: [[@LINE-2]]:48 | instance-method/acc-set/ObjC | customSet: | {{.*}} | -[I2 customSet:] | Decl,Dyn,RelChild,RelAcc | rel: 2
134 // CHECK: [[@LINE-3]]:63 | instance-property/ObjC | unrelated | {{.*}} | <no-cgname> | Decl,RelChild | rel: 1
136 -(id)declaredGet;
137 @property (readwrite, getter=declaredGet) id otherProp;
138 // CHECK: [[@LINE-1]]:30 | instance-method/acc-get/ObjC | declaredGet | {{.*}} | -[I2 declaredGet] | Ref,RelCont | rel: 1
139 // CHECK: [[@LINE-3]]:6 | instance-method/acc-get/ObjC | declaredGet | {{.*}} | -[I2 declaredGet] | Decl,Dyn,RelChild,RelAcc | rel: 2
140 // CHECK: [[@LINE-3]]:46 | instance-method/acc-set/ObjC | setOtherProp: | {{.*}} | -[I2 setOtherProp:] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
142 // CHECK: [[@LINE+4]]:63 | instance-property(IB,IBColl)/ObjC | buttons | [[buttons_USR:.*]] | <no-cgname> | Decl,RelChild | rel: 1
143 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
144 // CHECK: [[@LINE+2]]:50 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
145 // CHECK-NEXT: RelCont,RelIBType | buttons | [[buttons_USR]]
146 @property (nonatomic, strong) IBOutletCollection(I1) NSArray *buttons;
147 @end
149 @implementation I2
150 // CHECK: [[@LINE+9]]:13 | instance-property/ObjC | prop | [[I2_prop_USR:.*]] | <no-cgname> | Def,RelChild,RelAcc | rel: 2
151 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
152 // CHECK-NEXT: RelAcc | _prop | c:objc(cs)I2@_prop
153 // CHECK: [[@LINE+6]]:13 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR]] | -[I2 prop] | Def,Dyn,Impl,RelChild | rel: 1
154 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
155 // CHECK: [[@LINE+4]]:13 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR]] | -[I2 setProp:] | Def,Dyn,Impl,RelChild | rel: 1
156 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
157 // CHECK: [[@LINE+2]]:20 | field/ObjC | _prop | c:objc(cs)I2@_prop | <no-cgname> | Def,RelChild | rel: 1
158 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
159 @synthesize prop = _prop;
161 // CHECK: [[@LINE+11]]:12 | instance-method(IB)/ObjC | doAction:foo: | [[doAction_USR:.*]] | -[I2 doAction:foo:] | Def,Dyn,RelChild | rel: 1
162 // CHECK-NEXT: RelChild | I2 | [[I2_USR]]
163 // CHECK: [[@LINE+9]]:22 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont,RelIBType | rel: 1
164 // CHECK-NEXT: RelCont,RelIBType | doAction:foo: | [[doAction_USR]]
165 // CHECK-NOT: [[@LINE+7]]:27 | param
166 // LOCAL: [[@LINE+6]]:27 | param(local)/C | sender | c:{{.*}} | _sender | Def,RelChild | rel: 1
167 // LOCAL-NEXT: RelChild | doAction:foo: | [[doAction_USR:.*]]
168 // CHECK: [[@LINE+4]]:39 | class/ObjC | I1 | c:objc(cs)I1 | _OBJC_CLASS_$_I1 | Ref,RelCont | rel: 1
169 // CHECK-NOT: [[@LINE+3]]:44 | param
170 // LOCAL: [[@LINE+2]]:44 | param(local)/C | bar | c:{{.*}} | _bar | Def,RelChild | rel: 1
171 // LOCAL-NEXT: RelChild | doAction:foo: | [[doAction_USR]]
172 -(IBAction)doAction:(I1 *)sender foo:(I1 *)bar {
173   [self prop];
174   // CHECK: [[@LINE-1]]:9 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR]] | -[I2 prop] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
175   // CHECK-NEXT: RelCall,RelCont | doAction:foo: | [[doAction_USR]]
176   // CHECK-NEXT: RelRec | I2 | [[I2_USR]]
178   [self setProp: bar];
179   // CHECK: [[@LINE-1]]:9 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR]] | -[I2 setProp:] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
180   // CHECK-NEXT: RelCall,RelCont | doAction:foo: | [[doAction_USR]]
181   // CHECK-NEXT: RelRec | I2 | [[I2_USR]]
183   self.prop;
184   // CHECK: [[@LINE-1]]:8 | instance-property/ObjC | prop | [[I2_prop_USR]] | <no-cgname> | Ref,RelCont | rel: 1
185   // CHECK-NEXT: RelCont | doAction:foo: | [[doAction_USR]]
186   // CHECK: [[@LINE-3]]:8 | instance-method/acc-get/ObjC | prop | [[I2_prop_getter_USR]] | -[I2 prop] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
187   // CHECK-NEXT: RelCall,RelCont | doAction:foo: | [[doAction_USR]]
188   // CHECK-NEXT: RelRec | I2 | [[I2_USR]]
190   self.prop = self.prop;
191   // CHECK: [[@LINE-1]]:8 | instance-property/ObjC | prop | [[I2_prop_USR]] | <no-cgname> | Ref,Writ,RelCont | rel: 1
192   // CHECK-NEXT: RelCont | doAction:foo: | [[doAction_USR]]
193   // CHECK:[[@LINE-3]]:8 | instance-method/acc-set/ObjC | setProp: | [[I2_prop_setter_USR]] | -[I2 setProp:] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
194   // CHECK-NEXT: RelCall,RelCont | doAction:foo: | [[doAction_USR]]
195   // CHECK-NEXT: RelRec | I2 | [[I2_USR]]
197 @end
199 @interface I3
200 @property (readwrite) id prop;
201 // CHECK: [[@LINE+3]]:6 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Decl,Dyn,RelChild,RelAcc | rel: 2
202 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
203 // CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
204 -(id)prop;
205 // CHECK: [[@LINE+4]]:8 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Decl,Dyn,RelChild,RelAcc | rel: 2
206 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
207 // CHECK-NEXT: RelAcc | prop | c:objc(cs)I3(py)prop
208 // LOCAL-NOT: [[@LINE+1]]:20 | param
209 -(void)setProp:(id)p;
210 @end
212 // CHECK: [[@LINE+1]]:17 | class/ObjC | I3 | c:objc(cs)I3 | <no-cgname> | Def | rel: 0
213 @implementation I3
214 // CHECK: [[@LINE+5]]:13 | instance-property/ObjC | prop | c:objc(cs)I3(py)prop | <no-cgname> | Def,RelChild,RelAcc | rel: 2
215 // CHECK-NEXT: RelChild | I3 | c:objc(cs)I3
216 // CHECK-NEXT: RelAcc | _prop | c:objc(cs)I3@_prop
217 // CHECK: [[@LINE+2]]:13 | instance-method/acc-get/ObjC | prop | c:objc(cs)I3(im)prop | -[I3 prop] | Def,Dyn,Impl,RelChild | rel: 1
218 // CHECK: [[@LINE+1]]:13 | instance-method/acc-set/ObjC | setProp: | c:objc(cs)I3(im)setProp: | -[I3 setProp:] | Def,Dyn,Impl,RelChild | rel: 1
219 @synthesize prop = _prop;
220 @end
222 // CHECK: [[@LINE+5]]:12 | class/ObjC | I3 | c:objc(cs)I3 | _OBJC_CLASS_$_I3 | Ref,RelExt,RelCont | rel: 1
223 // CHECK-NEXT: RelExt,RelCont | bar | c:objc(cy)I3@bar
224 // CHECK: [[@LINE+3]]:15 | extension/ObjC | bar | c:objc(cy)I3@bar | <no-cgname> | Decl | rel: 0
225 // CHECK: [[@LINE+2]]:21 | protocol/ObjC | Prot1 | c:objc(pl)Prot1 | <no-cgname> | Ref,RelBase,RelCont | rel: 1
226 // CHECK-NEXT: RelBase,RelCont | bar | c:objc(cy)I3@bar
227 @interface I3(bar) <Prot1>
228 @end
230 // CHECK: [[@LINE+2]]:17 | class/ObjC | I3 | c:objc(cs)I3 | _OBJC_CLASS_$_I3 | Ref,RelCont | rel: 1
231 // CHECK: [[@LINE+1]]:20 | extension/ObjC | bar | c:objc(cy)I3@bar | <no-cgname> | Def | rel: 0
232 @implementation I3(bar)
233 @end
235 // CHECK-NOT: [[@LINE+1]]:12 | extension/ObjC |
236 @interface NonExistent()
237 @end
239 @interface MyGenCls<ObjectType> : Base
240 @end
242 @protocol MyEnumerating
243 @end
245 // CHECK: [[@LINE+4]]:41 | type-alias/C | MyEnumerator | [[MyEnumerator_USR:.*]] | <no-cgname> | Def | rel: 0
246 // CHECK: [[@LINE+3]]:26 | protocol/ObjC | MyEnumerating | c:objc(pl)MyEnumerating | <no-cgname> | Ref,RelCont | rel: 1
247 // CHECK: [[@LINE+2]]:9 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | _OBJC_CLASS_$_MyGenCls | Ref,RelCont | rel: 1
248 // CHECK: [[@LINE+1]]:18 | class/ObjC | Base | c:objc(cs)Base | _OBJC_CLASS_$_Base | Ref,RelCont | rel: 1
249 typedef MyGenCls<Base *><MyEnumerating> MyEnumerator;
251 // CHECK: [[@LINE+7]]:12 | class/ObjC | PermanentEnumerator | [[PermanentEnumerator_USR:.*]] | _OBJC_CLASS_$_PermanentEnumerator | Decl | rel: 0
252 // CHECK: [[@LINE+6]]:34 | type-alias/C | MyEnumerator | [[MyEnumerator_USR]] | <no-cgname> | Ref,RelCont | rel: 1
253 // CHECK-NEXT: RelCont | PermanentEnumerator | [[PermanentEnumerator_USR]]
254 // CHECK: [[@LINE+4]]:34 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | _OBJC_CLASS_$_MyGenCls | Ref,Impl,RelBase,RelCont | rel: 1
255 // CHECK-NEXT: RelBase,RelCont | PermanentEnumerator | [[PermanentEnumerator_USR]]
256 // CHECK: [[@LINE+2]]:34 | protocol/ObjC | MyEnumerating | c:objc(pl)MyEnumerating | <no-cgname> | Ref,Impl,RelBase,RelCont | rel: 1
257 // CHECK-NEXT: RelBase,RelCont | PermanentEnumerator | [[PermanentEnumerator_USR]]
258 @interface PermanentEnumerator : MyEnumerator
259 @end
261 // CHECK: [[@LINE+2]]:48 | protocol/ObjC | Prot1 | c:objc(pl)Prot1 | <no-cgname> | Ref,RelBase,RelCont | rel: 1
262 // CHECK: [[@LINE+1]]:35 | protocol/ObjC | MyEnumerating | c:objc(pl)MyEnumerating | <no-cgname> | Ref,Impl,RelBase,RelCont | rel: 1
263 @interface PermanentEnumerator2 : MyEnumerator<Prot1>
264 @end
266 @interface I4
267 @property id foo;
268 @end
270 @implementation I4 {
271   id _blahfoo; // explicit def
272   // CHECK: [[@LINE-1]]:6 | field/ObjC | _blahfoo | c:objc(cs)I4@_blahfoo | <no-cgname> | Def,RelChild | rel: 1
274 @synthesize foo = _blahfoo; // ref of field _blahfoo
275 // CHECK: [[@LINE-1]]:13 | instance-property/ObjC | foo | c:objc(cs)I4(py)foo | <no-cgname> | Def,RelChild,RelAcc | rel: 2
276 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4
277 // CHECK-NEXT: RelAcc | _blahfoo | c:objc(cs)I4@_blahfoo
278 // CHECK: [[@LINE-4]]:13 | instance-method/acc-get/ObjC | foo | c:objc(cs)I4(im)foo | -[I4 foo] | Def,Dyn,Impl,RelChild | rel: 1
279 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4
280 // CHECK: [[@LINE-6]]:13 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I4(im)setFoo: | -[I4 setFoo:] | Def,Dyn,Impl,RelChild | rel: 1
281 // CHECK-NEXT: RelChild | I4 | c:objc(cs)I4
282 // CHECK: [[@LINE-8]]:19 | field/ObjC | _blahfoo | c:objc(cs)I4@_blahfoo | <no-cgname> | Ref | rel: 0
284 -(void)method {
285   _blahfoo = 0;
286   // CHECK: [[@LINE-1]]:3 | field/ObjC | _blahfoo | c:objc(cs)I4@_blahfoo | <no-cgname> | Ref,Writ,RelCont | rel: 1
288 @end
290 @interface I5
291 @property id foo;
292 @end
294 @implementation I5
295 @synthesize foo = _blahfoo; // explicit def of field _blahfoo
296 // CHECK: [[@LINE-1]]:13 | instance-property/ObjC | foo | c:objc(cs)I5(py)foo | <no-cgname> | Def,RelChild,RelAcc | rel: 2
297 // CHECK-NEXT: RelChild | I5 | c:objc(cs)I5
298 // CHECK-NEXT: RelAcc | _blahfoo | c:objc(cs)I5@_blahfoo
299 // CHECK: [[@LINE-4]]:13 | instance-method/acc-get/ObjC | foo | c:objc(cs)I5(im)foo | -[I5 foo] | Def,Dyn,Impl,RelChild | rel: 1
300 // CHECK-NEXT: RelChild | I5 | c:objc(cs)I5
301 // CHECK: [[@LINE-6]]:13 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I5(im)setFoo: | -[I5 setFoo:] | Def,Dyn,Impl,RelChild | rel: 1
302 // CHECK-NEXT: RelChild | I5 | c:objc(cs)I5
303 // CHECK: [[@LINE-8]]:19 | field/ObjC | _blahfoo | c:objc(cs)I5@_blahfoo | <no-cgname> | Def,RelChild | rel: 1
305 -(void)method {
306   _blahfoo = 0;
307   // CHECK: [[@LINE-1]]:3 | field/ObjC | _blahfoo | c:objc(cs)I5@_blahfoo | <no-cgname> | Ref,Writ,RelCont | rel: 1
309 @end
311 @interface I6
312 @property id foo;
313 @end
315 @implementation I6
316 @synthesize foo; // implicit def of field foo
317 // CHECK: [[@LINE-1]]:13 | instance-property/ObjC | foo | c:objc(cs)I6(py)foo | <no-cgname> | Def,RelChild,RelAcc | rel: 2
318 // CHECK-NEXT: RelChild | I6 | c:objc(cs)I6
319 // CHECK-NEXT: RelAcc | foo | c:objc(cs)I6@foo
320 // CHECK: [[@LINE-4]]:13 | instance-method/acc-get/ObjC | foo | c:objc(cs)I6(im)foo | -[I6 foo] | Def,Dyn,Impl,RelChild | rel: 1
321 // CHECK-NEXT: RelChild | I6 | c:objc(cs)I6
322 // CHECK: [[@LINE-6]]:13 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I6(im)setFoo: | -[I6 setFoo:] | Def,Dyn,Impl,RelChild | rel: 1
323 // CHECK-NEXT: RelChild | I6 | c:objc(cs)I6
324 // CHECK: [[@LINE-8]]:13 | field/ObjC | foo | c:objc(cs)I6@foo | <no-cgname> | Def,Impl,RelChild | rel: 1
326 -(void)method {
327   foo = 0;
328   // CHECK: [[@LINE-1]]:3 | field/ObjC | foo | c:objc(cs)I6@foo | <no-cgname> | Ref,Writ,RelCont | rel: 1
330 @end
332 @interface I7
333 @property id foo;
334 @end
336 @implementation I7 // implicit def of field _foo
337 // CHECK: [[@LINE-1]]:17 | instance-property/ObjC | foo | c:objc(cs)I7(py)foo | <no-cgname> | Def,Impl,RelChild,RelAcc | rel: 2
338 // CHECK-NEXT: RelChild | I7 | c:objc(cs)I7
339 // CHECK-NEXT: RelAcc | _foo | c:objc(cs)I7@_foo
340 // CHECK: [[@LINE-4]]:17 | instance-method/acc-get/ObjC | foo | c:objc(cs)I7(im)foo | -[I7 foo] | Def,Dyn,Impl,RelChild | rel: 1
341 // CHECK-NEXT: RelChild | I7 | c:objc(cs)I7
342 // CHECK: [[@LINE-6]]:17 | instance-method/acc-set/ObjC | setFoo: | c:objc(cs)I7(im)setFoo: | -[I7 setFoo:] | Def,Dyn,Impl,RelChild | rel: 1
343 // CHECK-NEXT: RelChild | I7 | c:objc(cs)I7
344 // CHECK: [[@LINE-8]]:17 | field/ObjC | _foo | c:objc(cs)I7@_foo | <no-cgname> | Def,Impl,RelChild | rel: 1
346 -(void)method {
347   _foo = 0;
348 // CHECK: [[@LINE-1]]:3 | field/ObjC | _foo | c:objc(cs)I7@_foo | <no-cgname> | Ref,Writ,RelCont | rel: 1
350 @end
352 #define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
354 typedef NS_ENUM(AnotherEnum, int) {
355 // CHECK-NOT: [[@LINE-1]]:17 | type-alias/C | AnotherEnum |
356 // CHECK-NOT: [[@LINE-2]]:17 | {{.*}} | Ref
357 // CHECK: [[@LINE-3]]:17 | enum/C | AnotherEnum | [[AnotherEnum_USR:.*]] | {{.*}} | Def | rel: 0
358   AnotherEnumFirst = 0,
359   AnotherEnumSecond = 1,
360   AnotherEnumThird = 2,
363 AnotherEnum anotherT;
364 // CHECK: [[@LINE-1]]:1 | enum/C | AnotherEnum | [[AnotherEnum_USR]] | {{.*}} | Ref,RelCont | rel: 1
365 enum AnotherEnum anotherE;
366 // CHECK: [[@LINE-1]]:6 | enum/C | AnotherEnum | [[AnotherEnum_USR]] | {{.*}} | Ref,RelCont | rel: 1
368 #define TRANSPARENT(_name) struct _name _name; struct _name
369 #define OPAQUE(_name) struct _name *_name; struct _name
371 typedef TRANSPARENT(AStruct) {
372   int x;
375 AStruct aStructT;
376 // CHECK: [[@LINE-1]]:1 | struct/C | AStruct | {{.*}} | {{.*}} | Ref,RelCont | rel: 1
377 struct AStruct aStructS;
378 // CHECK: [[@LINE-1]]:8 | struct/C | AStruct | {{.*}} | {{.*}} | Ref,RelCont | rel: 1
380 typedef OPAQUE(Separate) {
381   int x;
384 Separate separateT;
385 // CHECK: [[@LINE-1]]:1 | type-alias/C | Separate | {{.*}} | {{.*}} | Ref,RelCont | rel: 1
386 struct Separate separateE;
387 // CHECK: [[@LINE-1]]:8 | struct/C | Separate | {{.*}} | {{.*}} | Ref,RelCont | rel: 1
389 @interface ClassReceivers
391 @property(class) int p1;
392 // CHECK: [[@LINE-1]]:22 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
393 // CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers
394 // CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1
395 // CHECK: [[@LINE-4]]:22 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Decl,Dyn,Impl,RelChild,RelAcc | rel: 2
396 // CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers
397 // CHECK-NEXT: RelAcc | p1 | c:objc(cs)ClassReceivers(cpy)p1
398 // CHECK: [[@LINE-7]]:22 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Decl,RelChild | rel: 1
399 // CHECK-NEXT: RelChild | ClassReceivers | c:objc(cs)ClassReceivers
401 + (int)implicit;
402 + (void)setImplicit:(int)x;
404 @end
406 void classReceivers() {
407   ClassReceivers.p1 = 0;
408 // CHECK: [[@LINE-1]]:18 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,Writ,RelCont | rel: 1
409 // CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
410 // CHECK: [[@LINE-3]]:3 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
411 // CHECK: [[@LINE-4]]:18 | class-method/acc-set/ObjC | setP1: | c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | Ref,Call,Impl,RelCall,RelCont | rel: 1
412 // CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
413   (void)ClassReceivers.p1;
414 // CHECK: [[@LINE-1]]:24 | instance-property/ObjC | p1 | c:objc(cs)ClassReceivers(cpy)p1 | <no-cgname> | Ref,RelCont | rel: 1
415 // CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
416 // CHECK: [[@LINE-3]]:9 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
417 // CHECK: [[@LINE-4]]:24 | class-method/acc-get/ObjC | p1 | c:objc(cs)ClassReceivers(cm)p1 | +[ClassReceivers p1] | Ref,Call,Impl,RelCall,RelCont | rel: 1
418 // CHECK-NEXT: RelCall,RelCont | classReceivers | c:@F@classReceivers
420   ClassReceivers.implicit = 0;
421 // CHECK: [[@LINE-1]]:3 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
422   (void)ClassReceivers.implicit;
423 // CHECK: [[@LINE-1]]:9 | class/ObjC | ClassReceivers | c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
426 @interface ImplicitProperties
428 - (int)implicit;
429 - (void)setImplicit:(int)x;
431 + (int)classImplicit;
432 + (void)setClassImplicit:(int)y;
434 @end
436 void testImplicitProperties(ImplicitProperties *c) {
437   c.implicit = 0;
438 // CHECK: [[@LINE-1]]:5 | instance-method/ObjC | setImplicit: | c:objc(cs)ImplicitProperties(im)setImplicit: | -[ImplicitProperties setImplicit:] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
439 // CHECK-NEXT: RelCall,RelCont | testImplicitProperties | c:@F@testImplicitProperties
440   c.implicit;
441 // CHECK: [[@LINE-1]]:5 | instance-method/ObjC | implicit | c:objc(cs)ImplicitProperties(im)implicit | -[ImplicitProperties implicit] | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 2
442 // CHECK-NEXT: RelCall,RelCont | testImplicitProperties | c:@F@testImplicitProperties
443   ImplicitProperties.classImplicit = 1;
444 // CHECK: [[@LINE-1]]:22 | class-method/ObjC | setClassImplicit: | c:objc(cs)ImplicitProperties(cm)setClassImplicit: | +[ImplicitProperties setClassImplicit:] | Ref,Call,RelCall,RelCont | rel: 1
445 // CHECK-NEXT: RelCall,RelCont | testImplicitProperties | c:@F@testImplicitProperties
446   ImplicitProperties.classImplicit;
447 // CHECK: [[@LINE-1]]:22 | class-method/ObjC | classImplicit | c:objc(cs)ImplicitProperties(cm)classImplicit | +[ImplicitProperties classImplicit] | Ref,Call,RelCall,RelCont | rel: 1
448 // CHECK-NEXT: RelCall,RelCont | testImplicitProperties | c:@F@testImplicitProperties
451 @interface EmptySelectors
453 - (int):(int)_; // CHECK: [[@LINE]]:8 | instance-method/ObjC | : | c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
454 - (void)test: (int)x :(int)y; // CHECK: [[@LINE]]:9 | instance-method/ObjC | test:: | c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
455 - (void):(int)_ :(int)m:(int)z; // CHECK: [[@LINE]]:9 | instance-method/ObjC | ::: | c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors :::]
457 @end
459 @implementation EmptySelectors
461 - (int):(int)_ { // CHECK: [[@LINE]]:8 | instance-method/ObjC | : | c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
462   [self :2]; // CHECK: [[@LINE]]:9 | instance-method/ObjC | : | c:objc(cs)EmptySelectors(im): | -[EmptySelectors :]
463   return 0;
466 - (void)test: (int)x :(int)y { // CHECK: [[@LINE]]:9 | instance-method/ObjC | test:: | c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
469 - (void) :(int)_ :(int)m :(int)z { // CHECK: [[@LINE]]:10 | instance-method/ObjC | ::: | c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors :::]
470   [self test:0:1]; // CHECK: [[@LINE]]:9 | instance-method/ObjC | test:: | c:objc(cs)EmptySelectors(im)test:: | -[EmptySelectors test::]
471   [self: 0: 1: 2]; // CHECK: [[@LINE]]:8 | instance-method/ObjC | ::: | c:objc(cs)EmptySelectors(im)::: | -[EmptySelectors :::]
474 @end
476 @protocol Prot3 // CHECK: [[@LINE]]:11 | protocol/ObjC | Prot3 | [[PROT3_USR:.*]] | <no-cgname> | Decl |
477 -(void)meth; // CHECK: [[@LINE]]:8 | instance-method(protocol)/ObjC | meth | [[PROT3_meth_USR:.*]] | -[Prot3 meth] | Decl,Dyn,RelChild |
478 @end
480 void test_rec1() {
481   id<Prot3, Prot1> o1;
482   [o1 meth]; // CHECK: [[@LINE]]:7 | instance-method(protocol)/ObjC | meth | [[PROT3_meth_USR]] | {{.*}} | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 3
483     // CHECK-NEXT: RelCall,RelCont | test_rec1 |
484     // CHECK-NEXT: RelRec | Prot3 | [[PROT3_USR]]
485     // CHECK-NEXT: RelRec | Prot1 | [[PROT1_USR]]
486   Base<Prot3, Prot1> *o2;
487   [o2 meth]; // CHECK: [[@LINE]]:7 | instance-method/ObjC | meth | {{.*}} | Ref,Call,Dyn,RelRec,RelCall,RelCont | rel: 4
488     // CHECK-NEXT: RelCall,RelCont | test_rec1 |
489     // CHECK-NEXT: RelRec | Base | [[BASE_USR]]
490     // CHECK-NEXT: RelRec | Prot3 | [[PROT3_USR]]
491     // CHECK-NEXT: RelRec | Prot1 | [[PROT1_USR]]