xref: /llvm-project/clang/test/ExtractAPI/simple_inheritance.cpp (revision e05c1b46d0d3739cc48ad912dbe6e9affce05927)
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
7 
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
12 
13 //--- input.h
14 class Foo {};
15 
16 class Bar : public Foo {};
17 /// expected-no-diagnostics
18 
19 //--- reference.output.json.in
20 {
21   "metadata": {
22     "formatVersion": {
23       "major": 0,
24       "minor": 5,
25       "patch": 3
26     },
27     "generator": "?"
28   },
29   "module": {
30     "name": "",
31     "platform": {
32       "architecture": "arm64",
33       "operatingSystem": {
34         "minimumVersion": {
35           "major": 11,
36           "minor": 0,
37           "patch": 0
38         },
39         "name": "macosx"
40       },
41       "vendor": "apple"
42     }
43   },
44   "relationships": [
45     {
46       "kind": "inheritsFrom",
47       "source": "c:@S@Bar",
48       "target": "c:@S@Foo",
49       "targetFallback": "Foo"
50     }
51   ],
52   "symbols": [
53     {
54       "accessLevel": "public",
55       "declarationFragments": [
56         {
57           "kind": "keyword",
58           "spelling": "class"
59         },
60         {
61           "kind": "text",
62           "spelling": " "
63         },
64         {
65           "kind": "identifier",
66           "spelling": "Foo"
67         },
68         {
69           "kind": "text",
70           "spelling": ";"
71         }
72       ],
73       "identifier": {
74         "interfaceLanguage": "c++",
75         "precise": "c:@S@Foo"
76       },
77       "kind": {
78         "displayName": "Class",
79         "identifier": "c++.class"
80       },
81       "location": {
82         "position": {
83           "character": 6,
84           "line": 0
85         },
86         "uri": "file://INPUT_DIR/input.h"
87       },
88       "names": {
89         "navigator": [
90           {
91             "kind": "identifier",
92             "spelling": "Foo"
93           }
94         ],
95         "subHeading": [
96           {
97             "kind": "identifier",
98             "spelling": "Foo"
99           }
100         ],
101         "title": "Foo"
102       },
103       "pathComponents": [
104         "Foo"
105       ]
106     },
107     {
108       "accessLevel": "public",
109       "declarationFragments": [
110         {
111           "kind": "keyword",
112           "spelling": "class"
113         },
114         {
115           "kind": "text",
116           "spelling": " "
117         },
118         {
119           "kind": "identifier",
120           "spelling": "Bar"
121         },
122         {
123           "kind": "text",
124           "spelling": ";"
125         }
126       ],
127       "identifier": {
128         "interfaceLanguage": "c++",
129         "precise": "c:@S@Bar"
130       },
131       "kind": {
132         "displayName": "Class",
133         "identifier": "c++.class"
134       },
135       "location": {
136         "position": {
137           "character": 6,
138           "line": 2
139         },
140         "uri": "file://INPUT_DIR/input.h"
141       },
142       "names": {
143         "navigator": [
144           {
145             "kind": "identifier",
146             "spelling": "Bar"
147           }
148         ],
149         "subHeading": [
150           {
151             "kind": "identifier",
152             "spelling": "Bar"
153           }
154         ],
155         "title": "Bar"
156       },
157       "pathComponents": [
158         "Bar"
159       ]
160     }
161   ]
162 }
163