xref: /llvm-project/clang/test/ExtractAPI/class.cpp (revision e05c1b46d0d3739cc48ad912dbe6e9affce05927)
175f55eb3SErick Velez // RUN: rm -rf %t
275f55eb3SErick Velez // RUN: split-file %s %t
375f55eb3SErick Velez // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
475f55eb3SErick 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 \
675f55eb3SErick Velez // RUN:   -x c++-header %t/input.h -o %t/output.json -verify
775f55eb3SErick Velez 
875f55eb3SErick Velez // Generator version is not consistent across test runs, normalize it.
975f55eb3SErick Velez // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
1075f55eb3SErick Velez // RUN: %t/output.json >> %t/output-normalized.json
1175f55eb3SErick Velez // RUN: diff %t/reference.output.json %t/output-normalized.json
1275f55eb3SErick Velez 
1375f55eb3SErick Velez //--- input.h
1475f55eb3SErick Velez class Foo {
1575f55eb3SErick Velez private:
1675f55eb3SErick Velez   int a;
1775f55eb3SErick Velez   mutable int b;
1875f55eb3SErick Velez 
1975f55eb3SErick Velez protected:
2075f55eb3SErick Velez   int c;
2175f55eb3SErick Velez 
2275f55eb3SErick Velez public:
2375f55eb3SErick Velez   int d;
2475f55eb3SErick Velez };
2575f55eb3SErick Velez /// expected-no-diagnostics
2675f55eb3SErick Velez 
2775f55eb3SErick Velez //--- reference.output.json.in
2875f55eb3SErick Velez {
2975f55eb3SErick Velez   "metadata": {
3075f55eb3SErick Velez     "formatVersion": {
3175f55eb3SErick Velez       "major": 0,
3275f55eb3SErick Velez       "minor": 5,
3375f55eb3SErick Velez       "patch": 3
3475f55eb3SErick Velez     },
3575f55eb3SErick Velez     "generator": "?"
3675f55eb3SErick Velez   },
3775f55eb3SErick Velez   "module": {
3875f55eb3SErick Velez     "name": "",
3975f55eb3SErick Velez     "platform": {
4075f55eb3SErick Velez       "architecture": "arm64",
4175f55eb3SErick Velez       "operatingSystem": {
4275f55eb3SErick Velez         "minimumVersion": {
4375f55eb3SErick Velez           "major": 11,
4475f55eb3SErick Velez           "minor": 0,
4575f55eb3SErick Velez           "patch": 0
4675f55eb3SErick Velez         },
4775f55eb3SErick Velez         "name": "macosx"
4875f55eb3SErick Velez       },
4975f55eb3SErick Velez       "vendor": "apple"
5075f55eb3SErick Velez     }
5175f55eb3SErick Velez   },
5275f55eb3SErick Velez   "relationships": [
5375f55eb3SErick Velez     {
5475f55eb3SErick Velez       "kind": "memberOf",
5575f55eb3SErick Velez       "source": "c:@S@Foo@FI@a",
5675f55eb3SErick Velez       "target": "c:@S@Foo",
5775f55eb3SErick Velez       "targetFallback": "Foo"
5875f55eb3SErick Velez     },
5975f55eb3SErick Velez     {
6075f55eb3SErick Velez       "kind": "memberOf",
6175f55eb3SErick Velez       "source": "c:@S@Foo@FI@b",
6275f55eb3SErick Velez       "target": "c:@S@Foo",
6375f55eb3SErick Velez       "targetFallback": "Foo"
6475f55eb3SErick Velez     },
6575f55eb3SErick Velez     {
6675f55eb3SErick Velez       "kind": "memberOf",
6775f55eb3SErick Velez       "source": "c:@S@Foo@FI@c",
6875f55eb3SErick Velez       "target": "c:@S@Foo",
6975f55eb3SErick Velez       "targetFallback": "Foo"
7075f55eb3SErick Velez     },
7175f55eb3SErick Velez     {
7275f55eb3SErick Velez       "kind": "memberOf",
7375f55eb3SErick Velez       "source": "c:@S@Foo@FI@d",
7475f55eb3SErick Velez       "target": "c:@S@Foo",
7575f55eb3SErick Velez       "targetFallback": "Foo"
7675f55eb3SErick Velez     }
7775f55eb3SErick Velez   ],
7875f55eb3SErick Velez   "symbols": [
7975f55eb3SErick Velez     {
8075f55eb3SErick Velez       "accessLevel": "public",
8175f55eb3SErick Velez       "declarationFragments": [
8275f55eb3SErick Velez         {
8375f55eb3SErick Velez           "kind": "keyword",
8475f55eb3SErick Velez           "spelling": "class"
8575f55eb3SErick Velez         },
8675f55eb3SErick Velez         {
8775f55eb3SErick Velez           "kind": "text",
8875f55eb3SErick Velez           "spelling": " "
8975f55eb3SErick Velez         },
9075f55eb3SErick Velez         {
9175f55eb3SErick Velez           "kind": "identifier",
9275f55eb3SErick Velez           "spelling": "Foo"
9375f55eb3SErick Velez         },
9475f55eb3SErick Velez         {
9575f55eb3SErick Velez           "kind": "text",
9675f55eb3SErick Velez           "spelling": ";"
9775f55eb3SErick Velez         }
9875f55eb3SErick Velez       ],
9975f55eb3SErick Velez       "identifier": {
10075f55eb3SErick Velez         "interfaceLanguage": "c++",
10175f55eb3SErick Velez         "precise": "c:@S@Foo"
10275f55eb3SErick Velez       },
10375f55eb3SErick Velez       "kind": {
10475f55eb3SErick Velez         "displayName": "Class",
10575f55eb3SErick Velez         "identifier": "c++.class"
10675f55eb3SErick Velez       },
10775f55eb3SErick Velez       "location": {
10875f55eb3SErick Velez         "position": {
10963537872SQuietMisdreavus           "character": 6,
11063537872SQuietMisdreavus           "line": 0
11175f55eb3SErick Velez         },
11275f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
11375f55eb3SErick Velez       },
11475f55eb3SErick Velez       "names": {
11575f55eb3SErick Velez         "navigator": [
11675f55eb3SErick Velez           {
11775f55eb3SErick Velez             "kind": "identifier",
11875f55eb3SErick Velez             "spelling": "Foo"
11975f55eb3SErick Velez           }
12075f55eb3SErick Velez         ],
12175f55eb3SErick Velez         "subHeading": [
12275f55eb3SErick Velez           {
12375f55eb3SErick Velez             "kind": "identifier",
12475f55eb3SErick Velez             "spelling": "Foo"
12575f55eb3SErick Velez           }
12675f55eb3SErick Velez         ],
12775f55eb3SErick Velez         "title": "Foo"
12875f55eb3SErick Velez       },
12975f55eb3SErick Velez       "pathComponents": [
13075f55eb3SErick Velez         "Foo"
13175f55eb3SErick Velez       ]
13275f55eb3SErick Velez     },
13375f55eb3SErick Velez     {
13475f55eb3SErick Velez       "accessLevel": "private",
13575f55eb3SErick Velez       "declarationFragments": [
13675f55eb3SErick Velez         {
13775f55eb3SErick Velez           "kind": "typeIdentifier",
13875f55eb3SErick Velez           "preciseIdentifier": "c:I",
13975f55eb3SErick Velez           "spelling": "int"
14075f55eb3SErick Velez         },
14175f55eb3SErick Velez         {
14275f55eb3SErick Velez           "kind": "text",
14375f55eb3SErick Velez           "spelling": " "
14475f55eb3SErick Velez         },
14575f55eb3SErick Velez         {
14675f55eb3SErick Velez           "kind": "identifier",
14775f55eb3SErick Velez           "spelling": "a"
14875f55eb3SErick Velez         },
14975f55eb3SErick Velez         {
15075f55eb3SErick Velez           "kind": "text",
15175f55eb3SErick Velez           "spelling": ";"
15275f55eb3SErick Velez         }
15375f55eb3SErick Velez       ],
15475f55eb3SErick Velez       "identifier": {
15575f55eb3SErick Velez         "interfaceLanguage": "c++",
15675f55eb3SErick Velez         "precise": "c:@S@Foo@FI@a"
15775f55eb3SErick Velez       },
15875f55eb3SErick Velez       "kind": {
15975f55eb3SErick Velez         "displayName": "Instance Property",
16075f55eb3SErick Velez         "identifier": "c++.property"
16175f55eb3SErick Velez       },
16275f55eb3SErick Velez       "location": {
16375f55eb3SErick Velez         "position": {
16463537872SQuietMisdreavus           "character": 6,
16563537872SQuietMisdreavus           "line": 2
16675f55eb3SErick Velez         },
16775f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
16875f55eb3SErick Velez       },
16975f55eb3SErick Velez       "names": {
17075f55eb3SErick Velez         "navigator": [
17175f55eb3SErick Velez           {
17275f55eb3SErick Velez             "kind": "identifier",
17375f55eb3SErick Velez             "spelling": "a"
17475f55eb3SErick Velez           }
17575f55eb3SErick Velez         ],
17675f55eb3SErick Velez         "subHeading": [
17775f55eb3SErick Velez           {
17875f55eb3SErick Velez             "kind": "identifier",
17975f55eb3SErick Velez             "spelling": "a"
18075f55eb3SErick Velez           }
18175f55eb3SErick Velez         ],
18275f55eb3SErick Velez         "title": "a"
18375f55eb3SErick Velez       },
18475f55eb3SErick Velez       "pathComponents": [
18575f55eb3SErick Velez         "Foo",
18675f55eb3SErick Velez         "a"
18775f55eb3SErick Velez       ]
18875f55eb3SErick Velez     },
18975f55eb3SErick Velez     {
19075f55eb3SErick Velez       "accessLevel": "private",
19175f55eb3SErick Velez       "declarationFragments": [
19275f55eb3SErick Velez         {
19375f55eb3SErick Velez           "kind": "keyword",
19475f55eb3SErick Velez           "spelling": "mutable"
19575f55eb3SErick Velez         },
19675f55eb3SErick Velez         {
19775f55eb3SErick Velez           "kind": "text",
19875f55eb3SErick Velez           "spelling": " "
19975f55eb3SErick Velez         },
20075f55eb3SErick Velez         {
20175f55eb3SErick Velez           "kind": "typeIdentifier",
20275f55eb3SErick Velez           "preciseIdentifier": "c:I",
20375f55eb3SErick Velez           "spelling": "int"
20475f55eb3SErick Velez         },
20575f55eb3SErick Velez         {
20675f55eb3SErick Velez           "kind": "text",
20775f55eb3SErick Velez           "spelling": " "
20875f55eb3SErick Velez         },
20975f55eb3SErick Velez         {
21075f55eb3SErick Velez           "kind": "identifier",
21175f55eb3SErick Velez           "spelling": "b"
21275f55eb3SErick Velez         },
21375f55eb3SErick Velez         {
21475f55eb3SErick Velez           "kind": "text",
21575f55eb3SErick Velez           "spelling": ";"
21675f55eb3SErick Velez         }
21775f55eb3SErick Velez       ],
21875f55eb3SErick Velez       "identifier": {
21975f55eb3SErick Velez         "interfaceLanguage": "c++",
22075f55eb3SErick Velez         "precise": "c:@S@Foo@FI@b"
22175f55eb3SErick Velez       },
22275f55eb3SErick Velez       "kind": {
22375f55eb3SErick Velez         "displayName": "Instance Property",
22475f55eb3SErick Velez         "identifier": "c++.property"
22575f55eb3SErick Velez       },
22675f55eb3SErick Velez       "location": {
22775f55eb3SErick Velez         "position": {
22863537872SQuietMisdreavus           "character": 14,
22963537872SQuietMisdreavus           "line": 3
23075f55eb3SErick Velez         },
23175f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
23275f55eb3SErick Velez       },
23375f55eb3SErick Velez       "names": {
23475f55eb3SErick Velez         "navigator": [
23575f55eb3SErick Velez           {
23675f55eb3SErick Velez             "kind": "identifier",
23775f55eb3SErick Velez             "spelling": "b"
23875f55eb3SErick Velez           }
23975f55eb3SErick Velez         ],
24075f55eb3SErick Velez         "subHeading": [
24175f55eb3SErick Velez           {
24275f55eb3SErick Velez             "kind": "identifier",
24375f55eb3SErick Velez             "spelling": "b"
24475f55eb3SErick Velez           }
24575f55eb3SErick Velez         ],
24675f55eb3SErick Velez         "title": "b"
24775f55eb3SErick Velez       },
24875f55eb3SErick Velez       "pathComponents": [
24975f55eb3SErick Velez         "Foo",
25075f55eb3SErick Velez         "b"
25175f55eb3SErick Velez       ]
25275f55eb3SErick Velez     },
25375f55eb3SErick Velez     {
25475f55eb3SErick Velez       "accessLevel": "protected",
25575f55eb3SErick Velez       "declarationFragments": [
25675f55eb3SErick Velez         {
25775f55eb3SErick Velez           "kind": "typeIdentifier",
25875f55eb3SErick Velez           "preciseIdentifier": "c:I",
25975f55eb3SErick Velez           "spelling": "int"
26075f55eb3SErick Velez         },
26175f55eb3SErick Velez         {
26275f55eb3SErick Velez           "kind": "text",
26375f55eb3SErick Velez           "spelling": " "
26475f55eb3SErick Velez         },
26575f55eb3SErick Velez         {
26675f55eb3SErick Velez           "kind": "identifier",
26775f55eb3SErick Velez           "spelling": "c"
26875f55eb3SErick Velez         },
26975f55eb3SErick Velez         {
27075f55eb3SErick Velez           "kind": "text",
27175f55eb3SErick Velez           "spelling": ";"
27275f55eb3SErick Velez         }
27375f55eb3SErick Velez       ],
27475f55eb3SErick Velez       "identifier": {
27575f55eb3SErick Velez         "interfaceLanguage": "c++",
27675f55eb3SErick Velez         "precise": "c:@S@Foo@FI@c"
27775f55eb3SErick Velez       },
27875f55eb3SErick Velez       "kind": {
27975f55eb3SErick Velez         "displayName": "Instance Property",
28075f55eb3SErick Velez         "identifier": "c++.property"
28175f55eb3SErick Velez       },
28275f55eb3SErick Velez       "location": {
28375f55eb3SErick Velez         "position": {
28463537872SQuietMisdreavus           "character": 6,
28563537872SQuietMisdreavus           "line": 6
28675f55eb3SErick Velez         },
28775f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
28875f55eb3SErick Velez       },
28975f55eb3SErick Velez       "names": {
29075f55eb3SErick Velez         "navigator": [
29175f55eb3SErick Velez           {
29275f55eb3SErick Velez             "kind": "identifier",
29375f55eb3SErick Velez             "spelling": "c"
29475f55eb3SErick Velez           }
29575f55eb3SErick Velez         ],
29675f55eb3SErick Velez         "subHeading": [
29775f55eb3SErick Velez           {
29875f55eb3SErick Velez             "kind": "identifier",
29975f55eb3SErick Velez             "spelling": "c"
30075f55eb3SErick Velez           }
30175f55eb3SErick Velez         ],
30275f55eb3SErick Velez         "title": "c"
30375f55eb3SErick Velez       },
30475f55eb3SErick Velez       "pathComponents": [
30575f55eb3SErick Velez         "Foo",
30675f55eb3SErick Velez         "c"
30775f55eb3SErick Velez       ]
30875f55eb3SErick Velez     },
30975f55eb3SErick Velez     {
31075f55eb3SErick Velez       "accessLevel": "public",
31175f55eb3SErick Velez       "declarationFragments": [
31275f55eb3SErick Velez         {
31375f55eb3SErick Velez           "kind": "typeIdentifier",
31475f55eb3SErick Velez           "preciseIdentifier": "c:I",
31575f55eb3SErick Velez           "spelling": "int"
31675f55eb3SErick Velez         },
31775f55eb3SErick Velez         {
31875f55eb3SErick Velez           "kind": "text",
31975f55eb3SErick Velez           "spelling": " "
32075f55eb3SErick Velez         },
32175f55eb3SErick Velez         {
32275f55eb3SErick Velez           "kind": "identifier",
32375f55eb3SErick Velez           "spelling": "d"
32475f55eb3SErick Velez         },
32575f55eb3SErick Velez         {
32675f55eb3SErick Velez           "kind": "text",
32775f55eb3SErick Velez           "spelling": ";"
32875f55eb3SErick Velez         }
32975f55eb3SErick Velez       ],
33075f55eb3SErick Velez       "identifier": {
33175f55eb3SErick Velez         "interfaceLanguage": "c++",
33275f55eb3SErick Velez         "precise": "c:@S@Foo@FI@d"
33375f55eb3SErick Velez       },
33475f55eb3SErick Velez       "kind": {
33575f55eb3SErick Velez         "displayName": "Instance Property",
33675f55eb3SErick Velez         "identifier": "c++.property"
33775f55eb3SErick Velez       },
33875f55eb3SErick Velez       "location": {
33975f55eb3SErick Velez         "position": {
34063537872SQuietMisdreavus           "character": 6,
34163537872SQuietMisdreavus           "line": 9
34275f55eb3SErick Velez         },
34375f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
34475f55eb3SErick Velez       },
34575f55eb3SErick Velez       "names": {
34675f55eb3SErick Velez         "navigator": [
34775f55eb3SErick Velez           {
34875f55eb3SErick Velez             "kind": "identifier",
34975f55eb3SErick Velez             "spelling": "d"
35075f55eb3SErick Velez           }
35175f55eb3SErick Velez         ],
35275f55eb3SErick Velez         "subHeading": [
35375f55eb3SErick Velez           {
35475f55eb3SErick Velez             "kind": "identifier",
35575f55eb3SErick Velez             "spelling": "d"
35675f55eb3SErick Velez           }
35775f55eb3SErick Velez         ],
35875f55eb3SErick Velez         "title": "d"
35975f55eb3SErick Velez       },
36075f55eb3SErick Velez       "pathComponents": [
36175f55eb3SErick Velez         "Foo",
36275f55eb3SErick Velez         "d"
36375f55eb3SErick Velez       ]
36475f55eb3SErick Velez     }
36575f55eb3SErick Velez   ]
36675f55eb3SErick Velez }
367