Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ExtractAPI / objc_module_category.m
blob351c96e1fbad0c843d4782212094633df6303dc4
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/input.h -o %t/output.json | FileCheck -allow-empty %s
9 // Generator version is not consistent across test runs, normalize it.
10 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
11 // RUN: %t/output.json >> %t/output-normalized.json
12 // RUN: diff %t/reference.output.json %t/output-normalized.json
14 // CHECK-NOT: error:
15 // CHECK-NOT: warning:
17 //--- input.h
18 #import "Foundation.h"
20 /// Doc comment 1
21 @interface NSString (Category1)
22 -(void)method1;
23 @end
25 /// Doc comment 2
26 @interface NSString (Category2)
27 -(void)method2;
28 @end
30 //--- Foundation.h
31 @interface NSString
32 @end
34 //--- reference.output.json.in
36   "metadata": {
37     "formatVersion": {
38       "major": 0,
39       "minor": 5,
40       "patch": 3
41     },
42     "generator": "?"
43   },
44   "module": {
45     "name": "",
46     "platform": {
47       "architecture": "arm64",
48       "operatingSystem": {
49         "minimumVersion": {
50           "major": 11,
51           "minor": 0,
52           "patch": 0
53         },
54         "name": "macosx"
55       },
56       "vendor": "apple"
57     }
58   },
59   "relationships": [
60     {
61       "kind": "extensionTo",
62       "source": "c:objc(cy)NSString@Category1",
63       "target": "c:objc(cs)NSString",
64       "targetFallback": "NSString"
65     },
66     {
67       "kind": "memberOf",
68       "source": "c:objc(cs)NSString(im)method1",
69       "target": "c:objc(cy)NSString@Category1",
70       "targetFallback": "Category1"
71     },
72     {
73       "kind": "extensionTo",
74       "source": "c:objc(cy)NSString@Category2",
75       "target": "c:objc(cs)NSString",
76       "targetFallback": "NSString"
77     },
78     {
79       "kind": "memberOf",
80       "source": "c:objc(cs)NSString(im)method2",
81       "target": "c:objc(cy)NSString@Category2",
82       "targetFallback": "Category2"
83     }
84   ],
85   "symbols": [
86     {
87       "accessLevel": "public",
88       "identifier": {
89         "interfaceLanguage": "objective-c",
90         "precise": "c:objc(cy)NSString@Category1"
91       },
92       "kind": {
93         "displayName": "Module Extension",
94         "identifier": "objective-c.module.extension"
95       }
96     },
97     {
98       "accessLevel": "public",
99       "declarationFragments": [
100         {
101           "kind": "keyword",
102           "spelling": "@interface"
103         },
104         {
105           "kind": "text",
106           "spelling": " "
107         },
108         {
109           "kind": "typeIdentifier",
110           "preciseIdentifier": "c:objc(cs)NSString",
111           "spelling": "NSString"
112         },
113         {
114           "kind": "text",
115           "spelling": " ("
116         },
117         {
118           "kind": "identifier",
119           "spelling": "Category1"
120         },
121         {
122           "kind": "text",
123           "spelling": ")"
124         }
125       ],
126       "docComment": {
127         "lines": [
128           {
129             "range": {
130               "end": {
131                 "character": 18,
132                 "line": 3
133               },
134               "start": {
135                 "character": 5,
136                 "line": 3
137               }
138             },
139             "text": "Doc comment 1"
140           }
141         ]
142       },
143       "identifier": {
144         "interfaceLanguage": "objective-c",
145         "precise": "c:objc(cy)NSString@Category1"
146       },
147       "kind": {
148         "displayName": "Class Extension",
149         "identifier": "objective-c.class.extension"
150       },
151       "location": {
152         "position": {
153           "character": 12,
154           "line": 4
155         },
156         "uri": "file://INPUT_DIR/input.h"
157       },
158       "names": {
159         "navigator": [
160           {
161             "kind": "identifier",
162             "spelling": "Category1"
163           }
164         ],
165         "subHeading": [
166           {
167             "kind": "identifier",
168             "spelling": "Category1"
169           }
170         ],
171         "title": "NSString (Category1)"
172       },
173       "pathComponents": [
174         "Category1"
175       ]
176     },
177     {
178       "accessLevel": "public",
179       "declarationFragments": [
180         {
181           "kind": "text",
182           "spelling": "- ("
183         },
184         {
185           "kind": "typeIdentifier",
186           "preciseIdentifier": "c:v",
187           "spelling": "void"
188         },
189         {
190           "kind": "text",
191           "spelling": ") "
192         },
193         {
194           "kind": "identifier",
195           "spelling": "method1"
196         },
197         {
198           "kind": "text",
199           "spelling": ";"
200         }
201       ],
202       "functionSignature": {
203         "returns": [
204           {
205             "kind": "typeIdentifier",
206             "preciseIdentifier": "c:v",
207             "spelling": "void"
208           }
209         ]
210       },
211       "identifier": {
212         "interfaceLanguage": "objective-c",
213         "precise": "c:objc(cs)NSString(im)method1"
214       },
215       "kind": {
216         "displayName": "Instance Method",
217         "identifier": "objective-c.method"
218       },
219       "location": {
220         "position": {
221           "character": 1,
222           "line": 5
223         },
224         "uri": "file://INPUT_DIR/input.h"
225       },
226       "names": {
227         "navigator": [
228           {
229             "kind": "identifier",
230             "spelling": "method1"
231           }
232         ],
233         "subHeading": [
234           {
235             "kind": "text",
236             "spelling": "- "
237           },
238           {
239             "kind": "identifier",
240             "spelling": "method1"
241           }
242         ],
243         "title": "method1"
244       },
245       "pathComponents": [
246         "Category1",
247         "method1"
248       ]
249     },
250     {
251       "accessLevel": "public",
252       "declarationFragments": [
253         {
254           "kind": "keyword",
255           "spelling": "@interface"
256         },
257         {
258           "kind": "text",
259           "spelling": " "
260         },
261         {
262           "kind": "typeIdentifier",
263           "preciseIdentifier": "c:objc(cs)NSString",
264           "spelling": "NSString"
265         },
266         {
267           "kind": "text",
268           "spelling": " ("
269         },
270         {
271           "kind": "identifier",
272           "spelling": "Category2"
273         },
274         {
275           "kind": "text",
276           "spelling": ")"
277         }
278       ],
279       "docComment": {
280         "lines": [
281           {
282             "range": {
283               "end": {
284                 "character": 18,
285                 "line": 8
286               },
287               "start": {
288                 "character": 5,
289                 "line": 8
290               }
291             },
292             "text": "Doc comment 2"
293           }
294         ]
295       },
296       "identifier": {
297         "interfaceLanguage": "objective-c",
298         "precise": "c:objc(cy)NSString@Category2"
299       },
300       "kind": {
301         "displayName": "Class Extension",
302         "identifier": "objective-c.class.extension"
303       },
304       "location": {
305         "position": {
306           "character": 12,
307           "line": 9
308         },
309         "uri": "file://INPUT_DIR/input.h"
310       },
311       "names": {
312         "navigator": [
313           {
314             "kind": "identifier",
315             "spelling": "Category2"
316           }
317         ],
318         "subHeading": [
319           {
320             "kind": "identifier",
321             "spelling": "Category2"
322           }
323         ],
324         "title": "NSString (Category2)"
325       },
326       "pathComponents": [
327         "Category2"
328       ]
329     },
330     {
331       "accessLevel": "public",
332       "declarationFragments": [
333         {
334           "kind": "text",
335           "spelling": "- ("
336         },
337         {
338           "kind": "typeIdentifier",
339           "preciseIdentifier": "c:v",
340           "spelling": "void"
341         },
342         {
343           "kind": "text",
344           "spelling": ") "
345         },
346         {
347           "kind": "identifier",
348           "spelling": "method2"
349         },
350         {
351           "kind": "text",
352           "spelling": ";"
353         }
354       ],
355       "functionSignature": {
356         "returns": [
357           {
358             "kind": "typeIdentifier",
359             "preciseIdentifier": "c:v",
360             "spelling": "void"
361           }
362         ]
363       },
364       "identifier": {
365         "interfaceLanguage": "objective-c",
366         "precise": "c:objc(cs)NSString(im)method2"
367       },
368       "kind": {
369         "displayName": "Instance Method",
370         "identifier": "objective-c.method"
371       },
372       "location": {
373         "position": {
374           "character": 1,
375           "line": 10
376         },
377         "uri": "file://INPUT_DIR/input.h"
378       },
379       "names": {
380         "navigator": [
381           {
382             "kind": "identifier",
383             "spelling": "method2"
384           }
385         ],
386         "subHeading": [
387           {
388             "kind": "text",
389             "spelling": "- "
390           },
391           {
392             "kind": "identifier",
393             "spelling": "method2"
394           }
395         ],
396         "title": "method2"
397       },
398       "pathComponents": [
399         "Category2",
400         "method2"
401       ]
402     }
403   ]