[clang][extract-api] Add struct support
[llvm-project.git] / clang / test / ExtractAPI / struct.c
blob9be2ff4a4ffed82630b4de283117cc11a37832ea
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 -target arm64-apple-macosx \
6 // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
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
13 // CHECK-NOT: error:
14 // CHECK-NOT: warning:
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;
26 //--- reference.output.json.in
28 "metadata": {
29 "formatVersion": {
30 "major": 0,
31 "minor": 5,
32 "patch": 3
34 "generator": "?"
36 "module": {
37 "name": "",
38 "platform": {
39 "architecture": "arm64",
40 "operatingSystem": {
41 "minimumVersion": {
42 "major": 11,
43 "minor": 0,
44 "patch": 0
46 "name": "macosx"
48 "vendor": "apple"
51 "relationhips": [
53 "kind": "memberOf",
54 "source": "c:@S@Color@FI@Red",
55 "target": "c:@S@Color"
58 "kind": "memberOf",
59 "source": "c:@S@Color@FI@Green",
60 "target": "c:@S@Color"
63 "kind": "memberOf",
64 "source": "c:@S@Color@FI@Blue",
65 "target": "c:@S@Color"
68 "kind": "memberOf",
69 "source": "c:@S@Color@FI@Alpha",
70 "target": "c:@S@Color"
73 "symbols": [
75 "declarationFragments": [
77 "kind": "keyword",
78 "spelling": "struct"
81 "kind": "text",
82 "spelling": " "
85 "kind": "identifier",
86 "spelling": "Color"
89 "docComment": {
90 "lines": [
92 "range": {
93 "end": {
94 "character": 18,
95 "line": 1
97 "start": {
98 "character": 5,
99 "line": 1
102 "text": "Color in RGBA"
106 "identifier": {
107 "interfaceLanguage": "c",
108 "precise": "c:@S@Color"
110 "kind": {
111 "displayName": "Structure",
112 "identifier": "c.struct"
114 "location": {
115 "character": 8,
116 "line": 2,
117 "uri": "file://INPUT_DIR/input.h"
119 "names": {
120 "subHeading": [
122 "kind": "identifier",
123 "spelling": "Color"
126 "title": "Color"
130 "declarationFragments": [
132 "kind": "typeIdentifier",
133 "preciseIdentifier": "c:i",
134 "spelling": "unsigned int"
137 "kind": "text",
138 "spelling": " "
141 "kind": "identifier",
142 "spelling": "Red"
145 "identifier": {
146 "interfaceLanguage": "c",
147 "precise": "c:@S@Color@FI@Red"
149 "kind": {
150 "displayName": "Instance Property",
151 "identifier": "c.property"
153 "location": {
154 "character": 12,
155 "line": 3,
156 "uri": "file://INPUT_DIR/input.h"
158 "names": {
159 "subHeading": [
161 "kind": "identifier",
162 "spelling": "Red"
165 "title": "Red"
169 "declarationFragments": [
171 "kind": "typeIdentifier",
172 "preciseIdentifier": "c:i",
173 "spelling": "unsigned int"
176 "kind": "text",
177 "spelling": " "
180 "kind": "identifier",
181 "spelling": "Green"
184 "identifier": {
185 "interfaceLanguage": "c",
186 "precise": "c:@S@Color@FI@Green"
188 "kind": {
189 "displayName": "Instance Property",
190 "identifier": "c.property"
192 "location": {
193 "character": 12,
194 "line": 4,
195 "uri": "file://INPUT_DIR/input.h"
197 "names": {
198 "subHeading": [
200 "kind": "identifier",
201 "spelling": "Green"
204 "title": "Green"
208 "declarationFragments": [
210 "kind": "typeIdentifier",
211 "preciseIdentifier": "c:i",
212 "spelling": "unsigned int"
215 "kind": "text",
216 "spelling": " "
219 "kind": "identifier",
220 "spelling": "Blue"
223 "identifier": {
224 "interfaceLanguage": "c",
225 "precise": "c:@S@Color@FI@Blue"
227 "kind": {
228 "displayName": "Instance Property",
229 "identifier": "c.property"
231 "location": {
232 "character": 12,
233 "line": 5,
234 "uri": "file://INPUT_DIR/input.h"
236 "names": {
237 "subHeading": [
239 "kind": "identifier",
240 "spelling": "Blue"
243 "title": "Blue"
247 "declarationFragments": [
249 "kind": "typeIdentifier",
250 "preciseIdentifier": "c:i",
251 "spelling": "unsigned int"
254 "kind": "text",
255 "spelling": " "
258 "kind": "identifier",
259 "spelling": "Alpha"
262 "docComment": {
263 "lines": [
265 "range": {
266 "end": {
267 "character": 37,
268 "line": 6
270 "start": {
271 "character": 7,
272 "line": 6
275 "text": "Alpha channel for transparency"
279 "identifier": {
280 "interfaceLanguage": "c",
281 "precise": "c:@S@Color@FI@Alpha"
283 "kind": {
284 "displayName": "Instance Property",
285 "identifier": "c.property"
287 "location": {
288 "character": 12,
289 "line": 7,
290 "uri": "file://INPUT_DIR/input.h"
292 "names": {
293 "subHeading": [
295 "kind": "identifier",
296 "spelling": "Alpha"
299 "title": "Alpha"