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 FUNC_GEN(NAME, ...) void NAME(__VA_ARGS__);
19 FUNC_GEN(foo)
20 FUNC_GEN(bar, const int *, unsigned);
21 #undef FUNC_GEN
22 
23 //--- reference.output.json.in
24 {
25   "metadata": {
26     "formatVersion": {
27       "major": 0,
28       "minor": 5,
29       "patch": 3
30     },
31     "generator": "?"
32   },
33   "module": {
34     "name": "Macros",
35     "platform": {
36       "architecture": "arm64",
37       "operatingSystem": {
38         "minimumVersion": {
39           "major": 11,
40           "minor": 0,
41           "patch": 0
42         },
43         "name": "macosx"
44       },
45       "vendor": "apple"
46     }
47   },
48   "relationhips": [],
49   "symbols": [
50     {
51       "declarationFragments": [
52         {
53           "kind": "typeIdentifier",
54           "preciseIdentifier": "c:v",
55           "spelling": "void"
56         },
57         {
58           "kind": "text",
59           "spelling": " "
60         },
61         {
62           "kind": "identifier",
63           "spelling": "foo"
64         },
65         {
66           "kind": "text",
67           "spelling": "()"
68         }
69       ],
70       "identifier": {
71         "interfaceLanguage": "objective-c",
72         "precise": "c:@F@foo"
73       },
74       "kind": {
75         "displayName": "Function",
76         "identifier": "objective-c.func"
77       },
78       "location": {
79         "character": 1,
80         "line": 3,
81         "uri": "file://INPUT_DIR/input.h"
82       },
83       "names": {
84         "subHeading": [
85           {
86             "kind": "identifier",
87             "spelling": "foo"
88           }
89         ],
90         "title": "foo"
91       },
92       "parameters": {
93         "returns": [
94           {
95             "kind": "typeIdentifier",
96             "preciseIdentifier": "c:v",
97             "spelling": "void"
98           }
99         ]
100       }
101     },
102     {
103       "declarationFragments": [
104         {
105           "kind": "typeIdentifier",
106           "preciseIdentifier": "c:v",
107           "spelling": "void"
108         },
109         {
110           "kind": "text",
111           "spelling": " "
112         },
113         {
114           "kind": "identifier",
115           "spelling": "bar"
116         },
117         {
118           "kind": "text",
119           "spelling": "("
120         },
121         {
122           "kind": "keyword",
123           "spelling": "const"
124         },
125         {
126           "kind": "text",
127           "spelling": " "
128         },
129         {
130           "kind": "typeIdentifier",
131           "preciseIdentifier": "c:I",
132           "spelling": "int"
133         },
134         {
135           "kind": "text",
136           "spelling": " *"
137         },
138         {
139           "kind": "internalParam",
140           "spelling": ""
141         },
142         {
143           "kind": "text",
144           "spelling": ", "
145         },
146         {
147           "kind": "typeIdentifier",
148           "preciseIdentifier": "c:i",
149           "spelling": "unsigned int"
150         },
151         {
152           "kind": "text",
153           "spelling": " "
154         },
155         {
156           "kind": "internalParam",
157           "spelling": ""
158         },
159         {
160           "kind": "text",
161           "spelling": ")"
162         }
163       ],
164       "identifier": {
165         "interfaceLanguage": "objective-c",
166         "precise": "c:@F@bar"
167       },
168       "kind": {
169         "displayName": "Function",
170         "identifier": "objective-c.func"
171       },
172       "location": {
173         "character": 1,
174         "line": 4,
175         "uri": "file://INPUT_DIR/input.h"
176       },
177       "names": {
178         "subHeading": [
179           {
180             "kind": "identifier",
181             "spelling": "bar"
182           }
183         ],
184         "title": "bar"
185       },
186       "parameters": {
187         "parameters": [
188           {
189             "declarationFragments": [
190               {
191                 "kind": "keyword",
192                 "spelling": "const"
193               },
194               {
195                 "kind": "text",
196                 "spelling": " "
197               },
198               {
199                 "kind": "typeIdentifier",
200                 "preciseIdentifier": "c:I",
201                 "spelling": "int"
202               },
203               {
204                 "kind": "text",
205                 "spelling": " *"
206               },
207               {
208                 "kind": "internalParam",
209                 "spelling": ""
210               }
211             ],
212             "name": ""
213           },
214           {
215             "declarationFragments": [
216               {
217                 "kind": "typeIdentifier",
218                 "preciseIdentifier": "c:i",
219                 "spelling": "unsigned int"
220               },
221               {
222                 "kind": "text",
223                 "spelling": " "
224               },
225               {
226                 "kind": "internalParam",
227                 "spelling": ""
228               }
229             ],
230             "name": ""
231           }
232         ],
233         "returns": [
234           {
235             "kind": "typeIdentifier",
236             "preciseIdentifier": "c:v",
237             "spelling": "void"
238           }
239         ]
240       }
241     },
242     {
243       "declarationFragments": [
244         {
245           "kind": "keyword",
246           "spelling": "#define"
247         },
248         {
249           "kind": "text",
250           "spelling": " "
251         },
252         {
253           "kind": "identifier",
254           "spelling": "HELLO"
255         }
256       ],
257       "identifier": {
258         "interfaceLanguage": "objective-c",
259         "precise": "c:input.h@8@macro@HELLO"
260       },
261       "kind": {
262         "displayName": "Macro",
263         "identifier": "objective-c.macro"
264       },
265       "location": {
266         "character": 9,
267         "line": 1,
268         "uri": "file://INPUT_DIR/input.h"
269       },
270       "names": {
271         "subHeading": [
272           {
273             "kind": "identifier",
274             "spelling": "HELLO"
275           }
276         ],
277         "title": "HELLO"
278       }
279     }
280   ]
281 }
282