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@end
23
24@interface Derived : Super {
25  char Ivar;
26}
27- (char)getIvar;
28@end
29
30//--- reference.output.json.in
31{
32  "metadata": {
33    "formatVersion": {
34      "major": 0,
35      "minor": 5,
36      "patch": 3
37    },
38    "generator": "?"
39  },
40  "module": {
41    "name": "",
42    "platform": {
43      "architecture": "arm64",
44      "operatingSystem": {
45        "minimumVersion": {
46          "major": 11,
47          "minor": 0,
48          "patch": 0
49        },
50        "name": "macosx"
51      },
52      "vendor": "apple"
53    }
54  },
55  "relationhips": [
56    {
57      "kind": "memberOf",
58      "source": "c:objc(cs)Super(cm)getWithProperty:",
59      "target": "c:objc(cs)Super"
60    },
61    {
62      "kind": "memberOf",
63      "source": "c:objc(cs)Super(py)Property",
64      "target": "c:objc(cs)Super"
65    },
66    {
67      "kind": "conformsTo",
68      "source": "c:objc(cs)Super",
69      "target": "c:objc(pl)Protocol"
70    },
71    {
72      "kind": "memberOf",
73      "source": "c:objc(cs)Derived@Ivar",
74      "target": "c:objc(cs)Derived"
75    },
76    {
77      "kind": "memberOf",
78      "source": "c:objc(cs)Derived(im)getIvar",
79      "target": "c:objc(cs)Derived"
80    },
81    {
82      "kind": "inheritsFrom",
83      "source": "c:objc(cs)Derived",
84      "target": "c:objc(cs)Super"
85    }
86  ],
87  "symbols": [
88    {
89      "declarationFragments": [
90        {
91          "kind": "keyword",
92          "spelling": "@interface"
93        },
94        {
95          "kind": "text",
96          "spelling": " "
97        },
98        {
99          "kind": "identifier",
100          "spelling": "Super"
101        }
102      ],
103      "identifier": {
104        "interfaceLanguage": "objective-c",
105        "precise": "c:objc(cs)Super"
106      },
107      "kind": {
108        "displayName": "Class",
109        "identifier": "objective-c.class"
110      },
111      "location": {
112        "character": 12,
113        "line": 3,
114        "uri": "file://INPUT_DIR/input.h"
115      },
116      "names": {
117        "subHeading": [
118          {
119            "kind": "identifier",
120            "spelling": "Super"
121          }
122        ],
123        "title": "Super"
124      }
125    },
126    {
127      "declarationFragments": [
128        {
129          "kind": "text",
130          "spelling": "+ ("
131        },
132        {
133          "kind": "keyword",
134          "spelling": "id"
135        },
136        {
137          "kind": "text",
138          "spelling": ")"
139        },
140        {
141          "kind": "identifier",
142          "spelling": "getWithProperty"
143        },
144        {
145          "kind": "text",
146          "spelling": ":"
147        },
148        {
149          "kind": "text",
150          "spelling": "("
151        },
152        {
153          "kind": "typeIdentifier",
154          "preciseIdentifier": "c:i",
155          "spelling": "unsigned int"
156        },
157        {
158          "kind": "text",
159          "spelling": ")"
160        },
161        {
162          "kind": "internalParam",
163          "spelling": "Property"
164        }
165      ],
166      "identifier": {
167        "interfaceLanguage": "objective-c",
168        "precise": "c:objc(cs)Super(cm)getWithProperty:"
169      },
170      "kind": {
171        "displayName": "Type Method",
172        "identifier": "objective-c.type.method"
173      },
174      "location": {
175        "character": 1,
176        "line": 5,
177        "uri": "file://INPUT_DIR/input.h"
178      },
179      "names": {
180        "subHeading": [
181          {
182            "kind": "text",
183            "spelling": "+ "
184          },
185          {
186            "kind": "identifier",
187            "spelling": "getWithProperty:"
188          }
189        ],
190        "title": "getWithProperty:"
191      }
192    },
193    {
194      "declarationFragments": [
195        {
196          "kind": "keyword",
197          "spelling": "@property"
198        },
199        {
200          "kind": "text",
201          "spelling": " ("
202        },
203        {
204          "kind": "keyword",
205          "spelling": "atomic"
206        },
207        {
208          "kind": "text",
209          "spelling": ", "
210        },
211        {
212          "kind": "keyword",
213          "spelling": "readonly"
214        },
215        {
216          "kind": "text",
217          "spelling": ", "
218        },
219        {
220          "kind": "keyword",
221          "spelling": "getter"
222        },
223        {
224          "kind": "text",
225          "spelling": "="
226        },
227        {
228          "kind": "identifier",
229          "spelling": "getProperty"
230        },
231        {
232          "kind": "text",
233          "spelling": ")"
234        },
235        {
236          "kind": "typeIdentifier",
237          "preciseIdentifier": "c:i",
238          "spelling": "unsigned int"
239        },
240        {
241          "kind": "identifier",
242          "spelling": "Property"
243        }
244      ],
245      "identifier": {
246        "interfaceLanguage": "objective-c",
247        "precise": "c:objc(cs)Super(py)Property"
248      },
249      "kind": {
250        "displayName": "Instance Property",
251        "identifier": "objective-c.property"
252      },
253      "location": {
254        "character": 50,
255        "line": 4,
256        "uri": "file://INPUT_DIR/input.h"
257      },
258      "names": {
259        "subHeading": [
260          {
261            "kind": "identifier",
262            "spelling": "Property"
263          }
264        ],
265        "title": "Property"
266      }
267    },
268    {
269      "declarationFragments": [
270        {
271          "kind": "keyword",
272          "spelling": "@interface"
273        },
274        {
275          "kind": "text",
276          "spelling": " "
277        },
278        {
279          "kind": "identifier",
280          "spelling": "Derived"
281        },
282        {
283          "kind": "text",
284          "spelling": " : "
285        },
286        {
287          "kind": "typeIdentifier",
288          "preciseIdentifier": "c:objc(cs)Super",
289          "spelling": "Super"
290        }
291      ],
292      "identifier": {
293        "interfaceLanguage": "objective-c",
294        "precise": "c:objc(cs)Derived"
295      },
296      "kind": {
297        "displayName": "Class",
298        "identifier": "objective-c.class"
299      },
300      "location": {
301        "character": 12,
302        "line": 8,
303        "uri": "file://INPUT_DIR/input.h"
304      },
305      "names": {
306        "subHeading": [
307          {
308            "kind": "identifier",
309            "spelling": "Derived"
310          }
311        ],
312        "title": "Derived"
313      }
314    },
315    {
316      "declarationFragments": [
317        {
318          "kind": "typeIdentifier",
319          "preciseIdentifier": "c:C",
320          "spelling": "char"
321        },
322        {
323          "kind": "text",
324          "spelling": " "
325        },
326        {
327          "kind": "identifier",
328          "spelling": "Ivar"
329        }
330      ],
331      "identifier": {
332        "interfaceLanguage": "objective-c",
333        "precise": "c:objc(cs)Derived@Ivar"
334      },
335      "kind": {
336        "displayName": "Instance Variable",
337        "identifier": "objective-c.ivar"
338      },
339      "location": {
340        "character": 8,
341        "line": 9,
342        "uri": "file://INPUT_DIR/input.h"
343      },
344      "names": {
345        "subHeading": [
346          {
347            "kind": "identifier",
348            "spelling": "Ivar"
349          }
350        ],
351        "title": "Ivar"
352      }
353    },
354    {
355      "declarationFragments": [
356        {
357          "kind": "text",
358          "spelling": "- ("
359        },
360        {
361          "kind": "typeIdentifier",
362          "preciseIdentifier": "c:C",
363          "spelling": "char"
364        },
365        {
366          "kind": "text",
367          "spelling": ")"
368        },
369        {
370          "kind": "identifier",
371          "spelling": "getIvar"
372        }
373      ],
374      "identifier": {
375        "interfaceLanguage": "objective-c",
376        "precise": "c:objc(cs)Derived(im)getIvar"
377      },
378      "kind": {
379        "displayName": "Instance Method",
380        "identifier": "objective-c.method"
381      },
382      "location": {
383        "character": 1,
384        "line": 11,
385        "uri": "file://INPUT_DIR/input.h"
386      },
387      "names": {
388        "subHeading": [
389          {
390            "kind": "text",
391            "spelling": "- "
392          },
393          {
394            "kind": "identifier",
395            "spelling": "getIvar"
396          }
397        ],
398        "title": "getIvar"
399      }
400    }
401  ]
402}
403