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