xref: /llvm-project/clang/test/ExtractAPI/operator_overload.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   int operator+(int x);
1675f55eb3SErick Velez };
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": "memberOf",
4775f55eb3SErick Velez       "source": "c:@S@Foo@F@operator+#I#",
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": "private",
10975f55eb3SErick Velez       "declarationFragments": [
11075f55eb3SErick Velez         {
11175f55eb3SErick Velez           "kind": "typeIdentifier",
11275f55eb3SErick Velez           "preciseIdentifier": "c:I",
11375f55eb3SErick Velez           "spelling": "int"
11475f55eb3SErick Velez         },
11575f55eb3SErick Velez         {
11675f55eb3SErick Velez           "kind": "text",
11775f55eb3SErick Velez           "spelling": " "
11875f55eb3SErick Velez         },
11975f55eb3SErick Velez         {
12075f55eb3SErick Velez           "kind": "identifier",
12175f55eb3SErick Velez           "spelling": "operator+"
12275f55eb3SErick Velez         },
12375f55eb3SErick Velez         {
12475f55eb3SErick Velez           "kind": "text",
12575f55eb3SErick Velez           "spelling": "("
12675f55eb3SErick Velez         },
12775f55eb3SErick Velez         {
12875f55eb3SErick Velez           "kind": "typeIdentifier",
12975f55eb3SErick Velez           "preciseIdentifier": "c:I",
13075f55eb3SErick Velez           "spelling": "int"
13175f55eb3SErick Velez         },
13275f55eb3SErick Velez         {
13375f55eb3SErick Velez           "kind": "text",
13475f55eb3SErick Velez           "spelling": " "
13575f55eb3SErick Velez         },
13675f55eb3SErick Velez         {
13775f55eb3SErick Velez           "kind": "internalParam",
13875f55eb3SErick Velez           "spelling": "x"
13975f55eb3SErick Velez         },
14075f55eb3SErick Velez         {
14175f55eb3SErick Velez           "kind": "text",
14275f55eb3SErick Velez           "spelling": ");"
14375f55eb3SErick Velez         }
14475f55eb3SErick Velez       ],
14575f55eb3SErick Velez       "functionSignature": {
14675f55eb3SErick Velez         "parameters": [
14775f55eb3SErick Velez           {
14875f55eb3SErick Velez             "declarationFragments": [
14975f55eb3SErick Velez               {
15075f55eb3SErick Velez                 "kind": "typeIdentifier",
15175f55eb3SErick Velez                 "preciseIdentifier": "c:I",
15275f55eb3SErick Velez                 "spelling": "int"
15375f55eb3SErick Velez               },
15475f55eb3SErick Velez               {
15575f55eb3SErick Velez                 "kind": "text",
15675f55eb3SErick Velez                 "spelling": " "
15775f55eb3SErick Velez               },
15875f55eb3SErick Velez               {
15975f55eb3SErick Velez                 "kind": "internalParam",
16075f55eb3SErick Velez                 "spelling": "x"
16175f55eb3SErick Velez               }
16275f55eb3SErick Velez             ],
16375f55eb3SErick Velez             "name": "x"
16475f55eb3SErick Velez           }
16575f55eb3SErick Velez         ],
16675f55eb3SErick Velez         "returns": [
16775f55eb3SErick Velez           {
16875f55eb3SErick Velez             "kind": "typeIdentifier",
16975f55eb3SErick Velez             "preciseIdentifier": "c:I",
17075f55eb3SErick Velez             "spelling": "int"
17175f55eb3SErick Velez           }
17275f55eb3SErick Velez         ]
17375f55eb3SErick Velez       },
17475f55eb3SErick Velez       "identifier": {
17575f55eb3SErick Velez         "interfaceLanguage": "c++",
17675f55eb3SErick Velez         "precise": "c:@S@Foo@F@operator+#I#"
17775f55eb3SErick Velez       },
17875f55eb3SErick Velez       "kind": {
17975f55eb3SErick Velez         "displayName": "Instance Method",
18075f55eb3SErick Velez         "identifier": "c++.method"
18175f55eb3SErick Velez       },
18275f55eb3SErick Velez       "location": {
18375f55eb3SErick Velez         "position": {
18463537872SQuietMisdreavus           "character": 6,
18563537872SQuietMisdreavus           "line": 1
18675f55eb3SErick Velez         },
18775f55eb3SErick Velez         "uri": "file://INPUT_DIR/input.h"
18875f55eb3SErick Velez       },
18975f55eb3SErick Velez       "names": {
19075f55eb3SErick Velez         "navigator": [
19175f55eb3SErick Velez           {
19275f55eb3SErick Velez             "kind": "identifier",
19375f55eb3SErick Velez             "spelling": "operator+"
19475f55eb3SErick Velez           }
19575f55eb3SErick Velez         ],
19675f55eb3SErick Velez         "subHeading": [
19775f55eb3SErick Velez           {
19875f55eb3SErick Velez             "kind": "identifier",
19975f55eb3SErick Velez             "spelling": "operator+"
20075f55eb3SErick Velez           }
20175f55eb3SErick Velez         ],
20275f55eb3SErick Velez         "title": "operator+"
20375f55eb3SErick Velez       },
20475f55eb3SErick Velez       "pathComponents": [
20575f55eb3SErick Velez         "Foo",
20675f55eb3SErick Velez         "operator+"
20775f55eb3SErick Velez       ]
20875f55eb3SErick Velez     }
20975f55eb3SErick Velez   ]
21075f55eb3SErick Velez }
211