Debian Codegraph @

clang/test/ExtractAPI/emit-symbol-graph/single_file.c

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
5 // RUN: %t/reference.output.json.in >> %t/reference.output.json
6 // RUN: %clang_cc1 %t/main.c -emit-symbol-graph --pretty-sgf \
7 // RUN: --symbol-graph-dir=%t/SymbolGraphs --product-name=basicfile -triple=x86_64-apple-macosx12.0.0
8
9 // Generator version is not consistent across test runs, normalize it.
10 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
11 // RUN: %t/SymbolGraphs/main.c.symbols.json >> %t/output-normalized.json
12 // RUN: diff %t/reference.output.json %t/output-normalized.json
13
14 // CHECK-NOT: error:
15 // CHECK-NOT: warning:
16
17 //--- main.c
18 #define TESTMACRO1 2
19 #define TESTMARCRO2 5
20
21 int main ()
22 {
23 return 0;
24 }
25
26
27 //--- reference.output.json.in
28 {
29 "metadata": {
30 "formatVersion": {
31 "major": 0,
32 "minor": 5,
33 "patch": 3
34 },
35 "generator": "?"
36 },
37 "module": {
38 "name": "basicfile",
39 "platform": {
40 "architecture": "x86_64",
41 "operatingSystem": {
42 "name": "macosx"
43 },
44 "vendor": "apple"
45 }
46 },
47 "relationships": [],
48 "symbols": [
49 {
50 "accessLevel": "public",
51 "declarationFragments": [
52 {
53 "kind": "typeIdentifier",
54 "preciseIdentifier": "c:I",
55 "spelling": "int"
56 },
57 {
58 "kind": "text",
59 "spelling": " "
60 },
61 {
62 "kind": "identifier",
63 "spelling": "main"
64 },
65 {
66 "kind": "text",
67 "spelling": "();"
68 }
69 ],
70 "functionSignature": {
71 "returns": [
72 {
73 "kind": "typeIdentifier",
74 "preciseIdentifier": "c:I",
75 "spelling": "int"
76 }
77 ]
78 },
79 "identifier": {
80 "interfaceLanguage": "c",
81 "precise": "c:@F@main"
82 },
83 "kind": {
84 "displayName": "Function",
85 "identifier": "c.func"
86 },
87 "location": {
88 "position": {
89 "character": 4,
90 "line": 3
91 },
92 "uri": "file://INPUT_DIR/main.c"
93 },
94 "names": {
95 "navigator": [
96 {
97 "kind": "identifier",
98 "spelling": "main"
99 }
100 ],
101 "subHeading": [
102 {
103 "kind": "identifier",
104 "spelling": "main"
105 }
106 ],
107 "title": "main"
108 },
109 "pathComponents": [
110 "main"
111 ]
112 },
113 {
114 "accessLevel": "public",
115 "declarationFragments": [
116 {
117 "kind": "keyword",
118 "spelling": "#define"
119 },
120 {
121 "kind": "text",
122 "spelling": " "
123 },
124 {
125 "kind": "identifier",
126 "spelling": "TESTMACRO1"
127 }
128 ],
129 "identifier": {
130 "interfaceLanguage": "c",
131 "precise": "c:main.c@8@macro@TESTMACRO1"
132 },
133 "kind": {
134 "displayName": "Macro",
135 "identifier": "c.macro"
136 },
137 "location": {
138 "position": {
139 "character": 8,
140 "line": 0
141 },
142 "uri": "file://INPUT_DIR/main.c"
143 },
144 "names": {
145 "navigator": [
146 {
147 "kind": "identifier",
148 "spelling": "TESTMACRO1"
149 }
150 ],
151 "subHeading": [
152 {
153 "kind": "identifier",
154 "spelling": "TESTMACRO1"
155 }
156 ],
157 "title": "TESTMACRO1"
158 },
159 "pathComponents": [
160 "TESTMACRO1"
161 ]
162 },
163 {
164 "accessLevel": "public",
165 "declarationFragments": [
166 {
167 "kind": "keyword",
168 "spelling": "#define"
169 },
170 {
171 "kind": "text",
172 "spelling": " "
173 },
174 {
175 "kind": "identifier",
176 "spelling": "TESTMARCRO2"
177 }
178 ],
179 "identifier": {
180 "interfaceLanguage": "c",
181 "precise": "c:main.c@29@macro@TESTMARCRO2"
182 },
183 "kind": {
184 "displayName": "Macro",
185 "identifier": "c.macro"
186 },
187 "location": {
188 "position": {
189 "character": 8,
190 "line": 1
191 },
192 "uri": "file://INPUT_DIR/main.c"
193 },
194 "names": {
195 "navigator": [
196 {
197 "kind": "identifier",
198 "spelling": "TESTMARCRO2"
199 }
200 ],
201 "subHeading": [
202 {
203 "kind": "identifier",
204 "spelling": "TESTMARCRO2"
205 }
206 ],
207 "title": "TESTMARCRO2"
208 },
209 "pathComponents": [
210 "TESTMARCRO2"
211 ]
212 }
213 ]
214 }