xref: /llvm-project/clang/test/ExtractAPI/bool.c (revision b1b24d751776d5fd2218a5cb43a8d103bf59fa32)
1e8174456SErick Velez // RUN: rm -rf %t
2e8174456SErick Velez // RUN: split-file %s %t
3e8174456SErick Velez // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4e8174456SErick Velez // RUN: %t/reference.output.json.in >> %t/reference.output.json
5*b1b24d75SDaniel Grumberg // RUN: %clang_cc1 -extract-api --product-name=BoolTest --pretty-sgf -triple arm64-apple-macosx \
6e8174456SErick Velez // RUN:   %t/input.h -o %t/output.json
7e8174456SErick Velez 
8e8174456SErick Velez // Generator version is not consistent across test runs, normalize it.
9e8174456SErick Velez // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
10e8174456SErick Velez // RUN: %t/output.json >> %t/output-normalized.json
11e8174456SErick Velez // RUN: diff %t/reference.output.json %t/output-normalized.json
12e8174456SErick Velez 
13e8174456SErick Velez //--- input.h
14e8174456SErick Velez #include <stdbool.h>
15e8174456SErick Velez bool Foo;
16e8174456SErick Velez 
17e8174456SErick Velez bool IsFoo(bool Bar);
18*b1b24d75SDaniel Grumberg // expected-no-diagnostics
19e8174456SErick Velez 
20e8174456SErick Velez //--- reference.output.json.in
21e8174456SErick Velez {
22e8174456SErick Velez   "metadata": {
23e8174456SErick Velez     "formatVersion": {
24e8174456SErick Velez       "major": 0,
25e8174456SErick Velez       "minor": 5,
26e8174456SErick Velez       "patch": 3
27e8174456SErick Velez     },
28e8174456SErick Velez     "generator": "?"
29e8174456SErick Velez   },
30e8174456SErick Velez   "module": {
31*b1b24d75SDaniel Grumberg     "name": "BoolTest",
32e8174456SErick Velez     "platform": {
33e8174456SErick Velez       "architecture": "arm64",
34e8174456SErick Velez       "operatingSystem": {
35e8174456SErick Velez         "minimumVersion": {
36e8174456SErick Velez           "major": 11,
37e8174456SErick Velez           "minor": 0,
38e8174456SErick Velez           "patch": 0
39e8174456SErick Velez         },
40e8174456SErick Velez         "name": "macosx"
41e8174456SErick Velez       },
42e8174456SErick Velez       "vendor": "apple"
43e8174456SErick Velez     }
44e8174456SErick Velez   },
45e8174456SErick Velez   "relationships": [],
46e8174456SErick Velez   "symbols": [
47e8174456SErick Velez     {
48e8174456SErick Velez       "accessLevel": "public",
49e8174456SErick Velez       "declarationFragments": [
50e8174456SErick Velez         {
51e8174456SErick Velez           "kind": "typeIdentifier",
52e8174456SErick Velez           "preciseIdentifier": "c:b",
53e8174456SErick Velez           "spelling": "bool"
54e8174456SErick Velez         },
55e8174456SErick Velez         {
56e8174456SErick Velez           "kind": "text",
57e8174456SErick Velez           "spelling": " "
58e8174456SErick Velez         },
59e8174456SErick Velez         {
60e8174456SErick Velez           "kind": "identifier",
61e8174456SErick Velez           "spelling": "Foo"
62e8174456SErick Velez         },
63e8174456SErick Velez         {
64e8174456SErick Velez           "kind": "text",
65e8174456SErick Velez           "spelling": ";"
66e8174456SErick Velez         }
67e8174456SErick Velez       ],
68e8174456SErick Velez       "identifier": {
69e8174456SErick Velez         "interfaceLanguage": "c",
70e8174456SErick Velez         "precise": "c:@Foo"
71e8174456SErick Velez       },
72e8174456SErick Velez       "kind": {
73e8174456SErick Velez         "displayName": "Global Variable",
74e8174456SErick Velez         "identifier": "c.var"
75e8174456SErick Velez       },
76e8174456SErick Velez       "location": {
77e8174456SErick Velez         "position": {
7863537872SQuietMisdreavus           "character": 5,
7963537872SQuietMisdreavus           "line": 1
80e8174456SErick Velez         },
81e8174456SErick Velez         "uri": "file://INPUT_DIR/input.h"
82e8174456SErick Velez       },
83e8174456SErick Velez       "names": {
84e8174456SErick Velez         "navigator": [
85e8174456SErick Velez           {
86e8174456SErick Velez             "kind": "identifier",
87e8174456SErick Velez             "spelling": "Foo"
88e8174456SErick Velez           }
89e8174456SErick Velez         ],
90e8174456SErick Velez         "subHeading": [
91e8174456SErick Velez           {
92e8174456SErick Velez             "kind": "identifier",
93e8174456SErick Velez             "spelling": "Foo"
94e8174456SErick Velez           }
95e8174456SErick Velez         ],
96e8174456SErick Velez         "title": "Foo"
97e8174456SErick Velez       },
98e8174456SErick Velez       "pathComponents": [
99e8174456SErick Velez         "Foo"
100e8174456SErick Velez       ]
101e8174456SErick Velez     },
102e8174456SErick Velez     {
103e8174456SErick Velez       "accessLevel": "public",
104e8174456SErick Velez       "declarationFragments": [
105e8174456SErick Velez         {
106e8174456SErick Velez           "kind": "typeIdentifier",
107e8174456SErick Velez           "preciseIdentifier": "c:b",
108e8174456SErick Velez           "spelling": "bool"
109e8174456SErick Velez         },
110e8174456SErick Velez         {
111e8174456SErick Velez           "kind": "text",
112e8174456SErick Velez           "spelling": " "
113e8174456SErick Velez         },
114e8174456SErick Velez         {
115e8174456SErick Velez           "kind": "identifier",
116e8174456SErick Velez           "spelling": "IsFoo"
117e8174456SErick Velez         },
118e8174456SErick Velez         {
119e8174456SErick Velez           "kind": "text",
120e8174456SErick Velez           "spelling": "("
121e8174456SErick Velez         },
122e8174456SErick Velez         {
123e8174456SErick Velez           "kind": "typeIdentifier",
124e8174456SErick Velez           "preciseIdentifier": "c:b",
125e8174456SErick Velez           "spelling": "bool"
126e8174456SErick Velez         },
127e8174456SErick Velez         {
128e8174456SErick Velez           "kind": "text",
129e8174456SErick Velez           "spelling": " "
130e8174456SErick Velez         },
131e8174456SErick Velez         {
132e8174456SErick Velez           "kind": "internalParam",
133e8174456SErick Velez           "spelling": "Bar"
134e8174456SErick Velez         },
135e8174456SErick Velez         {
136e8174456SErick Velez           "kind": "text",
137e8174456SErick Velez           "spelling": ");"
138e8174456SErick Velez         }
139e8174456SErick Velez       ],
140e8174456SErick Velez       "functionSignature": {
141e8174456SErick Velez         "parameters": [
142e8174456SErick Velez           {
143e8174456SErick Velez             "declarationFragments": [
144e8174456SErick Velez               {
145e8174456SErick Velez                 "kind": "typeIdentifier",
146e8174456SErick Velez                 "preciseIdentifier": "c:b",
147e8174456SErick Velez                 "spelling": "bool"
148e8174456SErick Velez               },
149e8174456SErick Velez               {
150e8174456SErick Velez                 "kind": "text",
151e8174456SErick Velez                 "spelling": " "
152e8174456SErick Velez               },
153e8174456SErick Velez               {
154e8174456SErick Velez                 "kind": "internalParam",
155e8174456SErick Velez                 "spelling": "Bar"
156e8174456SErick Velez               }
157e8174456SErick Velez             ],
158e8174456SErick Velez             "name": "Bar"
159e8174456SErick Velez           }
160e8174456SErick Velez         ],
161e8174456SErick Velez         "returns": [
162e8174456SErick Velez           {
163e8174456SErick Velez             "kind": "typeIdentifier",
164e8174456SErick Velez             "preciseIdentifier": "c:b",
165e8174456SErick Velez             "spelling": "bool"
166e8174456SErick Velez           }
167e8174456SErick Velez         ]
168e8174456SErick Velez       },
169e8174456SErick Velez       "identifier": {
170e8174456SErick Velez         "interfaceLanguage": "c",
171e8174456SErick Velez         "precise": "c:@F@IsFoo"
172e8174456SErick Velez       },
173e8174456SErick Velez       "kind": {
174e8174456SErick Velez         "displayName": "Function",
175e8174456SErick Velez         "identifier": "c.func"
176e8174456SErick Velez       },
177e8174456SErick Velez       "location": {
178e8174456SErick Velez         "position": {
17963537872SQuietMisdreavus           "character": 5,
18063537872SQuietMisdreavus           "line": 3
181e8174456SErick Velez         },
182e8174456SErick Velez         "uri": "file://INPUT_DIR/input.h"
183e8174456SErick Velez       },
184e8174456SErick Velez       "names": {
185e8174456SErick Velez         "navigator": [
186e8174456SErick Velez           {
187e8174456SErick Velez             "kind": "identifier",
188e8174456SErick Velez             "spelling": "IsFoo"
189e8174456SErick Velez           }
190e8174456SErick Velez         ],
191e8174456SErick Velez         "subHeading": [
192e8174456SErick Velez           {
193e8174456SErick Velez             "kind": "identifier",
194e8174456SErick Velez             "spelling": "IsFoo"
195e8174456SErick Velez           }
196e8174456SErick Velez         ],
197e8174456SErick Velez         "title": "IsFoo"
198e8174456SErick Velez       },
199e8174456SErick Velez       "pathComponents": [
200e8174456SErick Velez         "IsFoo"
201e8174456SErick Velez       ]
202e8174456SErick Velez     }
203e8174456SErick Velez   ]
204e8174456SErick Velez }
205