Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ExtractAPI / emit-symbol-graph / multi_file.c
blob1b44cfbdeb75a9888a0ebbcddaa494c48ac712b9
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.main.json.in >> %t/reference.main.json
6 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
7 // RUN: %t/reference.test.json.in >> %t/reference.test.json
8 // RUN: %clang_cc1 %t/test.c %t/main.c --emit-symbol-graph=%t/SymbolGraphs --product-name=multifile_test -triple=x86_64-apple-macosx12.0.0
10 // Test main.json
11 // Generator version is not consistent across test runs, normalize it.
12 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
13 // RUN: %t/SymbolGraphs/main.json > %t/output-normalized.json
14 // RUN: diff %t/reference.main.json %t/output-normalized.json
16 // Test test.json
17 // Generator version is not consistent across test runs, normalize it.
18 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
19 // RUN: %t/SymbolGraphs/test.json > %t/output-normalized.json
20 // RUN: diff %t/reference.test.json %t/output-normalized.json
22 // CHECK-NOT: error:
23 // CHECK-NOT: warning:
25 //--- test.h
26 #ifndef TEST_H
27 #define TEST_H
29 #define testmarcro1 32
30 #define testmacro2 42
32 int testfunc (int param1, int param2);
33 void testfunc2 ();
34 #endif /* TEST_H */
36 //--- test.c
37 #include "test.h"
39 int testfunc(int param1, int param2) { return param1 + param2; }
41 void testfunc2() {}
43 //--- main.c
44 #include "test.h"
46 int main ()
48 testfunc2();
49 return 0;
52 //--- reference.main.json.in
54 "metadata": {
55 "formatVersion": {
56 "major": 0,
57 "minor": 5,
58 "patch": 3
60 "generator": "?"
62 "module": {
63 "name": "multifile_test",
64 "platform": {
65 "architecture": "x86_64",
66 "operatingSystem": {
67 "name": "macosx"
69 "vendor": "apple"
72 "relationships": [],
73 "symbols": [
75 "accessLevel": "public",
76 "declarationFragments": [
78 "kind": "typeIdentifier",
79 "preciseIdentifier": "c:I",
80 "spelling": "int"
83 "kind": "text",
84 "spelling": " "
87 "kind": "identifier",
88 "spelling": "testfunc"
91 "kind": "text",
92 "spelling": "("
95 "kind": "typeIdentifier",
96 "preciseIdentifier": "c:I",
97 "spelling": "int"
100 "kind": "text",
101 "spelling": " "
104 "kind": "internalParam",
105 "spelling": "param1"
108 "kind": "text",
109 "spelling": ", "
112 "kind": "typeIdentifier",
113 "preciseIdentifier": "c:I",
114 "spelling": "int"
117 "kind": "text",
118 "spelling": " "
121 "kind": "internalParam",
122 "spelling": "param2"
125 "kind": "text",
126 "spelling": ");"
129 "functionSignature": {
130 "parameters": [
132 "declarationFragments": [
134 "kind": "typeIdentifier",
135 "preciseIdentifier": "c:I",
136 "spelling": "int"
139 "kind": "text",
140 "spelling": " "
143 "kind": "internalParam",
144 "spelling": "param1"
147 "name": "param1"
150 "declarationFragments": [
152 "kind": "typeIdentifier",
153 "preciseIdentifier": "c:I",
154 "spelling": "int"
157 "kind": "text",
158 "spelling": " "
161 "kind": "internalParam",
162 "spelling": "param2"
165 "name": "param2"
168 "returns": [
170 "kind": "typeIdentifier",
171 "preciseIdentifier": "c:I",
172 "spelling": "int"
176 "identifier": {
177 "interfaceLanguage": "c",
178 "precise": "c:@F@testfunc"
180 "kind": {
181 "displayName": "Function",
182 "identifier": "c.func"
184 "location": {
185 "position": {
186 "character": 5,
187 "line": 7
189 "uri": "file://INPUT_DIR/test.h"
191 "names": {
192 "navigator": [
194 "kind": "identifier",
195 "spelling": "testfunc"
198 "subHeading": [
200 "kind": "identifier",
201 "spelling": "testfunc"
204 "title": "testfunc"
206 "pathComponents": [
207 "testfunc"
211 "accessLevel": "public",
212 "declarationFragments": [
214 "kind": "typeIdentifier",
215 "preciseIdentifier": "c:v",
216 "spelling": "void"
219 "kind": "text",
220 "spelling": " "
223 "kind": "identifier",
224 "spelling": "testfunc2"
227 "kind": "text",
228 "spelling": "();"
231 "functionSignature": {
232 "returns": [
234 "kind": "typeIdentifier",
235 "preciseIdentifier": "c:v",
236 "spelling": "void"
240 "identifier": {
241 "interfaceLanguage": "c",
242 "precise": "c:@F@testfunc2"
244 "kind": {
245 "displayName": "Function",
246 "identifier": "c.func"
248 "location": {
249 "position": {
250 "character": 6,
251 "line": 8
253 "uri": "file://INPUT_DIR/test.h"
255 "names": {
256 "navigator": [
258 "kind": "identifier",
259 "spelling": "testfunc2"
262 "subHeading": [
264 "kind": "identifier",
265 "spelling": "testfunc2"
268 "title": "testfunc2"
270 "pathComponents": [
271 "testfunc2"
275 "accessLevel": "public",
276 "declarationFragments": [
278 "kind": "typeIdentifier",
279 "preciseIdentifier": "c:I",
280 "spelling": "int"
283 "kind": "text",
284 "spelling": " "
287 "kind": "identifier",
288 "spelling": "main"
291 "kind": "text",
292 "spelling": "();"
295 "functionSignature": {
296 "returns": [
298 "kind": "typeIdentifier",
299 "preciseIdentifier": "c:I",
300 "spelling": "int"
304 "identifier": {
305 "interfaceLanguage": "c",
306 "precise": "c:@F@main"
308 "kind": {
309 "displayName": "Function",
310 "identifier": "c.func"
312 "location": {
313 "position": {
314 "character": 5,
315 "line": 3
317 "uri": "file://INPUT_DIR/main.c"
319 "names": {
320 "navigator": [
322 "kind": "identifier",
323 "spelling": "main"
326 "subHeading": [
328 "kind": "identifier",
329 "spelling": "main"
332 "title": "main"
334 "pathComponents": [
335 "main"
339 "accessLevel": "public",
340 "declarationFragments": [
342 "kind": "keyword",
343 "spelling": "#define"
346 "kind": "text",
347 "spelling": " "
350 "kind": "identifier",
351 "spelling": "testmarcro1"
354 "identifier": {
355 "interfaceLanguage": "c",
356 "precise": "c:test.h@39@macro@testmarcro1"
358 "kind": {
359 "displayName": "Macro",
360 "identifier": "c.macro"
362 "location": {
363 "position": {
364 "character": 9,
365 "line": 4
367 "uri": "file://INPUT_DIR/test.h"
369 "names": {
370 "navigator": [
372 "kind": "identifier",
373 "spelling": "testmarcro1"
376 "subHeading": [
378 "kind": "identifier",
379 "spelling": "testmarcro1"
382 "title": "testmarcro1"
384 "pathComponents": [
385 "testmarcro1"
389 "accessLevel": "public",
390 "declarationFragments": [
392 "kind": "keyword",
393 "spelling": "#define"
396 "kind": "text",
397 "spelling": " "
400 "kind": "identifier",
401 "spelling": "testmacro2"
404 "identifier": {
405 "interfaceLanguage": "c",
406 "precise": "c:test.h@62@macro@testmacro2"
408 "kind": {
409 "displayName": "Macro",
410 "identifier": "c.macro"
412 "location": {
413 "position": {
414 "character": 9,
415 "line": 5
417 "uri": "file://INPUT_DIR/test.h"
419 "names": {
420 "navigator": [
422 "kind": "identifier",
423 "spelling": "testmacro2"
426 "subHeading": [
428 "kind": "identifier",
429 "spelling": "testmacro2"
432 "title": "testmacro2"
434 "pathComponents": [
435 "testmacro2"
440 //--- reference.test.json.in
442 "metadata": {
443 "formatVersion": {
444 "major": 0,
445 "minor": 5,
446 "patch": 3
448 "generator": "?"
450 "module": {
451 "name": "multifile_test",
452 "platform": {
453 "architecture": "x86_64",
454 "operatingSystem": {
455 "name": "macosx"
457 "vendor": "apple"
460 "relationships": [],
461 "symbols": [
463 "accessLevel": "public",
464 "declarationFragments": [
466 "kind": "typeIdentifier",
467 "preciseIdentifier": "c:I",
468 "spelling": "int"
471 "kind": "text",
472 "spelling": " "
475 "kind": "identifier",
476 "spelling": "testfunc"
479 "kind": "text",
480 "spelling": "("
483 "kind": "typeIdentifier",
484 "preciseIdentifier": "c:I",
485 "spelling": "int"
488 "kind": "text",
489 "spelling": " "
492 "kind": "internalParam",
493 "spelling": "param1"
496 "kind": "text",
497 "spelling": ", "
500 "kind": "typeIdentifier",
501 "preciseIdentifier": "c:I",
502 "spelling": "int"
505 "kind": "text",
506 "spelling": " "
509 "kind": "internalParam",
510 "spelling": "param2"
513 "kind": "text",
514 "spelling": ");"
517 "functionSignature": {
518 "parameters": [
520 "declarationFragments": [
522 "kind": "typeIdentifier",
523 "preciseIdentifier": "c:I",
524 "spelling": "int"
527 "kind": "text",
528 "spelling": " "
531 "kind": "internalParam",
532 "spelling": "param1"
535 "name": "param1"
538 "declarationFragments": [
540 "kind": "typeIdentifier",
541 "preciseIdentifier": "c:I",
542 "spelling": "int"
545 "kind": "text",
546 "spelling": " "
549 "kind": "internalParam",
550 "spelling": "param2"
553 "name": "param2"
556 "returns": [
558 "kind": "typeIdentifier",
559 "preciseIdentifier": "c:I",
560 "spelling": "int"
564 "identifier": {
565 "interfaceLanguage": "c",
566 "precise": "c:@F@testfunc"
568 "kind": {
569 "displayName": "Function",
570 "identifier": "c.func"
572 "location": {
573 "position": {
574 "character": 5,
575 "line": 7
577 "uri": "file://INPUT_DIR/test.h"
579 "names": {
580 "navigator": [
582 "kind": "identifier",
583 "spelling": "testfunc"
586 "subHeading": [
588 "kind": "identifier",
589 "spelling": "testfunc"
592 "title": "testfunc"
594 "pathComponents": [
595 "testfunc"
599 "accessLevel": "public",
600 "declarationFragments": [
602 "kind": "typeIdentifier",
603 "preciseIdentifier": "c:v",
604 "spelling": "void"
607 "kind": "text",
608 "spelling": " "
611 "kind": "identifier",
612 "spelling": "testfunc2"
615 "kind": "text",
616 "spelling": "();"
619 "functionSignature": {
620 "returns": [
622 "kind": "typeIdentifier",
623 "preciseIdentifier": "c:v",
624 "spelling": "void"
628 "identifier": {
629 "interfaceLanguage": "c",
630 "precise": "c:@F@testfunc2"
632 "kind": {
633 "displayName": "Function",
634 "identifier": "c.func"
636 "location": {
637 "position": {
638 "character": 6,
639 "line": 8
641 "uri": "file://INPUT_DIR/test.h"
643 "names": {
644 "navigator": [
646 "kind": "identifier",
647 "spelling": "testfunc2"
650 "subHeading": [
652 "kind": "identifier",
653 "spelling": "testfunc2"
656 "title": "testfunc2"
658 "pathComponents": [
659 "testfunc2"
663 "accessLevel": "public",
664 "declarationFragments": [
666 "kind": "keyword",
667 "spelling": "#define"
670 "kind": "text",
671 "spelling": " "
674 "kind": "identifier",
675 "spelling": "testmarcro1"
678 "identifier": {
679 "interfaceLanguage": "c",
680 "precise": "c:test.h@39@macro@testmarcro1"
682 "kind": {
683 "displayName": "Macro",
684 "identifier": "c.macro"
686 "location": {
687 "position": {
688 "character": 9,
689 "line": 4
691 "uri": "file://INPUT_DIR/test.h"
693 "names": {
694 "navigator": [
696 "kind": "identifier",
697 "spelling": "testmarcro1"
700 "subHeading": [
702 "kind": "identifier",
703 "spelling": "testmarcro1"
706 "title": "testmarcro1"
708 "pathComponents": [
709 "testmarcro1"
713 "accessLevel": "public",
714 "declarationFragments": [
716 "kind": "keyword",
717 "spelling": "#define"
720 "kind": "text",
721 "spelling": " "
724 "kind": "identifier",
725 "spelling": "testmacro2"
728 "identifier": {
729 "interfaceLanguage": "c",
730 "precise": "c:test.h@62@macro@testmacro2"
732 "kind": {
733 "displayName": "Macro",
734 "identifier": "c.macro"
736 "location": {
737 "position": {
738 "character": 9,
739 "line": 5
741 "uri": "file://INPUT_DIR/test.h"
743 "names": {
744 "navigator": [
746 "kind": "identifier",
747 "spelling": "testmacro2"
750 "subHeading": [
752 "kind": "identifier",
753 "spelling": "testmacro2"
756 "title": "testmacro2"
758 "pathComponents": [
759 "testmacro2"