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