Debian Codegraph @

gcc/testsuite/libgdiagnostics.dg/test-dump.c

raw
1 /* Usage example of dump API. */
2
3 #include "libgdiagnostics.h"
4
5 const int line_num = 42;
6
7 int
8 main ()
9 {
10 diagnostic_manager *diag_mgr = diagnostic_manager_new ();
11
12 const diagnostic_file *file = diagnostic_manager_new_file (diag_mgr, "foo.c", "c");
13
14 fprintf (stderr, "file: ");
15 diagnostic_manager_debug_dump_file (diag_mgr, file, stderr);
16 fprintf (stderr, "\n");
17 /* { dg-begin-multiline-output "" }
18 file: file(name="foo.c", sarif_source_language="c")
19 { dg-end-multiline-output "" } */
20
21 const diagnostic_physical_location *loc_start
22 = diagnostic_manager_new_location_from_file_line_column (diag_mgr, file, line_num, 8);
23 const diagnostic_physical_location *loc_end
24 = diagnostic_manager_new_location_from_file_line_column (diag_mgr, file, line_num, 19);
25 const diagnostic_physical_location *loc_range
26 = diagnostic_manager_new_location_from_range (diag_mgr,
27 loc_start,
28 loc_start,
29 loc_end);
30
31 fprintf (stderr, "loc_start: ");
32 diagnostic_manager_debug_dump_location (diag_mgr, loc_start, stderr);
33 fprintf (stderr, "\n");
34 /* { dg-begin-multiline-output "" }
35 loc_start: foo.c:42:8:
36 { dg-end-multiline-output "" } */
37
38 fprintf (stderr, "loc_end: ");
39 diagnostic_manager_debug_dump_location (diag_mgr, loc_end, stderr);
40 fprintf (stderr, "\n");
41 /* { dg-begin-multiline-output "" }
42 loc_end: foo.c:42:19:
43 { dg-end-multiline-output "" } */
44
45 fprintf (stderr, "loc_range: ");
46 diagnostic_manager_debug_dump_location (diag_mgr, loc_range, stderr);
47 fprintf (stderr, "\n");
48 /* { dg-begin-multiline-output "" }
49 loc_range: foo.c:42:8:
50 { dg-end-multiline-output "" } */
51
52 const diagnostic_logical_location *logical_loc
53 = diagnostic_manager_new_logical_location (diag_mgr,
54 DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION,
55 NULL, /* parent */
56 "test_short_name",
57 "test_qualified_name",
58 "test_decorated_name");
59
60 fprintf (stderr, "logical_loc: ");
61 diagnostic_manager_debug_dump_logical_location (diag_mgr, logical_loc, stderr);
62 fprintf (stderr, "\n");
63 /* { dg-begin-multiline-output "" }
64 logical_loc: logical_location(kind=function, short_name="test_short_name", fully_qualified_name="test_qualified_name", decorated_name="test_decorated_name")
65 { dg-end-multiline-output "" } */
66
67 diagnostic_manager_release (diag_mgr);
68 return 0;
69 };