Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ExtractAPI / objc_various_categories.m
blobf06663c8696d7b6d39dfbfeeef74eaaaedd853e2
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 -extract-api -x objective-c-header \
6 // RUN: -target arm64-apple-macosx \
7 // RUN: %t/myclass_1.h \
8 // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
10 // Generator version is not consistent across test runs, normalize it.
11 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
12 // RUN: %t/output.json >> %t/output-normalized.json
13 // RUN: diff %t/reference.output.json %t/output-normalized.json
15 // CHECK-NOT: error:
16 // CHECK-NOT: warning:
18 //--- input.h
19 #import "myclass_1.h"
20 #import "Foundation.h"
22 @interface MyClass1 (MyCategory1)
23 - (int) SomeMethod;
24 @end
26 @interface NSString (Category1)
27 -(void) StringMethod;
28 @end
30 @interface NSString (Category2)
31 -(void) StringMethod2;
32 @end
34 //--- myclass_1.h
35 @interface MyClass1
36 @end
38 //--- Foundation.h
39 @interface NSString
40 @end
42 //--- reference.output.json.in
44   "metadata": {
45     "formatVersion": {
46       "major": 0,
47       "minor": 5,
48       "patch": 3
49     },
50     "generator": "?"
51   },
52   "module": {
53     "name": "",
54     "platform": {
55       "architecture": "arm64",
56       "operatingSystem": {
57         "minimumVersion": {
58           "major": 11,
59           "minor": 0,
60           "patch": 0
61         },
62         "name": "macosx"
63       },
64       "vendor": "apple"
65     }
66   },
67   "relationships": [
68     {
69       "kind": "memberOf",
70       "source": "c:objc(cs)MyClass1(im)SomeMethod",
71       "target": "c:objc(cs)MyClass1",
72       "targetFallback": "MyClass1"
73     },
74     {
75       "kind": "extensionTo",
76       "source": "c:objc(cy)NSString@Category1",
77       "target": "c:objc(cs)NSString",
78       "targetFallback": "NSString"
79     },
80     {
81       "kind": "memberOf",
82       "source": "c:objc(cs)NSString(im)StringMethod",
83       "target": "c:objc(cy)NSString@Category1",
84       "targetFallback": "Category1"
85     },
86     {
87       "kind": "extensionTo",
88       "source": "c:objc(cy)NSString@Category2",
89       "target": "c:objc(cs)NSString",
90       "targetFallback": "NSString"
91     },
92     {
93       "kind": "memberOf",
94       "source": "c:objc(cs)NSString(im)StringMethod2",
95       "target": "c:objc(cy)NSString@Category2",
96       "targetFallback": "Category2"
97     }
98   ],
99   "symbols": [
100     {
101       "accessLevel": "public",
102       "declarationFragments": [
103         {
104           "kind": "keyword",
105           "spelling": "@interface"
106         },
107         {
108           "kind": "text",
109           "spelling": " "
110         },
111         {
112           "kind": "identifier",
113           "spelling": "MyClass1"
114         }
115       ],
116       "identifier": {
117         "interfaceLanguage": "objective-c",
118         "precise": "c:objc(cs)MyClass1"
119       },
120       "kind": {
121         "displayName": "Class",
122         "identifier": "objective-c.class"
123       },
124       "location": {
125         "position": {
126           "character": 12,
127           "line": 1
128         },
129         "uri": "file://INPUT_DIR/myclass_1.h"
130       },
131       "names": {
132         "navigator": [
133           {
134             "kind": "identifier",
135             "spelling": "MyClass1"
136           }
137         ],
138         "subHeading": [
139           {
140             "kind": "identifier",
141             "spelling": "MyClass1"
142           }
143         ],
144         "title": "MyClass1"
145       },
146       "pathComponents": [
147         "MyClass1"
148       ]
149     },
150     {
151       "accessLevel": "public",
152       "declarationFragments": [
153         {
154           "kind": "text",
155           "spelling": "- ("
156         },
157         {
158           "kind": "typeIdentifier",
159           "preciseIdentifier": "c:I",
160           "spelling": "int"
161         },
162         {
163           "kind": "text",
164           "spelling": ") "
165         },
166         {
167           "kind": "identifier",
168           "spelling": "SomeMethod"
169         },
170         {
171           "kind": "text",
172           "spelling": ";"
173         }
174       ],
175       "functionSignature": {
176         "returns": [
177           {
178             "kind": "typeIdentifier",
179             "preciseIdentifier": "c:I",
180             "spelling": "int"
181           }
182         ]
183       },
184       "identifier": {
185         "interfaceLanguage": "objective-c",
186         "precise": "c:objc(cs)MyClass1(im)SomeMethod"
187       },
188       "kind": {
189         "displayName": "Instance Method",
190         "identifier": "objective-c.method"
191       },
192       "location": {
193         "position": {
194           "character": 1,
195           "line": 5
196         },
197         "uri": "file://INPUT_DIR/input.h"
198       },
199       "names": {
200         "navigator": [
201           {
202             "kind": "identifier",
203             "spelling": "SomeMethod"
204           }
205         ],
206         "subHeading": [
207           {
208             "kind": "text",
209             "spelling": "- "
210           },
211           {
212             "kind": "identifier",
213             "spelling": "SomeMethod"
214           }
215         ],
216         "title": "SomeMethod"
217       },
218       "pathComponents": [
219         "MyClass1",
220         "SomeMethod"
221       ]
222     },
223     {
224       "accessLevel": "public",
225       "identifier": {
226         "interfaceLanguage": "objective-c",
227         "precise": "c:objc(cy)NSString@Category1"
228       },
229       "kind": {
230         "displayName": "Module Extension",
231         "identifier": "objective-c.module.extension"
232       }
233     },
234     {
235       "accessLevel": "public",
236       "declarationFragments": [
237         {
238           "kind": "keyword",
239           "spelling": "@interface"
240         },
241         {
242           "kind": "text",
243           "spelling": " "
244         },
245         {
246           "kind": "typeIdentifier",
247           "preciseIdentifier": "c:objc(cs)NSString",
248           "spelling": "NSString"
249         },
250         {
251           "kind": "text",
252           "spelling": " ("
253         },
254         {
255           "kind": "identifier",
256           "spelling": "Category1"
257         },
258         {
259           "kind": "text",
260           "spelling": ")"
261         }
262       ],
263       "identifier": {
264         "interfaceLanguage": "objective-c",
265         "precise": "c:objc(cy)NSString@Category1"
266       },
267       "kind": {
268         "displayName": "Class Extension",
269         "identifier": "objective-c.class.extension"
270       },
271       "location": {
272         "position": {
273           "character": 12,
274           "line": 8
275         },
276         "uri": "file://INPUT_DIR/input.h"
277       },
278       "names": {
279         "navigator": [
280           {
281             "kind": "identifier",
282             "spelling": "Category1"
283           }
284         ],
285         "subHeading": [
286           {
287             "kind": "identifier",
288             "spelling": "Category1"
289           }
290         ],
291         "title": "NSString (Category1)"
292       },
293       "pathComponents": [
294         "Category1"
295       ]
296     },
297     {
298       "accessLevel": "public",
299       "declarationFragments": [
300         {
301           "kind": "text",
302           "spelling": "- ("
303         },
304         {
305           "kind": "typeIdentifier",
306           "preciseIdentifier": "c:v",
307           "spelling": "void"
308         },
309         {
310           "kind": "text",
311           "spelling": ") "
312         },
313         {
314           "kind": "identifier",
315           "spelling": "StringMethod"
316         },
317         {
318           "kind": "text",
319           "spelling": ";"
320         }
321       ],
322       "functionSignature": {
323         "returns": [
324           {
325             "kind": "typeIdentifier",
326             "preciseIdentifier": "c:v",
327             "spelling": "void"
328           }
329         ]
330       },
331       "identifier": {
332         "interfaceLanguage": "objective-c",
333         "precise": "c:objc(cs)NSString(im)StringMethod"
334       },
335       "kind": {
336         "displayName": "Instance Method",
337         "identifier": "objective-c.method"
338       },
339       "location": {
340         "position": {
341           "character": 1,
342           "line": 9
343         },
344         "uri": "file://INPUT_DIR/input.h"
345       },
346       "names": {
347         "navigator": [
348           {
349             "kind": "identifier",
350             "spelling": "StringMethod"
351           }
352         ],
353         "subHeading": [
354           {
355             "kind": "text",
356             "spelling": "- "
357           },
358           {
359             "kind": "identifier",
360             "spelling": "StringMethod"
361           }
362         ],
363         "title": "StringMethod"
364       },
365       "pathComponents": [
366         "Category1",
367         "StringMethod"
368       ]
369     },
370     {
371       "accessLevel": "public",
372       "declarationFragments": [
373         {
374           "kind": "keyword",
375           "spelling": "@interface"
376         },
377         {
378           "kind": "text",
379           "spelling": " "
380         },
381         {
382           "kind": "typeIdentifier",
383           "preciseIdentifier": "c:objc(cs)NSString",
384           "spelling": "NSString"
385         },
386         {
387           "kind": "text",
388           "spelling": " ("
389         },
390         {
391           "kind": "identifier",
392           "spelling": "Category2"
393         },
394         {
395           "kind": "text",
396           "spelling": ")"
397         }
398       ],
399       "identifier": {
400         "interfaceLanguage": "objective-c",
401         "precise": "c:objc(cy)NSString@Category2"
402       },
403       "kind": {
404         "displayName": "Class Extension",
405         "identifier": "objective-c.class.extension"
406       },
407       "location": {
408         "position": {
409           "character": 12,
410           "line": 12
411         },
412         "uri": "file://INPUT_DIR/input.h"
413       },
414       "names": {
415         "navigator": [
416           {
417             "kind": "identifier",
418             "spelling": "Category2"
419           }
420         ],
421         "subHeading": [
422           {
423             "kind": "identifier",
424             "spelling": "Category2"
425           }
426         ],
427         "title": "NSString (Category2)"
428       },
429       "pathComponents": [
430         "Category2"
431       ]
432     },
433     {
434       "accessLevel": "public",
435       "declarationFragments": [
436         {
437           "kind": "text",
438           "spelling": "- ("
439         },
440         {
441           "kind": "typeIdentifier",
442           "preciseIdentifier": "c:v",
443           "spelling": "void"
444         },
445         {
446           "kind": "text",
447           "spelling": ") "
448         },
449         {
450           "kind": "identifier",
451           "spelling": "StringMethod2"
452         },
453         {
454           "kind": "text",
455           "spelling": ";"
456         }
457       ],
458       "functionSignature": {
459         "returns": [
460           {
461             "kind": "typeIdentifier",
462             "preciseIdentifier": "c:v",
463             "spelling": "void"
464           }
465         ]
466       },
467       "identifier": {
468         "interfaceLanguage": "objective-c",
469         "precise": "c:objc(cs)NSString(im)StringMethod2"
470       },
471       "kind": {
472         "displayName": "Instance Method",
473         "identifier": "objective-c.method"
474       },
475       "location": {
476         "position": {
477           "character": 1,
478           "line": 13
479         },
480         "uri": "file://INPUT_DIR/input.h"
481       },
482       "names": {
483         "navigator": [
484           {
485             "kind": "identifier",
486             "spelling": "StringMethod2"
487           }
488         ],
489         "subHeading": [
490           {
491             "kind": "text",
492             "spelling": "- "
493           },
494           {
495             "kind": "identifier",
496             "spelling": "StringMethod2"
497           }
498         ],
499         "title": "StringMethod2"
500       },
501       "pathComponents": [
502         "Category2",
503         "StringMethod2"
504       ]
505     }
506   ]