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
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 Interface
20@end
21
22@interface Interface (Category) <Protocol>
23@property int Property;
24- (void)InstanceMethod;
25+ (void)ClassMethod;
26@end
27
28//--- reference.output.json.in
29{
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    },
59    {
60      "kind": "memberOf",
61      "source": "c:objc(cs)Interface(cm)ClassMethod",
62      "target": "c:objc(cs)Interface"
63    },
64    {
65      "kind": "memberOf",
66      "source": "c:objc(cs)Interface(py)Property",
67      "target": "c:objc(cs)Interface"
68    },
69    {
70      "kind": "conformsTo",
71      "source": "c:objc(cs)Interface",
72      "target": "c:objc(pl)Protocol"
73    }
74  ],
75  "symbols": [
76    {
77      "accessLevel": "public",
78      "declarationFragments": [
79        {
80          "kind": "keyword",
81          "spelling": "@interface"
82        },
83        {
84          "kind": "text",
85          "spelling": " "
86        },
87        {
88          "kind": "identifier",
89          "spelling": "Interface"
90        }
91      ],
92      "identifier": {
93        "interfaceLanguage": "objective-c",
94        "precise": "c:objc(cs)Interface"
95      },
96      "kind": {
97        "displayName": "Class",
98        "identifier": "objective-c.class"
99      },
100      "location": {
101        "position": {
102          "character": 12,
103          "line": 3
104        },
105        "uri": "file://INPUT_DIR/input.h"
106      },
107      "names": {
108        "navigator": [
109          {
110            "kind": "identifier",
111            "spelling": "Interface"
112          }
113        ],
114        "subHeading": [
115          {
116            "kind": "identifier",
117            "spelling": "Interface"
118          }
119        ],
120        "title": "Interface"
121      },
122      "pathComponents": [
123        "Interface"
124      ]
125    },
126    {
127      "accessLevel": "public",
128      "declarationFragments": [
129        {
130          "kind": "text",
131          "spelling": "- ("
132        },
133        {
134          "kind": "typeIdentifier",
135          "preciseIdentifier": "c:v",
136          "spelling": "void"
137        },
138        {
139          "kind": "text",
140          "spelling": ") "
141        },
142        {
143          "kind": "identifier",
144          "spelling": "InstanceMethod"
145        },
146        {
147          "kind": "text",
148          "spelling": ";"
149        }
150      ],
151      "functionSignature": {
152        "returns": [
153          {
154            "kind": "typeIdentifier",
155            "preciseIdentifier": "c:v",
156            "spelling": "void"
157          }
158        ]
159      },
160      "identifier": {
161        "interfaceLanguage": "objective-c",
162        "precise": "c:objc(cs)Interface(im)InstanceMethod"
163      },
164      "kind": {
165        "displayName": "Instance Method",
166        "identifier": "objective-c.method"
167      },
168      "location": {
169        "position": {
170          "character": 1,
171          "line": 8
172        },
173        "uri": "file://INPUT_DIR/input.h"
174      },
175      "names": {
176        "navigator": [
177          {
178            "kind": "identifier",
179            "spelling": "InstanceMethod"
180          }
181        ],
182        "subHeading": [
183          {
184            "kind": "text",
185            "spelling": "- "
186          },
187          {
188            "kind": "identifier",
189            "spelling": "InstanceMethod"
190          }
191        ],
192        "title": "InstanceMethod"
193      },
194      "pathComponents": [
195        "Interface",
196        "InstanceMethod"
197      ]
198    },
199    {
200      "accessLevel": "public",
201      "declarationFragments": [
202        {
203          "kind": "text",
204          "spelling": "+ ("
205        },
206        {
207          "kind": "typeIdentifier",
208          "preciseIdentifier": "c:v",
209          "spelling": "void"
210        },
211        {
212          "kind": "text",
213          "spelling": ") "
214        },
215        {
216          "kind": "identifier",
217          "spelling": "ClassMethod"
218        },
219        {
220          "kind": "text",
221          "spelling": ";"
222        }
223      ],
224      "functionSignature": {
225        "returns": [
226          {
227            "kind": "typeIdentifier",
228            "preciseIdentifier": "c:v",
229            "spelling": "void"
230          }
231        ]
232      },
233      "identifier": {
234        "interfaceLanguage": "objective-c",
235        "precise": "c:objc(cs)Interface(cm)ClassMethod"
236      },
237      "kind": {
238        "displayName": "Type Method",
239        "identifier": "objective-c.type.method"
240      },
241      "location": {
242        "position": {
243          "character": 1,
244          "line": 9
245        },
246        "uri": "file://INPUT_DIR/input.h"
247      },
248      "names": {
249        "navigator": [
250          {
251            "kind": "identifier",
252            "spelling": "ClassMethod"
253          }
254        ],
255        "subHeading": [
256          {
257            "kind": "text",
258            "spelling": "+ "
259          },
260          {
261            "kind": "identifier",
262            "spelling": "ClassMethod"
263          }
264        ],
265        "title": "ClassMethod"
266      },
267      "pathComponents": [
268        "Interface",
269        "ClassMethod"
270      ]
271    },
272    {
273      "accessLevel": "public",
274      "declarationFragments": [
275        {
276          "kind": "keyword",
277          "spelling": "@property"
278        },
279        {
280          "kind": "text",
281          "spelling": " ("
282        },
283        {
284          "kind": "keyword",
285          "spelling": "atomic"
286        },
287        {
288          "kind": "text",
289          "spelling": ", "
290        },
291        {
292          "kind": "keyword",
293          "spelling": "assign"
294        },
295        {
296          "kind": "text",
297          "spelling": ", "
298        },
299        {
300          "kind": "keyword",
301          "spelling": "unsafe_unretained"
302        },
303        {
304          "kind": "text",
305          "spelling": ", "
306        },
307        {
308          "kind": "keyword",
309          "spelling": "readwrite"
310        },
311        {
312          "kind": "text",
313          "spelling": ") "
314        },
315        {
316          "kind": "typeIdentifier",
317          "preciseIdentifier": "c:I",
318          "spelling": "int"
319        },
320        {
321          "kind": "identifier",
322          "spelling": "Property"
323        }
324      ],
325      "identifier": {
326        "interfaceLanguage": "objective-c",
327        "precise": "c:objc(cs)Interface(py)Property"
328      },
329      "kind": {
330        "displayName": "Instance Property",
331        "identifier": "objective-c.property"
332      },
333      "location": {
334        "position": {
335          "character": 15,
336          "line": 7
337        },
338        "uri": "file://INPUT_DIR/input.h"
339      },
340      "names": {
341        "navigator": [
342          {
343            "kind": "identifier",
344            "spelling": "Property"
345          }
346        ],
347        "subHeading": [
348          {
349            "kind": "identifier",
350            "spelling": "Property"
351          }
352        ],
353        "title": "Property"
354      },
355      "pathComponents": [
356        "Interface",
357        "Property"
358      ]
359    }
360  ]
361}
362