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