Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ExtractAPI / objc_property.m
blob9c69a1156bffd4187cd7bc7ced3f0a8bf0efdabd
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4 // RUN: %t/reference.output.json.in >> %t/reference.output.json
5 // RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx -x objective-c-header %t/input.h -o %t/output.json -verify
7 // Generator version is not consistent across test runs, normalize it.
8 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
9 // RUN: %t/output.json >> %t/output-normalized.json
10 // RUN: diff %t/reference.output.json %t/output-normalized.json
12 //--- input.h
13 @protocol Protocol
14 @property(class) int myProtocolTypeProp;
15 @property int myProtocolInstanceProp;
16 @end
18 @interface Interface
19 @property(class) int myInterfaceTypeProp;
20 @property int myInterfaceInstanceProp;
21 @end
23 @interface Interface (Category) <Protocol>
24 @property(class) int myCategoryTypeProp;
25 @property int myCategoryInstanceProp;
26 @end
27 // expected-no-diagnostics
29 //--- reference.output.json.in
31   "metadata": {
32     "formatVersion": {
33       "major": 0,
34       "minor": 5,
35       "patch": 3
36     },
37     "generator": "?"
38   },
39   "module": {
40     "name": "",
41     "platform": {
42       "architecture": "arm64",
43       "operatingSystem": {
44         "minimumVersion": {
45           "major": 11,
46           "minor": 0,
47           "patch": 0
48         },
49         "name": "macosx"
50       },
51       "vendor": "apple"
52     }
53   },
54   "relationships": [
55     {
56       "kind": "memberOf",
57       "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
58       "target": "c:objc(cs)Interface",
59       "targetFallback": "Interface"
60     },
61     {
62       "kind": "memberOf",
63       "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
64       "target": "c:objc(cs)Interface",
65       "targetFallback": "Interface"
66     },
67     {
68       "kind": "memberOf",
69       "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
70       "target": "c:objc(cs)Interface",
71       "targetFallback": "Interface"
72     },
73     {
74       "kind": "memberOf",
75       "source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
76       "target": "c:objc(cs)Interface",
77       "targetFallback": "Interface"
78     },
79     {
80       "kind": "conformsTo",
81       "source": "c:objc(cs)Interface",
82       "target": "c:objc(pl)Protocol",
83       "targetFallback": "Protocol"
84     },
85     {
86       "kind": "memberOf",
87       "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
88       "target": "c:objc(pl)Protocol",
89       "targetFallback": "Protocol"
90     },
91     {
92       "kind": "memberOf",
93       "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
94       "target": "c:objc(pl)Protocol",
95       "targetFallback": "Protocol"
96     }
97   ],
98   "symbols": [
99     {
100       "accessLevel": "public",
101       "declarationFragments": [
102         {
103           "kind": "keyword",
104           "spelling": "@interface"
105         },
106         {
107           "kind": "text",
108           "spelling": " "
109         },
110         {
111           "kind": "identifier",
112           "spelling": "Interface"
113         }
114       ],
115       "identifier": {
116         "interfaceLanguage": "objective-c",
117         "precise": "c:objc(cs)Interface"
118       },
119       "kind": {
120         "displayName": "Class",
121         "identifier": "objective-c.class"
122       },
123       "location": {
124         "position": {
125           "character": 12,
126           "line": 6
127         },
128         "uri": "file://INPUT_DIR/input.h"
129       },
130       "names": {
131         "navigator": [
132           {
133             "kind": "identifier",
134             "spelling": "Interface"
135           }
136         ],
137         "subHeading": [
138           {
139             "kind": "identifier",
140             "spelling": "Interface"
141           }
142         ],
143         "title": "Interface"
144       },
145       "pathComponents": [
146         "Interface"
147       ]
148     },
149     {
150       "accessLevel": "public",
151       "declarationFragments": [
152         {
153           "kind": "keyword",
154           "spelling": "@property"
155         },
156         {
157           "kind": "text",
158           "spelling": " ("
159         },
160         {
161           "kind": "keyword",
162           "spelling": "class"
163         },
164         {
165           "kind": "text",
166           "spelling": ") "
167         },
168         {
169           "kind": "typeIdentifier",
170           "preciseIdentifier": "c:I",
171           "spelling": "int"
172         },
173         {
174           "kind": "text",
175           "spelling": " "
176         },
177         {
178           "kind": "identifier",
179           "spelling": "myInterfaceTypeProp"
180         }
181       ],
182       "identifier": {
183         "interfaceLanguage": "objective-c",
184         "precise": "c:objc(cs)Interface(cpy)myInterfaceTypeProp"
185       },
186       "kind": {
187         "displayName": "Type Property",
188         "identifier": "objective-c.type.property"
189       },
190       "location": {
191         "position": {
192           "character": 22,
193           "line": 7
194         },
195         "uri": "file://INPUT_DIR/input.h"
196       },
197       "names": {
198         "navigator": [
199           {
200             "kind": "identifier",
201             "spelling": "myInterfaceTypeProp"
202           }
203         ],
204         "subHeading": [
205           {
206             "kind": "identifier",
207             "spelling": "myInterfaceTypeProp"
208           }
209         ],
210         "title": "myInterfaceTypeProp"
211       },
212       "pathComponents": [
213         "Interface",
214         "myInterfaceTypeProp"
215       ]
216     },
217     {
218       "accessLevel": "public",
219       "declarationFragments": [
220         {
221           "kind": "keyword",
222           "spelling": "@property"
223         },
224         {
225           "kind": "text",
226           "spelling": " "
227         },
228         {
229           "kind": "typeIdentifier",
230           "preciseIdentifier": "c:I",
231           "spelling": "int"
232         },
233         {
234           "kind": "text",
235           "spelling": " "
236         },
237         {
238           "kind": "identifier",
239           "spelling": "myInterfaceInstanceProp"
240         }
241       ],
242       "identifier": {
243         "interfaceLanguage": "objective-c",
244         "precise": "c:objc(cs)Interface(py)myInterfaceInstanceProp"
245       },
246       "kind": {
247         "displayName": "Instance Property",
248         "identifier": "objective-c.property"
249       },
250       "location": {
251         "position": {
252           "character": 15,
253           "line": 8
254         },
255         "uri": "file://INPUT_DIR/input.h"
256       },
257       "names": {
258         "navigator": [
259           {
260             "kind": "identifier",
261             "spelling": "myInterfaceInstanceProp"
262           }
263         ],
264         "subHeading": [
265           {
266             "kind": "identifier",
267             "spelling": "myInterfaceInstanceProp"
268           }
269         ],
270         "title": "myInterfaceInstanceProp"
271       },
272       "pathComponents": [
273         "Interface",
274         "myInterfaceInstanceProp"
275       ]
276     },
277     {
278       "accessLevel": "public",
279       "declarationFragments": [
280         {
281           "kind": "keyword",
282           "spelling": "@property"
283         },
284         {
285           "kind": "text",
286           "spelling": " ("
287         },
288         {
289           "kind": "keyword",
290           "spelling": "class"
291         },
292         {
293           "kind": "text",
294           "spelling": ") "
295         },
296         {
297           "kind": "typeIdentifier",
298           "preciseIdentifier": "c:I",
299           "spelling": "int"
300         },
301         {
302           "kind": "text",
303           "spelling": " "
304         },
305         {
306           "kind": "identifier",
307           "spelling": "myCategoryTypeProp"
308         }
309       ],
310       "identifier": {
311         "interfaceLanguage": "objective-c",
312         "precise": "c:objc(cs)Interface(cpy)myCategoryTypeProp"
313       },
314       "kind": {
315         "displayName": "Type Property",
316         "identifier": "objective-c.type.property"
317       },
318       "location": {
319         "position": {
320           "character": 22,
321           "line": 12
322         },
323         "uri": "file://INPUT_DIR/input.h"
324       },
325       "names": {
326         "navigator": [
327           {
328             "kind": "identifier",
329             "spelling": "myCategoryTypeProp"
330           }
331         ],
332         "subHeading": [
333           {
334             "kind": "identifier",
335             "spelling": "myCategoryTypeProp"
336           }
337         ],
338         "title": "myCategoryTypeProp"
339       },
340       "pathComponents": [
341         "Interface",
342         "myCategoryTypeProp"
343       ]
344     },
345     {
346       "accessLevel": "public",
347       "declarationFragments": [
348         {
349           "kind": "keyword",
350           "spelling": "@property"
351         },
352         {
353           "kind": "text",
354           "spelling": " "
355         },
356         {
357           "kind": "typeIdentifier",
358           "preciseIdentifier": "c:I",
359           "spelling": "int"
360         },
361         {
362           "kind": "text",
363           "spelling": " "
364         },
365         {
366           "kind": "identifier",
367           "spelling": "myCategoryInstanceProp"
368         }
369       ],
370       "identifier": {
371         "interfaceLanguage": "objective-c",
372         "precise": "c:objc(cs)Interface(py)myCategoryInstanceProp"
373       },
374       "kind": {
375         "displayName": "Instance Property",
376         "identifier": "objective-c.property"
377       },
378       "location": {
379         "position": {
380           "character": 15,
381           "line": 13
382         },
383         "uri": "file://INPUT_DIR/input.h"
384       },
385       "names": {
386         "navigator": [
387           {
388             "kind": "identifier",
389             "spelling": "myCategoryInstanceProp"
390           }
391         ],
392         "subHeading": [
393           {
394             "kind": "identifier",
395             "spelling": "myCategoryInstanceProp"
396           }
397         ],
398         "title": "myCategoryInstanceProp"
399       },
400       "pathComponents": [
401         "Interface",
402         "myCategoryInstanceProp"
403       ]
404     },
405     {
406       "accessLevel": "public",
407       "declarationFragments": [
408         {
409           "kind": "keyword",
410           "spelling": "@protocol"
411         },
412         {
413           "kind": "text",
414           "spelling": " "
415         },
416         {
417           "kind": "identifier",
418           "spelling": "Protocol"
419         }
420       ],
421       "identifier": {
422         "interfaceLanguage": "objective-c",
423         "precise": "c:objc(pl)Protocol"
424       },
425       "kind": {
426         "displayName": "Protocol",
427         "identifier": "objective-c.protocol"
428       },
429       "location": {
430         "position": {
431           "character": 11,
432           "line": 1
433         },
434         "uri": "file://INPUT_DIR/input.h"
435       },
436       "names": {
437         "navigator": [
438           {
439             "kind": "identifier",
440             "spelling": "Protocol"
441           }
442         ],
443         "subHeading": [
444           {
445             "kind": "identifier",
446             "spelling": "Protocol"
447           }
448         ],
449         "title": "Protocol"
450       },
451       "pathComponents": [
452         "Protocol"
453       ]
454     },
455     {
456       "accessLevel": "public",
457       "declarationFragments": [
458         {
459           "kind": "keyword",
460           "spelling": "@property"
461         },
462         {
463           "kind": "text",
464           "spelling": " ("
465         },
466         {
467           "kind": "keyword",
468           "spelling": "class"
469         },
470         {
471           "kind": "text",
472           "spelling": ") "
473         },
474         {
475           "kind": "typeIdentifier",
476           "preciseIdentifier": "c:I",
477           "spelling": "int"
478         },
479         {
480           "kind": "text",
481           "spelling": " "
482         },
483         {
484           "kind": "identifier",
485           "spelling": "myProtocolTypeProp"
486         }
487       ],
488       "identifier": {
489         "interfaceLanguage": "objective-c",
490         "precise": "c:objc(pl)Protocol(cpy)myProtocolTypeProp"
491       },
492       "kind": {
493         "displayName": "Type Property",
494         "identifier": "objective-c.type.property"
495       },
496       "location": {
497         "position": {
498           "character": 22,
499           "line": 2
500         },
501         "uri": "file://INPUT_DIR/input.h"
502       },
503       "names": {
504         "navigator": [
505           {
506             "kind": "identifier",
507             "spelling": "myProtocolTypeProp"
508           }
509         ],
510         "subHeading": [
511           {
512             "kind": "identifier",
513             "spelling": "myProtocolTypeProp"
514           }
515         ],
516         "title": "myProtocolTypeProp"
517       },
518       "pathComponents": [
519         "Protocol",
520         "myProtocolTypeProp"
521       ]
522     },
523     {
524       "accessLevel": "public",
525       "declarationFragments": [
526         {
527           "kind": "keyword",
528           "spelling": "@property"
529         },
530         {
531           "kind": "text",
532           "spelling": " "
533         },
534         {
535           "kind": "typeIdentifier",
536           "preciseIdentifier": "c:I",
537           "spelling": "int"
538         },
539         {
540           "kind": "text",
541           "spelling": " "
542         },
543         {
544           "kind": "identifier",
545           "spelling": "myProtocolInstanceProp"
546         }
547       ],
548       "identifier": {
549         "interfaceLanguage": "objective-c",
550         "precise": "c:objc(pl)Protocol(py)myProtocolInstanceProp"
551       },
552       "kind": {
553         "displayName": "Instance Property",
554         "identifier": "objective-c.property"
555       },
556       "location": {
557         "position": {
558           "character": 15,
559           "line": 3
560         },
561         "uri": "file://INPUT_DIR/input.h"
562       },
563       "names": {
564         "navigator": [
565           {
566             "kind": "identifier",
567             "spelling": "myProtocolInstanceProp"
568           }
569         ],
570         "subHeading": [
571           {
572             "kind": "identifier",
573             "spelling": "myProtocolInstanceProp"
574           }
575         ],
576         "title": "myProtocolInstanceProp"
577       },
578       "pathComponents": [
579         "Protocol",
580         "myProtocolInstanceProp"
581       ]
582     }
583   ]