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 --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         "subHeading": [
84           {
85             "kind": "identifier",
86             "spelling": "HELLO"
87           }
88         ],
89         "title": "HELLO"
90       },
91       "pathComponents": [
92         "HELLO"
93       ]
94     },
95     {
96       "accessLevel": "public",
97       "declarationFragments": [
98         {
99           "kind": "keyword",
100           "spelling": "#define"
101         },
102         {
103           "kind": "text",
104           "spelling": " "
105         },
106         {
107           "kind": "identifier",
108           "spelling": "WORLD"
109         }
110       ],
111       "identifier": {
112         "interfaceLanguage": "objective-c",
113         "precise": "c:input.h@24@macro@WORLD"
114       },
115       "kind": {
116         "displayName": "Macro",
117         "identifier": "objective-c.macro"
118       },
119       "location": {
120         "position": {
121           "character": 9,
122           "line": 2
123         },
124         "uri": "file://INPUT_DIR/input.h"
125       },
126       "names": {
127         "subHeading": [
128           {
129             "kind": "identifier",
130             "spelling": "WORLD"
131           }
132         ],
133         "title": "WORLD"
134       },
135       "pathComponents": [
136         "WORLD"
137       ]
138     },
139     {
140       "accessLevel": "public",
141       "declarationFragments": [
142         {
143           "kind": "keyword",
144           "spelling": "#define"
145         },
146         {
147           "kind": "text",
148           "spelling": " "
149         },
150         {
151           "kind": "identifier",
152           "spelling": "MACRO_FUN"
153         },
154         {
155           "kind": "text",
156           "spelling": "("
157         },
158         {
159           "kind": "internalParam",
160           "spelling": "x"
161         },
162         {
163           "kind": "text",
164           "spelling": ")"
165         }
166       ],
167       "identifier": {
168         "interfaceLanguage": "objective-c",
169         "precise": "c:input.h@40@macro@MACRO_FUN"
170       },
171       "kind": {
172         "displayName": "Macro",
173         "identifier": "objective-c.macro"
174       },
175       "location": {
176         "position": {
177           "character": 9,
178           "line": 3
179         },
180         "uri": "file://INPUT_DIR/input.h"
181       },
182       "names": {
183         "subHeading": [
184           {
185             "kind": "identifier",
186             "spelling": "MACRO_FUN"
187           }
188         ],
189         "title": "MACRO_FUN"
190       },
191       "pathComponents": [
192         "MACRO_FUN"
193       ]
194     },
195     {
196       "accessLevel": "public",
197       "declarationFragments": [
198         {
199           "kind": "keyword",
200           "spelling": "#define"
201         },
202         {
203           "kind": "text",
204           "spelling": " "
205         },
206         {
207           "kind": "identifier",
208           "spelling": "FUN"
209         },
210         {
211           "kind": "text",
212           "spelling": "("
213         },
214         {
215           "kind": "internalParam",
216           "spelling": "x"
217         },
218         {
219           "kind": "text",
220           "spelling": ", "
221         },
222         {
223           "kind": "internalParam",
224           "spelling": "y"
225         },
226         {
227           "kind": "text",
228           "spelling": ", "
229         },
230         {
231           "kind": "internalParam",
232           "spelling": "z"
233         },
234         {
235           "kind": "text",
236           "spelling": ")"
237         }
238       ],
239       "identifier": {
240         "interfaceLanguage": "objective-c",
241         "precise": "c:input.h@65@macro@FUN"
242       },
243       "kind": {
244         "displayName": "Macro",
245         "identifier": "objective-c.macro"
246       },
247       "location": {
248         "position": {
249           "character": 9,
250           "line": 4
251         },
252         "uri": "file://INPUT_DIR/input.h"
253       },
254       "names": {
255         "subHeading": [
256           {
257             "kind": "identifier",
258             "spelling": "FUN"
259           }
260         ],
261         "title": "FUN"
262       },
263       "pathComponents": [
264         "FUN"
265       ]
266     },
267     {
268       "accessLevel": "public",
269       "declarationFragments": [
270         {
271           "kind": "keyword",
272           "spelling": "#define"
273         },
274         {
275           "kind": "text",
276           "spelling": " "
277         },
278         {
279           "kind": "identifier",
280           "spelling": "FUNC99"
281         },
282         {
283           "kind": "text",
284           "spelling": "("
285         },
286         {
287           "kind": "internalParam",
288           "spelling": "x"
289         },
290         {
291           "kind": "text",
292           "spelling": ", ...)"
293         }
294       ],
295       "identifier": {
296         "interfaceLanguage": "objective-c",
297         "precise": "c:input.h@96@macro@FUNC99"
298       },
299       "kind": {
300         "displayName": "Macro",
301         "identifier": "objective-c.macro"
302       },
303       "location": {
304         "position": {
305           "character": 9,
306           "line": 5
307         },
308         "uri": "file://INPUT_DIR/input.h"
309       },
310       "names": {
311         "subHeading": [
312           {
313             "kind": "identifier",
314             "spelling": "FUNC99"
315           }
316         ],
317         "title": "FUNC99"
318       },
319       "pathComponents": [
320         "FUNC99"
321       ]
322     },
323     {
324       "accessLevel": "public",
325       "declarationFragments": [
326         {
327           "kind": "keyword",
328           "spelling": "#define"
329         },
330         {
331           "kind": "text",
332           "spelling": " "
333         },
334         {
335           "kind": "identifier",
336           "spelling": "FUNGNU"
337         },
338         {
339           "kind": "text",
340           "spelling": "("
341         },
342         {
343           "kind": "internalParam",
344           "spelling": "x"
345         },
346         {
347           "kind": "text",
348           "spelling": "...)"
349         }
350       ],
351       "identifier": {
352         "interfaceLanguage": "objective-c",
353         "precise": "c:input.h@119@macro@FUNGNU"
354       },
355       "kind": {
356         "displayName": "Macro",
357         "identifier": "objective-c.macro"
358       },
359       "location": {
360         "position": {
361           "character": 9,
362           "line": 6
363         },
364         "uri": "file://INPUT_DIR/input.h"
365       },
366       "names": {
367         "subHeading": [
368           {
369             "kind": "identifier",
370             "spelling": "FUNGNU"
371           }
372         ],
373         "title": "FUNGNU"
374       },
375       "pathComponents": [
376         "FUNGNU"
377       ]
378     }
379   ]
380 }
381