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