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