[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ExtractAPI / class.cpp
blob0c5db8e9c9d215d9189e8c38733b669f625d18d9
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_cc1 -extract-api --pretty-sgf -triple arm64-apple-macosx \
6 // RUN: -x c++-header %t/input.h -o %t/output.json -verify
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 //--- input.h
14 class Foo {
15 private:
16 int a;
17 mutable int b;
19 protected:
20 int c;
22 public:
23 int d;
25 /// expected-no-diagnostics
27 //--- reference.output.json.in
29 "metadata": {
30 "formatVersion": {
31 "major": 0,
32 "minor": 5,
33 "patch": 3
35 "generator": "?"
37 "module": {
38 "name": "",
39 "platform": {
40 "architecture": "arm64",
41 "operatingSystem": {
42 "minimumVersion": {
43 "major": 11,
44 "minor": 0,
45 "patch": 0
47 "name": "macosx"
49 "vendor": "apple"
52 "relationships": [
54 "kind": "memberOf",
55 "source": "c:@S@Foo@FI@a",
56 "target": "c:@S@Foo",
57 "targetFallback": "Foo"
60 "kind": "memberOf",
61 "source": "c:@S@Foo@FI@b",
62 "target": "c:@S@Foo",
63 "targetFallback": "Foo"
66 "kind": "memberOf",
67 "source": "c:@S@Foo@FI@c",
68 "target": "c:@S@Foo",
69 "targetFallback": "Foo"
72 "kind": "memberOf",
73 "source": "c:@S@Foo@FI@d",
74 "target": "c:@S@Foo",
75 "targetFallback": "Foo"
78 "symbols": [
80 "accessLevel": "public",
81 "declarationFragments": [
83 "kind": "keyword",
84 "spelling": "class"
87 "kind": "text",
88 "spelling": " "
91 "kind": "identifier",
92 "spelling": "Foo"
95 "kind": "text",
96 "spelling": ";"
99 "identifier": {
100 "interfaceLanguage": "c++",
101 "precise": "c:@S@Foo"
103 "kind": {
104 "displayName": "Class",
105 "identifier": "c++.class"
107 "location": {
108 "position": {
109 "character": 6,
110 "line": 0
112 "uri": "file://INPUT_DIR/input.h"
114 "names": {
115 "navigator": [
117 "kind": "identifier",
118 "spelling": "Foo"
121 "subHeading": [
123 "kind": "identifier",
124 "spelling": "Foo"
127 "title": "Foo"
129 "pathComponents": [
130 "Foo"
134 "accessLevel": "private",
135 "declarationFragments": [
137 "kind": "typeIdentifier",
138 "preciseIdentifier": "c:I",
139 "spelling": "int"
142 "kind": "text",
143 "spelling": " "
146 "kind": "identifier",
147 "spelling": "a"
150 "kind": "text",
151 "spelling": ";"
154 "identifier": {
155 "interfaceLanguage": "c++",
156 "precise": "c:@S@Foo@FI@a"
158 "kind": {
159 "displayName": "Instance Property",
160 "identifier": "c++.property"
162 "location": {
163 "position": {
164 "character": 6,
165 "line": 2
167 "uri": "file://INPUT_DIR/input.h"
169 "names": {
170 "navigator": [
172 "kind": "identifier",
173 "spelling": "a"
176 "subHeading": [
178 "kind": "identifier",
179 "spelling": "a"
182 "title": "a"
184 "pathComponents": [
185 "Foo",
190 "accessLevel": "private",
191 "declarationFragments": [
193 "kind": "keyword",
194 "spelling": "mutable"
197 "kind": "text",
198 "spelling": " "
201 "kind": "typeIdentifier",
202 "preciseIdentifier": "c:I",
203 "spelling": "int"
206 "kind": "text",
207 "spelling": " "
210 "kind": "identifier",
211 "spelling": "b"
214 "kind": "text",
215 "spelling": ";"
218 "identifier": {
219 "interfaceLanguage": "c++",
220 "precise": "c:@S@Foo@FI@b"
222 "kind": {
223 "displayName": "Instance Property",
224 "identifier": "c++.property"
226 "location": {
227 "position": {
228 "character": 14,
229 "line": 3
231 "uri": "file://INPUT_DIR/input.h"
233 "names": {
234 "navigator": [
236 "kind": "identifier",
237 "spelling": "b"
240 "subHeading": [
242 "kind": "identifier",
243 "spelling": "b"
246 "title": "b"
248 "pathComponents": [
249 "Foo",
254 "accessLevel": "protected",
255 "declarationFragments": [
257 "kind": "typeIdentifier",
258 "preciseIdentifier": "c:I",
259 "spelling": "int"
262 "kind": "text",
263 "spelling": " "
266 "kind": "identifier",
267 "spelling": "c"
270 "kind": "text",
271 "spelling": ";"
274 "identifier": {
275 "interfaceLanguage": "c++",
276 "precise": "c:@S@Foo@FI@c"
278 "kind": {
279 "displayName": "Instance Property",
280 "identifier": "c++.property"
282 "location": {
283 "position": {
284 "character": 6,
285 "line": 6
287 "uri": "file://INPUT_DIR/input.h"
289 "names": {
290 "navigator": [
292 "kind": "identifier",
293 "spelling": "c"
296 "subHeading": [
298 "kind": "identifier",
299 "spelling": "c"
302 "title": "c"
304 "pathComponents": [
305 "Foo",
310 "accessLevel": "public",
311 "declarationFragments": [
313 "kind": "typeIdentifier",
314 "preciseIdentifier": "c:I",
315 "spelling": "int"
318 "kind": "text",
319 "spelling": " "
322 "kind": "identifier",
323 "spelling": "d"
326 "kind": "text",
327 "spelling": ";"
330 "identifier": {
331 "interfaceLanguage": "c++",
332 "precise": "c:@S@Foo@FI@d"
334 "kind": {
335 "displayName": "Instance Property",
336 "identifier": "c++.property"
338 "location": {
339 "position": {
340 "character": 6,
341 "line": 9
343 "uri": "file://INPUT_DIR/input.h"
345 "names": {
346 "navigator": [
348 "kind": "identifier",
349 "spelling": "d"
352 "subHeading": [
354 "kind": "identifier",
355 "spelling": "d"
358 "title": "d"
360 "pathComponents": [
361 "Foo",