xref: /llvm-project/clang/test/ExtractAPI/simple_inheritance.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 
1675f55eb3SErick Velez class Bar : public Foo {};
1775f55eb3SErick Velez /// expected-no-diagnostics
1875f55eb3SErick Velez 
1975f55eb3SErick Velez //--- reference.output.json.in
2075f55eb3SErick Velez {
2175f55eb3SErick Velez   "metadata": {
2275f55eb3SErick Velez     "formatVersion": {
2375f55eb3SErick Velez       "major": 0,
2475f55eb3SErick Velez       "minor": 5,
2575f55eb3SErick Velez       "patch": 3
2675f55eb3SErick Velez     },
2775f55eb3SErick Velez     "generator": "?"
2875f55eb3SErick Velez   },
2975f55eb3SErick Velez   "module": {
3075f55eb3SErick Velez     "name": "",
3175f55eb3SErick Velez     "platform": {
3275f55eb3SErick Velez       "architecture": "arm64",
3375f55eb3SErick Velez       "operatingSystem": {
3475f55eb3SErick Velez         "minimumVersion": {
3575f55eb3SErick Velez           "major": 11,
3675f55eb3SErick Velez           "minor": 0,
3775f55eb3SErick Velez           "patch": 0
3875f55eb3SErick Velez         },
3975f55eb3SErick Velez         "name": "macosx"
4075f55eb3SErick Velez       },
4175f55eb3SErick Velez       "vendor": "apple"
4275f55eb3SErick Velez     }
4375f55eb3SErick Velez   },
4475f55eb3SErick Velez   "relationships": [
4575f55eb3SErick Velez     {
4675f55eb3SErick Velez       "kind": "inheritsFrom",
4775f55eb3SErick Velez       "source": "c:@S@Bar",
4875f55eb3SErick Velez       "target": "c:@S@Foo",
4975f55eb3SErick Velez       "targetFallback": "Foo"
5075f55eb3SErick Velez     }
5175f55eb3SErick Velez   ],
5275f55eb3SErick Velez   "symbols": [
5375f55eb3SErick Velez     {
5475f55eb3SErick Velez       "accessLevel": "public",
5575f55eb3SErick Velez       "declarationFragments": [
5675f55eb3SErick Velez         {
5775f55eb3SErick Velez           "kind": "keyword",
5875f55eb3SErick Velez           "spelling": "class"
5975f55eb3SErick Velez         },
6075f55eb3SErick Velez         {
6175f55eb3SErick Velez           "kind": "text",
6275f55eb3SErick Velez           "spelling": " "
6375f55eb3SErick Velez         },
6475f55eb3SErick Velez         {
6575f55eb3SErick Velez           "kind": "identifier",
6675f55eb3SErick Velez           "spelling": "Foo"
6775f55eb3SErick Velez         },
6875f55eb3SErick Velez         {
6975f55eb3SErick Velez           "kind": "text",
7075f55eb3SErick Velez           "spelling": ";"
7175f55eb3SErick Velez         }
7275f55eb3SErick Velez       ],
7375f55eb3SErick Velez       "identifier": {
7475f55eb3SErick Velez         "interfaceLanguage": "c++",
7575f55eb3SErick Velez         "precise": "c:@S@Foo"
7675f55eb3SErick Velez       },
7775f55eb3SErick Velez       "kind": {
7875f55eb3SErick Velez         "displayName": "Class",
7975f55eb3SErick Velez         "identifier": "c++.class"
8075f55eb3SErick Velez       },
8175f55eb3SErick Velez       "location": {
8275f55eb3SErick Velez         "position": {
8363537872SQuietMisdreavus           "character": 6,
8463537872SQuietMisdreavus           "line": 0
8575f55eb3SErick Velez         },
8675f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
8775f55eb3SErick Velez       },
8875f55eb3SErick Velez       "names": {
8975f55eb3SErick Velez         "navigator": [
9075f55eb3SErick Velez           {
9175f55eb3SErick Velez             "kind": "identifier",
9275f55eb3SErick Velez             "spelling": "Foo"
9375f55eb3SErick Velez           }
9475f55eb3SErick Velez         ],
9575f55eb3SErick Velez         "subHeading": [
9675f55eb3SErick Velez           {
9775f55eb3SErick Velez             "kind": "identifier",
9875f55eb3SErick Velez             "spelling": "Foo"
9975f55eb3SErick Velez           }
10075f55eb3SErick Velez         ],
10175f55eb3SErick Velez         "title": "Foo"
10275f55eb3SErick Velez       },
10375f55eb3SErick Velez       "pathComponents": [
10475f55eb3SErick Velez         "Foo"
10575f55eb3SErick Velez       ]
10675f55eb3SErick Velez     },
10775f55eb3SErick Velez     {
10875f55eb3SErick Velez       "accessLevel": "public",
10975f55eb3SErick Velez       "declarationFragments": [
11075f55eb3SErick Velez         {
11175f55eb3SErick Velez           "kind": "keyword",
11275f55eb3SErick Velez           "spelling": "class"
11375f55eb3SErick Velez         },
11475f55eb3SErick Velez         {
11575f55eb3SErick Velez           "kind": "text",
11675f55eb3SErick Velez           "spelling": " "
11775f55eb3SErick Velez         },
11875f55eb3SErick Velez         {
11975f55eb3SErick Velez           "kind": "identifier",
12075f55eb3SErick Velez           "spelling": "Bar"
12175f55eb3SErick Velez         },
12275f55eb3SErick Velez         {
12375f55eb3SErick Velez           "kind": "text",
12475f55eb3SErick Velez           "spelling": ";"
12575f55eb3SErick Velez         }
12675f55eb3SErick Velez       ],
12775f55eb3SErick Velez       "identifier": {
12875f55eb3SErick Velez         "interfaceLanguage": "c++",
12975f55eb3SErick Velez         "precise": "c:@S@Bar"
13075f55eb3SErick Velez       },
13175f55eb3SErick Velez       "kind": {
13275f55eb3SErick Velez         "displayName": "Class",
13375f55eb3SErick Velez         "identifier": "c++.class"
13475f55eb3SErick Velez       },
13575f55eb3SErick Velez       "location": {
13675f55eb3SErick Velez         "position": {
13763537872SQuietMisdreavus           "character": 6,
13863537872SQuietMisdreavus           "line": 2
13975f55eb3SErick Velez         },
14075f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
14175f55eb3SErick Velez       },
14275f55eb3SErick Velez       "names": {
14375f55eb3SErick Velez         "navigator": [
14475f55eb3SErick Velez           {
14575f55eb3SErick Velez             "kind": "identifier",
14675f55eb3SErick Velez             "spelling": "Bar"
14775f55eb3SErick Velez           }
14875f55eb3SErick Velez         ],
14975f55eb3SErick Velez         "subHeading": [
15075f55eb3SErick Velez           {
15175f55eb3SErick Velez             "kind": "identifier",
15275f55eb3SErick Velez             "spelling": "Bar"
15375f55eb3SErick Velez           }
15475f55eb3SErick Velez         ],
15575f55eb3SErick Velez         "title": "Bar"
15675f55eb3SErick Velez       },
15775f55eb3SErick Velez       "pathComponents": [
15875f55eb3SErick Velez         "Bar"
15975f55eb3SErick Velez       ]
16075f55eb3SErick Velez     }
16175f55eb3SErick Velez   ]
16275f55eb3SErick Velez }
163