Mercurial > hg > CbC > CbC_gcc
comparison gcc/diagnostic.h @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Various declarations for language-independent diagnostics subroutines. | 1 /* Various declarations for language-independent diagnostics subroutines. |
2 Copyright (C) 2000-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2020 Free Software Foundation, Inc. |
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com> | 3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com> |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
22 #define GCC_DIAGNOSTIC_H | 22 #define GCC_DIAGNOSTIC_H |
23 | 23 |
24 #include "pretty-print.h" | 24 #include "pretty-print.h" |
25 #include "diagnostic-core.h" | 25 #include "diagnostic-core.h" |
26 | 26 |
27 /* Enum for overriding the standard output format. */ | |
28 | |
29 enum diagnostics_output_format | |
30 { | |
31 /* The default: textual output. */ | |
32 DIAGNOSTICS_OUTPUT_FORMAT_TEXT, | |
33 | |
34 /* JSON-based output. */ | |
35 DIAGNOSTICS_OUTPUT_FORMAT_JSON | |
36 }; | |
37 | |
38 /* An enum for controlling how diagnostic_paths should be printed. */ | |
39 enum diagnostic_path_format | |
40 { | |
41 /* Don't print diagnostic_paths. */ | |
42 DPF_NONE, | |
43 | |
44 /* Print diagnostic_paths by emitting a separate "note" for every event | |
45 in the path. */ | |
46 DPF_SEPARATE_EVENTS, | |
47 | |
48 /* Print diagnostic_paths by consolidating events together where they | |
49 are close enough, and printing such runs of events with multiple | |
50 calls to diagnostic_show_locus, showing the individual events in | |
51 each run via labels in the source. */ | |
52 DPF_INLINE_EVENTS | |
53 }; | |
54 | |
27 /* A diagnostic is described by the MESSAGE to send, the FILE and LINE of | 55 /* A diagnostic is described by the MESSAGE to send, the FILE and LINE of |
28 its context and its KIND (ice, error, warning, note, ...) See complete | 56 its context and its KIND (ice, error, warning, note, ...) See complete |
29 list in diagnostic.def. */ | 57 list in diagnostic.def. */ |
30 struct diagnostic_info | 58 struct diagnostic_info |
31 { | 59 { |
32 /* Text to be formatted. */ | 60 /* Text to be formatted. */ |
33 text_info message; | 61 text_info message; |
34 | 62 |
35 /* The location at which the diagnostic is to be reported. */ | 63 /* The location at which the diagnostic is to be reported. */ |
36 rich_location *richloc; | 64 rich_location *richloc; |
65 | |
66 /* An optional bundle of metadata associated with the diagnostic | |
67 (or NULL). */ | |
68 const diagnostic_metadata *metadata; | |
37 | 69 |
38 /* Auxiliary data for client. */ | 70 /* Auxiliary data for client. */ |
39 void *x_data; | 71 void *x_data; |
40 /* The kind of diagnostic it is about. */ | 72 /* The kind of diagnostic it is about. */ |
41 diagnostic_t kind; | 73 diagnostic_t kind; |
58 diagnostic_info *); | 90 diagnostic_info *); |
59 | 91 |
60 typedef void (*diagnostic_start_span_fn) (diagnostic_context *, | 92 typedef void (*diagnostic_start_span_fn) (diagnostic_context *, |
61 expanded_location); | 93 expanded_location); |
62 | 94 |
63 typedef diagnostic_starter_fn diagnostic_finalizer_fn; | 95 typedef void (*diagnostic_finalizer_fn) (diagnostic_context *, |
96 diagnostic_info *, | |
97 diagnostic_t); | |
64 | 98 |
65 class edit_context; | 99 class edit_context; |
100 namespace json { class value; } | |
66 | 101 |
67 /* This data structure bundles altogether any information relevant to | 102 /* This data structure bundles altogether any information relevant to |
68 the context of a diagnostic message. */ | 103 the context of a diagnostic message. */ |
69 struct diagnostic_context | 104 struct diagnostic_context |
70 { | 105 { |
110 /* Maximum width of the source line printed. */ | 145 /* Maximum width of the source line printed. */ |
111 int caret_max_width; | 146 int caret_max_width; |
112 | 147 |
113 /* Character used for caret diagnostics. */ | 148 /* Character used for caret diagnostics. */ |
114 char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES]; | 149 char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES]; |
150 | |
151 /* True if we should print any CWE identifiers associated with | |
152 diagnostics. */ | |
153 bool show_cwe; | |
154 | |
155 /* How should diagnostic_path objects be printed. */ | |
156 enum diagnostic_path_format path_format; | |
157 | |
158 /* True if we should print stack depths when printing diagnostic paths. */ | |
159 bool show_path_depths; | |
115 | 160 |
116 /* True if we should print the command line option which controls | 161 /* True if we should print the command line option which controls |
117 each diagnostic, if known. */ | 162 each diagnostic, if known. */ |
118 bool show_option_requested; | 163 bool show_option_requested; |
119 | 164 |
165 /* Client hook to report an internal error. */ | 210 /* Client hook to report an internal error. */ |
166 void (*internal_error) (diagnostic_context *, const char *, va_list *); | 211 void (*internal_error) (diagnostic_context *, const char *, va_list *); |
167 | 212 |
168 /* Client hook to say whether the option controlling a diagnostic is | 213 /* Client hook to say whether the option controlling a diagnostic is |
169 enabled. Returns nonzero if enabled, zero if disabled. */ | 214 enabled. Returns nonzero if enabled, zero if disabled. */ |
170 int (*option_enabled) (int, void *); | 215 int (*option_enabled) (int, unsigned, void *); |
171 | 216 |
172 /* Client information to pass as second argument to | 217 /* Client information to pass as second argument to |
173 option_enabled. */ | 218 option_enabled. */ |
174 void *option_state; | 219 void *option_state; |
175 | 220 |
179 (of warnings as errors, etc.); the second is the kind after any | 224 (of warnings as errors, etc.); the second is the kind after any |
180 reclassification. May return NULL if no name is to be printed. | 225 reclassification. May return NULL if no name is to be printed. |
181 May be passed 0 as well as the index of a particular option. */ | 226 May be passed 0 as well as the index of a particular option. */ |
182 char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t); | 227 char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t); |
183 | 228 |
229 /* Client hook to return a URL describing the option that controls | |
230 a diagnostic. Returns malloced memory. May return NULL if no URL | |
231 is available. May be passed 0 as well as the index of a | |
232 particular option. */ | |
233 char *(*get_option_url) (diagnostic_context *, int); | |
234 | |
235 void (*print_path) (diagnostic_context *, const diagnostic_path *); | |
236 json::value *(*make_json_for_path) (diagnostic_context *, const diagnostic_path *); | |
237 | |
184 /* Auxiliary data for client. */ | 238 /* Auxiliary data for client. */ |
185 void *x_data; | 239 void *x_data; |
186 | 240 |
187 /* Used to detect that the last caret was printed at the same location. */ | 241 /* Used to detect that the last caret was printed at the same location. */ |
188 location_t last_location; | 242 location_t last_location; |
190 /* Used to detect when the input file stack has changed since last | 244 /* Used to detect when the input file stack has changed since last |
191 described. */ | 245 described. */ |
192 const line_map_ordinary *last_module; | 246 const line_map_ordinary *last_module; |
193 | 247 |
194 int lock; | 248 int lock; |
249 | |
250 /* A copy of lang_hooks.option_lang_mask (). */ | |
251 unsigned lang_mask; | |
195 | 252 |
196 bool inhibit_notes_p; | 253 bool inhibit_notes_p; |
197 | 254 |
198 /* When printing source code, should the characters at carets and ranges | 255 /* When printing source code, should the characters at carets and ranges |
199 be colorized? (assuming colorization is on at all). | 256 be colorized? (assuming colorization is on at all). |
241 void (*begin_group_cb) (diagnostic_context * context); | 298 void (*begin_group_cb) (diagnostic_context * context); |
242 | 299 |
243 /* If non-NULL, this will be called when a stack of groups is | 300 /* If non-NULL, this will be called when a stack of groups is |
244 popped if any diagnostics were emitted within that group. */ | 301 popped if any diagnostics were emitted within that group. */ |
245 void (*end_group_cb) (diagnostic_context * context); | 302 void (*end_group_cb) (diagnostic_context * context); |
303 | |
304 /* Callback for final cleanup. */ | |
305 void (*final_cb) (diagnostic_context *context); | |
246 }; | 306 }; |
247 | 307 |
248 static inline void | 308 static inline void |
249 diagnostic_inhibit_notes (diagnostic_context * context) | 309 diagnostic_inhibit_notes (diagnostic_context * context) |
250 { | 310 { |
310 } | 370 } |
311 | 371 |
312 /* Diagnostic related functions. */ | 372 /* Diagnostic related functions. */ |
313 extern void diagnostic_initialize (diagnostic_context *, int); | 373 extern void diagnostic_initialize (diagnostic_context *, int); |
314 extern void diagnostic_color_init (diagnostic_context *, int value = -1); | 374 extern void diagnostic_color_init (diagnostic_context *, int value = -1); |
375 extern void diagnostic_urls_init (diagnostic_context *, int value = -1); | |
315 extern void diagnostic_finish (diagnostic_context *); | 376 extern void diagnostic_finish (diagnostic_context *); |
316 extern void diagnostic_report_current_module (diagnostic_context *, location_t); | 377 extern void diagnostic_report_current_module (diagnostic_context *, location_t); |
317 extern void diagnostic_show_locus (diagnostic_context *, | 378 extern void diagnostic_show_locus (diagnostic_context *, |
318 rich_location *richloc, | 379 rich_location *richloc, |
319 diagnostic_t diagnostic_kind); | 380 diagnostic_t diagnostic_kind); |
381 extern void diagnostic_show_any_path (diagnostic_context *, diagnostic_info *); | |
320 | 382 |
321 /* Force diagnostics controlled by OPTIDX to be kind KIND. */ | 383 /* Force diagnostics controlled by OPTIDX to be kind KIND. */ |
322 extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, | 384 extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, |
323 int /* optidx */, | 385 int /* optidx */, |
324 diagnostic_t /* kind */, | 386 diagnostic_t /* kind */, |
339 #endif | 401 #endif |
340 extern char *diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *); | 402 extern char *diagnostic_build_prefix (diagnostic_context *, const diagnostic_info *); |
341 void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); | 403 void default_diagnostic_starter (diagnostic_context *, diagnostic_info *); |
342 void default_diagnostic_start_span_fn (diagnostic_context *, | 404 void default_diagnostic_start_span_fn (diagnostic_context *, |
343 expanded_location); | 405 expanded_location); |
344 void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); | 406 void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *, |
407 diagnostic_t); | |
345 void diagnostic_set_caret_max_width (diagnostic_context *context, int value); | 408 void diagnostic_set_caret_max_width (diagnostic_context *context, int value); |
346 void diagnostic_action_after_output (diagnostic_context *, diagnostic_t); | 409 void diagnostic_action_after_output (diagnostic_context *, diagnostic_t); |
347 void diagnostic_check_max_errors (diagnostic_context *, bool flush = false); | 410 void diagnostic_check_max_errors (diagnostic_context *, bool flush = false); |
348 | 411 |
349 void diagnostic_file_cache_fini (void); | 412 void diagnostic_file_cache_fini (void); |
399 /* Pure text formatting support functions. */ | 462 /* Pure text formatting support functions. */ |
400 extern char *file_name_as_prefix (diagnostic_context *, const char *); | 463 extern char *file_name_as_prefix (diagnostic_context *, const char *); |
401 | 464 |
402 extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1; | 465 extern char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1; |
403 | 466 |
467 extern void diagnostic_output_format_init (diagnostic_context *, | |
468 enum diagnostics_output_format); | |
469 | |
470 /* Compute the number of digits in the decimal representation of an integer. */ | |
471 extern int num_digits (int); | |
472 | |
473 extern json::value *json_from_expanded_location (location_t loc); | |
404 | 474 |
405 #endif /* ! GCC_DIAGNOSTIC_H */ | 475 #endif /* ! GCC_DIAGNOSTIC_H */ |