xref: /llvm-project/clang/test/ExtractAPI/constructor_destructor.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   Foo();
1675f55eb3SErick Velez   ~Foo();
1775f55eb3SErick Velez };
1875f55eb3SErick Velez /// expected-no-diagnostics
1975f55eb3SErick Velez 
2075f55eb3SErick Velez //--- reference.output.json.in
2175f55eb3SErick Velez {
2275f55eb3SErick Velez   "metadata": {
2375f55eb3SErick Velez     "formatVersion": {
2475f55eb3SErick Velez       "major": 0,
2575f55eb3SErick Velez       "minor": 5,
2675f55eb3SErick Velez       "patch": 3
2775f55eb3SErick Velez     },
2875f55eb3SErick Velez     "generator": "?"
2975f55eb3SErick Velez   },
3075f55eb3SErick Velez   "module": {
3175f55eb3SErick Velez     "name": "",
3275f55eb3SErick Velez     "platform": {
3375f55eb3SErick Velez       "architecture": "arm64",
3475f55eb3SErick Velez       "operatingSystem": {
3575f55eb3SErick Velez         "minimumVersion": {
3675f55eb3SErick Velez           "major": 11,
3775f55eb3SErick Velez           "minor": 0,
3875f55eb3SErick Velez           "patch": 0
3975f55eb3SErick Velez         },
4075f55eb3SErick Velez         "name": "macosx"
4175f55eb3SErick Velez       },
4275f55eb3SErick Velez       "vendor": "apple"
4375f55eb3SErick Velez     }
4475f55eb3SErick Velez   },
4575f55eb3SErick Velez   "relationships": [
4675f55eb3SErick Velez     {
4775f55eb3SErick Velez       "kind": "memberOf",
4875f55eb3SErick Velez       "source": "c:@S@Foo@F@Foo#",
4975f55eb3SErick Velez       "target": "c:@S@Foo",
5075f55eb3SErick Velez       "targetFallback": "Foo"
5175f55eb3SErick Velez     },
5275f55eb3SErick Velez     {
5375f55eb3SErick Velez       "kind": "memberOf",
5475f55eb3SErick Velez       "source": "c:@S@Foo@F@~Foo#",
5575f55eb3SErick Velez       "target": "c:@S@Foo",
5675f55eb3SErick Velez       "targetFallback": "Foo"
5775f55eb3SErick Velez     }
5875f55eb3SErick Velez   ],
5975f55eb3SErick Velez   "symbols": [
6075f55eb3SErick Velez     {
6175f55eb3SErick Velez       "accessLevel": "public",
6275f55eb3SErick Velez       "declarationFragments": [
6375f55eb3SErick Velez         {
6475f55eb3SErick Velez           "kind": "keyword",
6575f55eb3SErick Velez           "spelling": "class"
6675f55eb3SErick Velez         },
6775f55eb3SErick Velez         {
6875f55eb3SErick Velez           "kind": "text",
6975f55eb3SErick Velez           "spelling": " "
7075f55eb3SErick Velez         },
7175f55eb3SErick Velez         {
7275f55eb3SErick Velez           "kind": "identifier",
7375f55eb3SErick Velez           "spelling": "Foo"
7475f55eb3SErick Velez         },
7575f55eb3SErick Velez         {
7675f55eb3SErick Velez           "kind": "text",
7775f55eb3SErick Velez           "spelling": ";"
7875f55eb3SErick Velez         }
7975f55eb3SErick Velez       ],
8075f55eb3SErick Velez       "identifier": {
8175f55eb3SErick Velez         "interfaceLanguage": "c++",
8275f55eb3SErick Velez         "precise": "c:@S@Foo"
8375f55eb3SErick Velez       },
8475f55eb3SErick Velez       "kind": {
8575f55eb3SErick Velez         "displayName": "Class",
8675f55eb3SErick Velez         "identifier": "c++.class"
8775f55eb3SErick Velez       },
8875f55eb3SErick Velez       "location": {
8975f55eb3SErick Velez         "position": {
9063537872SQuietMisdreavus           "character": 6,
9163537872SQuietMisdreavus           "line": 0
9275f55eb3SErick Velez         },
9375f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
9475f55eb3SErick Velez       },
9575f55eb3SErick Velez       "names": {
9675f55eb3SErick Velez         "navigator": [
9775f55eb3SErick Velez           {
9875f55eb3SErick Velez             "kind": "identifier",
9975f55eb3SErick Velez             "spelling": "Foo"
10075f55eb3SErick Velez           }
10175f55eb3SErick Velez         ],
10275f55eb3SErick Velez         "subHeading": [
10375f55eb3SErick Velez           {
10475f55eb3SErick Velez             "kind": "identifier",
10575f55eb3SErick Velez             "spelling": "Foo"
10675f55eb3SErick Velez           }
10775f55eb3SErick Velez         ],
10875f55eb3SErick Velez         "title": "Foo"
10975f55eb3SErick Velez       },
11075f55eb3SErick Velez       "pathComponents": [
11175f55eb3SErick Velez         "Foo"
11275f55eb3SErick Velez       ]
11375f55eb3SErick Velez     },
11475f55eb3SErick Velez     {
11575f55eb3SErick Velez       "accessLevel": "private",
11675f55eb3SErick Velez       "declarationFragments": [
11775f55eb3SErick Velez         {
11875f55eb3SErick Velez           "kind": "identifier",
11975f55eb3SErick Velez           "spelling": "Foo"
12075f55eb3SErick Velez         },
12175f55eb3SErick Velez         {
12275f55eb3SErick Velez           "kind": "text",
12375f55eb3SErick Velez           "spelling": "();"
12475f55eb3SErick Velez         }
12575f55eb3SErick Velez       ],
12675f55eb3SErick Velez       "functionSignature": {
12775f55eb3SErick Velez         "returns": [
12875f55eb3SErick Velez           {
12975f55eb3SErick Velez             "kind": "typeIdentifier",
13075f55eb3SErick Velez             "preciseIdentifier": "c:v",
13175f55eb3SErick Velez             "spelling": "void"
13275f55eb3SErick Velez           }
13375f55eb3SErick Velez         ]
13475f55eb3SErick Velez       },
13575f55eb3SErick Velez       "identifier": {
13675f55eb3SErick Velez         "interfaceLanguage": "c++",
13775f55eb3SErick Velez         "precise": "c:@S@Foo@F@Foo#"
13875f55eb3SErick Velez       },
13975f55eb3SErick Velez       "kind": {
140*e05c1b46SDaniel Grumberg         "displayName": "Constructor",
14175f55eb3SErick Velez         "identifier": "c++.method"
14275f55eb3SErick Velez       },
14375f55eb3SErick Velez       "location": {
14475f55eb3SErick Velez         "position": {
14563537872SQuietMisdreavus           "character": 2,
14663537872SQuietMisdreavus           "line": 1
14775f55eb3SErick Velez         },
14875f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
14975f55eb3SErick Velez       },
15075f55eb3SErick Velez       "names": {
15175f55eb3SErick Velez         "navigator": [
15275f55eb3SErick Velez           {
15375f55eb3SErick Velez             "kind": "identifier",
15475f55eb3SErick Velez             "spelling": "Foo"
15575f55eb3SErick Velez           }
15675f55eb3SErick Velez         ],
15775f55eb3SErick Velez         "subHeading": [
15875f55eb3SErick Velez           {
15975f55eb3SErick Velez             "kind": "identifier",
16075f55eb3SErick Velez             "spelling": "Foo"
16175f55eb3SErick Velez           }
16275f55eb3SErick Velez         ],
16375f55eb3SErick Velez         "title": "Foo"
16475f55eb3SErick Velez       },
16575f55eb3SErick Velez       "pathComponents": [
16675f55eb3SErick Velez         "Foo",
16775f55eb3SErick Velez         "Foo"
16875f55eb3SErick Velez       ]
16975f55eb3SErick Velez     },
17075f55eb3SErick Velez     {
17175f55eb3SErick Velez       "accessLevel": "private",
17275f55eb3SErick Velez       "declarationFragments": [
17375f55eb3SErick Velez         {
17475f55eb3SErick Velez           "kind": "identifier",
17575f55eb3SErick Velez           "spelling": "~Foo"
17675f55eb3SErick Velez         },
17775f55eb3SErick Velez         {
17875f55eb3SErick Velez           "kind": "text",
17975f55eb3SErick Velez           "spelling": "();"
18075f55eb3SErick Velez         }
18175f55eb3SErick Velez       ],
18275f55eb3SErick Velez       "functionSignature": {
18375f55eb3SErick Velez         "returns": [
18475f55eb3SErick Velez           {
18575f55eb3SErick Velez             "kind": "typeIdentifier",
18675f55eb3SErick Velez             "preciseIdentifier": "c:v",
18775f55eb3SErick Velez             "spelling": "void"
18875f55eb3SErick Velez           }
18975f55eb3SErick Velez         ]
19075f55eb3SErick Velez       },
19175f55eb3SErick Velez       "identifier": {
19275f55eb3SErick Velez         "interfaceLanguage": "c++",
19375f55eb3SErick Velez         "precise": "c:@S@Foo@F@~Foo#"
19475f55eb3SErick Velez       },
19575f55eb3SErick Velez       "kind": {
196*e05c1b46SDaniel Grumberg         "displayName": "Destructor",
19775f55eb3SErick Velez         "identifier": "c++.method"
19875f55eb3SErick Velez       },
19975f55eb3SErick Velez       "location": {
20075f55eb3SErick Velez         "position": {
20163537872SQuietMisdreavus           "character": 2,
20263537872SQuietMisdreavus           "line": 2
20375f55eb3SErick Velez         },
20475f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
20575f55eb3SErick Velez       },
20675f55eb3SErick Velez       "names": {
20775f55eb3SErick Velez         "navigator": [
20875f55eb3SErick Velez           {
20975f55eb3SErick Velez             "kind": "identifier",
21075f55eb3SErick Velez             "spelling": "~Foo"
21175f55eb3SErick Velez           }
21275f55eb3SErick Velez         ],
21375f55eb3SErick Velez         "subHeading": [
21475f55eb3SErick Velez           {
21575f55eb3SErick Velez             "kind": "identifier",
21675f55eb3SErick Velez             "spelling": "Foo"
21775f55eb3SErick Velez           }
21875f55eb3SErick Velez         ],
21975f55eb3SErick Velez         "title": "~Foo"
22075f55eb3SErick Velez       },
22175f55eb3SErick Velez       "pathComponents": [
22275f55eb3SErick Velez         "Foo",
22375f55eb3SErick Velez         "~Foo"
22475f55eb3SErick Velez       ]
22575f55eb3SErick Velez     }
22675f55eb3SErick Velez   ]
22775f55eb3SErick Velez }
228