GCC Middle and Back End API Reference
|
#include <diagnostic.h>
Public Types | |
typedef void(* | ice_handler_callback_t) (diagnostic_context *) |
typedef void(* | set_locations_callback_t) (diagnostic_context *, diagnostic_info *) |
Private Member Functions | |
bool | includes_seen_p (const line_map_ordinary *map) |
void | print_any_cwe (const diagnostic_info &diagnostic) |
void | print_any_rules (const diagnostic_info &diagnostic) |
void | print_option_information (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) |
void | show_any_path (const diagnostic_info &diagnostic) |
void | error_recursion () ATTRIBUTE_NORETURN |
bool | diagnostic_enabled (diagnostic_info *diagnostic) |
void | get_any_inlining_info (diagnostic_info *diagnostic) |
void | show_locus (const rich_location &richloc, diagnostic_t diagnostic_kind, pretty_printer *pp, diagnostic_source_effect_info *effect_info) |
Friends | |
diagnostic_starter_fn & | diagnostic_starter (diagnostic_context *context) |
diagnostic_start_span_fn & | diagnostic_start_span (diagnostic_context *context) |
diagnostic_finalizer_fn & | diagnostic_finalizer (diagnostic_context *context) |
This data structure bundles altogether any information relevant to the context of a diagnostic message.
typedef void(* diagnostic_context::ice_handler_callback_t) (diagnostic_context *) |
typedef void(* diagnostic_context::set_locations_callback_t) (diagnostic_context *, diagnostic_info *) |
void diagnostic_context::action_after_output | ( | diagnostic_t | diag_kind | ) |
Take any action which is expected to happen after the diagnostic is written out. This function does not always return.
References bt_callback(), bt_err_callback(), count, FATAL_EXIT_CODE, finish(), fnotice(), gcc_unreachable, ggc_alloc(), ICE_EXIT_CODE, m_abort_on_error, m_fatal_errors, m_ice_handler_cb, m_report_bug, NULL, and real_abort().
Referenced by diagnostic_action_after_output().
void diagnostic_context::begin_group | ( | ) |
class diagnostic_context.
Referenced by auto_diagnostic_group::auto_diagnostic_group().
Check if we've met the maximum error limit, and if so fatally exit with a message. FLUSH indicates whether a diagnostic_context::finish call is needed.
References count, FATAL_EXIT_CODE, finish(), fnotice(), ggc_alloc(), m_diagnostic_count, and m_max_errors.
Referenced by diagnostic_check_max_errors().
|
inline |
References diagnostic_option_classifier::classify_diagnostic(), ggc_alloc(), and m_option_classifier.
Referenced by diagnostic_classify_diagnostic().
void diagnostic_context::color_init | ( | int | value | ) |
Maybe initialize the color support. We require clients to do this explicitly, since most clients don't want color. When called without a VALUE, it initializes with DIAGNOSTICS_COLOR_DEFAULT.
References colorize_init(), DIAGNOSTICS_COLOR_AUTO, ggc_alloc(), pp_show_color, and printer.
Referenced by diagnostic_color_init().
int diagnostic_context::converted_column | ( | expanded_location | s | ) | const |
Given an expanded_location, convert the column (which is in 1-based bytes) to the requested units and origin. Return -1 if the column is invalid (<= 0).
References convert_column_unit(), get_file_cache(), ggc_alloc(), m_column_origin, m_column_unit, and m_tabstop.
Referenced by get_location_text(), json_from_expanded_location(), and report_current_module().
void diagnostic_context::create_edit_context | ( | ) |
References gcc_assert, m_edit_context_ptr, and m_file_cache.
Referenced by process_options().
|
inline |
References m_diagnostic_count.
|
private |
Returns whether a DIAGNOSTIC should be printed, and adjusts diagnostic->kind as appropriate for #pragma GCC diagnostic and -Werror=foo.
References DK_ANY, ggc_alloc(), option_unspecified_p(), and permissive_error_option.
void diagnostic_context::emit_diagram | ( | const diagnostic_diagram & | diagram | ) |
Emit DIAGRAM to this context, respecting the output format.
References gcc_assert, and ggc_alloc().
void diagnostic_context::end_group | ( | ) |
Referenced by auto_diagnostic_group::~auto_diagnostic_group().
|
private |
Inform the user that an error occurred while trying to report some other error. This indicates catastrophic internal inconsistencies, so give up now. But do try to flush out the previous error. This mustn't use internal_error, that will cause infinite recursion.
References diagnostic_action_after_output(), fnotice(), ggc_alloc(), pp_newline_and_flush(), and real_abort().
void diagnostic_context::finish | ( | ) |
Do any cleaning up required after the last diagnostic is emitted.
References diagnostic_option_classifier::fini(), ggc_alloc(), m_client_data_hooks, m_diagrams, m_edit_context_ptr, m_file_cache, m_includes_seen, m_option_classifier, m_output_format, m_urlifier, printer, and pretty_printer::~pretty_printer().
Referenced by action_after_output(), check_max_errors(), and diagnostic_finish().
|
private |
Update the inlining info in this context for a DIAGNOSTIC.
References diagnostic_location(), ggc_alloc(), and in_system_header_at().
|
inline |
|
inline |
References m_diagrams.
|
inline |
References m_edit_context_ptr.
Referenced by toplev::main().
|
inline |
References m_escape_format.
|
inline |
|
inline |
References m_option_callbacks.
Referenced by init_asm_output(), and make_option_url().
label_text diagnostic_context::get_location_text | ( | const expanded_location & | s | ) | const |
Return a string describing a location e.g. "foo.c:42:10".
References build_message_string(), colorize_start(), colorize_stop(), converted_column(), ggc_alloc(), m_show_column, maybe_line_and_column(), pp_show_color, printer, progname, and special_fname_builtin().
Referenced by default_diagnostic_start_span_fn(), and diagnostic_build_prefix().
|
inline |
References m_output_format.
Referenced by fnotice().
|
inline |
References m_path_format.
Referenced by default_tree_diagnostic_path_printer().
|
private |
Only dump the "In file included from..." stack once for each file.
References hash_set< KeyId, Lazy, Traits >::add(), ggc_alloc(), line_table, m_includes_seen, and map.
Referenced by report_current_module().
void diagnostic_context::initialize | ( | int | n_opts | ) |
Initialize the diagnostic message outputting machinery.
References diagnostic_source_printing_options::caret_chars, diagnostic_source_printing_options::colorize_source_p, default_diagnostic_finalizer(), default_diagnostic_start_span_fn(), default_diagnostic_starter(), diagnostic_set_caret_max_width(), DIAGNOSTICS_COLUMN_UNIT_DISPLAY, DIAGNOSTICS_ESCAPE_FORMAT_UNICODE, DIAGNOSTICS_TEXT_ART_CHARSET_ASCII, DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI, DPF_NONE, diagnostic_source_printing_options::enabled, EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1, EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2, EXTRA_DIAGNOSTIC_OUTPUT_none, ggc_alloc(), i, diagnostic_option_classifier::init(), m_abort_on_error, m_client_aux_data, m_client_data_hooks, m_column_origin, m_column_unit, m_diagnostic_count, m_diagnostic_groups, m_diagrams, m_edit_context_ptr, m_escape_format, m_extra_output_kind, m_fatal_errors, m_file_cache, m_ice_handler_cb, m_includes_seen, m_inhibit_notes_p, m_inhibit_warnings, m_internal_error, m_last_location, m_last_module, m_lock, m_max_errors, m_n_opts, m_opt_permissive, m_option_callbacks, m_option_classifier, m_output_format, m_path_format, m_pedantic_errors, m_permissive, m_report_bug, m_set_locations_cb, m_show_column, m_show_cwe, m_show_option_requested, m_show_path_depths, m_show_rules, m_source_printing, m_tabstop, m_text_callbacks, m_urlifier, m_warn_system_headers, m_warning_as_error_requested, diagnostic_source_printing_options::min_margin_width, pp_line_cutoff, printer, set_text_art_charset(), diagnostic_source_printing_options::show_event_links_p, diagnostic_source_printing_options::show_labels_p, diagnostic_source_printing_options::show_line_numbers_p, diagnostic_source_printing_options::show_ruler_p, and UNKNOWN_LOCATION.
Referenced by diagnostic_initialize().
void diagnostic_context::initialize_input_context | ( | diagnostic_input_charset_callback | ccb, |
bool | should_skip_bom ) |
Create the file_cache, if not already created, and tell it how to translate files on input.
References file_cache::initialize_input_context(), and m_file_cache.
Referenced by diagnostic_initialize_input_context().
|
inline |
References ggc_alloc(), and m_option_callbacks.
Referenced by sarif_builder::make_result_object(), and json_output_format::on_end_diagnostic().
|
inline |
References get_lang_mask(), and m_option_callbacks.
Referenced by sarif_builder::make_reporting_descriptor_object_for_warning(), json_output_format::on_end_diagnostic(), and print_lto_docs_link().
void diagnostic_context::maybe_show_locus | ( | const rich_location & | richloc, |
diagnostic_t | diagnostic_kind, | ||
pretty_printer * | pp, | ||
diagnostic_source_effect_info * | effects ) |
As per diagnostic_context::show_locus, but don't print anything if source printing is disabled, or if the location hasn't changed.
References BUILTINS_LOCATION, ggc_alloc(), and NULL.
Referenced by diagnostic_show_locus().
|
inline |
References m_option_callbacks.
Referenced by diagnostic_option_classifier::classify_diagnostic().
|
inline |
References m_option_classifier, and diagnostic_option_classifier::option_unspecified_p().
Referenced by option_unspecified_p().
|
inline |
References m_option_classifier, and diagnostic_option_classifier::pop().
Referenced by diagnostic_pop_diagnostics().
|
private |
If DIAGNOSTIC has a CWE identifier, print it. For example, if the diagnostic metadata associates it with CWE-119, " [CWE-119]" will be printed, suitably colorized, and with a URL of a description of the security issue.
References colorize_start(), colorize_stop(), diagnostic_kind_color, free(), get_cwe_url(), ggc_alloc(), NULL, pp_begin_url(), pp_character(), pp_end_url(), pp_printf(), pp_set_prefix(), pp_show_color, pp_string(), pp_take_prefix(), pretty_printer::url_format, and URL_FORMAT_NONE.
|
private |
If DIAGNOSTIC has any rules associated with it, print them. For example, if the diagnostic metadata associates it with a rule named "STR34-C", then " [STR34-C]" will be printed, suitably colorized, with any URL provided by the rule.
References colorize_start(), colorize_stop(), diagnostic_kind_color, free(), ggc_alloc(), diagnostic_metadata::rule::make_description(), diagnostic_metadata::rule::make_url(), NULL, pp_begin_url(), pp_character(), pp_end_url(), pp_set_prefix(), pp_show_color, pp_string(), pp_take_prefix(), pretty_printer::url_format, and URL_FORMAT_NONE.
|
private |
Print any metadata about the option used to control DIAGNOSTIC to CONTEXT's printer, e.g. " [-Werror=uninitialized]". Subroutine of diagnostic_context::report_diagnostic.
References colorize_start(), colorize_stop(), diagnostic_kind_color, free(), ggc_alloc(), pp_begin_url(), pp_character(), pp_end_url(), pp_show_color, pp_string(), and URL_FORMAT_NONE.
|
inline |
References m_option_classifier, and diagnostic_option_classifier::push().
Referenced by diagnostic_push_diagnostics().
void diagnostic_context::report_current_module | ( | location_t | where | ) |
References _, BUILTINS_LOCATION, converted_column(), ggc_alloc(), includes_seen_p(), line_table, m_last_module, m_show_column, map, maybe_line_and_column(), N_, NULL, pp_needs_newline, pp_newline(), pp_verbatim(), and printer.
Referenced by diagnostic_report_current_module().
bool diagnostic_context::report_diagnostic | ( | diagnostic_info * | diagnostic | ) |
Report a diagnostic message (an error or a warning) as specified by this diagnostic_context. front-end independent format specifiers are exactly those described in the documentation of output_format. Return true if a diagnostic was printed, false otherwise.
References diagnostic_action_after_output(), diagnostic_check_max_errors(), diagnostic_location(), DIAGNOSTICS_COLUMN_UNIT_BYTE, DIAGNOSTICS_COLUMN_UNIT_DISPLAY, expand_location(), EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1, EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2, fnotice(), gcc_assert, ggc_alloc(), ICE_EXIT_CODE, NULL, pedantic_warning_kind, pp_flush(), pp_format(), pp_newline_and_flush(), pp_output_formatted_text(), and print_parseable_fixits().
Referenced by diagnostic_impl(), diagnostic_n_impl(), and diagnostic_report_diagnostic().
void diagnostic_context::set_client_data_hooks | ( | diagnostic_client_data_hooks * | hooks | ) |
References ggc_alloc(), and m_client_data_hooks.
Referenced by tree_diagnostics_defaults().
|
inline |
References m_escape_format.
Referenced by common_handle_option().
|
inline |
References m_extra_output_kind.
Referenced by common_handle_option().
|
inline |
References m_ice_handler_cb.
Referenced by diagnostic_output_format_init_sarif().
|
inline |
References m_max_errors.
Referenced by common_handle_option().
void diagnostic_context::set_option_hooks | ( | diagnostic_option_enabled_cb | option_enabled_cb, |
void * | option_state, | ||
diagnostic_make_option_name_cb | make_option_name_cb, | ||
diagnostic_make_option_url_cb | make_option_url_cb, | ||
unsigned | lang_mask ) |
References ggc_alloc(), and m_option_callbacks.
Referenced by general_init(), and main().
void diagnostic_context::set_output_format | ( | diagnostic_output_format * | output_format | ) |
|
inline |
References m_path_format.
Referenced by common_handle_option(), and general_init().
References m_report_bug.
Referenced by common_handle_option().
|
inline |
References m_set_locations_cb.
Referenced by tree_diagnostics_defaults().
References m_show_cwe.
Referenced by common_handle_option(), diagnostic_output_format_init_json(), diagnostic_output_format_init_sarif(), and general_init().
References m_show_option_requested.
Referenced by common_handle_option(), diagnostic_output_format_init_json(), diagnostic_output_format_init_sarif(), and general_init().
References m_show_path_depths.
Referenced by common_handle_option(), and general_init().
References m_show_rules.
Referenced by common_handle_option(), diagnostic_output_format_init_json(), diagnostic_output_format_init_sarif(), and general_init().
void diagnostic_context::set_text_art_charset | ( | enum diagnostic_text_art_charset | charset | ) |
Initialize this context's m_diagrams based on CHARSET. Specifically, make a text_art::theme object for m_diagrams.m_theme, (or NULL for "no diagrams").
References DIAGNOSTICS_TEXT_ART_CHARSET_ASCII, DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI, DIAGNOSTICS_TEXT_ART_CHARSET_NONE, DIAGNOSTICS_TEXT_ART_CHARSET_UNICODE, gcc_unreachable, and ggc_alloc().
Referenced by common_handle_option(), driver_handle_option(), and initialize().
References m_urlifier.
Referenced by general_init(), and driver::global_initializations().
References m_warning_as_error_requested.
Referenced by common_handle_option().
|
private |
If DIAGNOSTIC has a diagnostic_path and this context supports printing paths, print the path.
References ggc_alloc(), and m_print_path.
|
private |
Print the physical source code corresponding to the location of this diagnostic, with additional annotations. If PP is non-null, then use it rather than this context's printer. If EFFECTS is non-null, then use and update it.
References ggc_alloc().
|
inline |
References m_show_path_depths.
Referenced by default_tree_diagnostic_path_printer().
void diagnostic_context::urls_init | ( | int | value | ) |
Initialize URL support within this context based on VALUE, handling "auto".
References determine_url_format(), DIAGNOSTICS_URL_AUTO, ggc_alloc(), printer, and pretty_printer::url_format.
Referenced by diagnostic_urls_init().
|
inline |
References m_warning_as_error_requested.
Referenced by option_name().
bool diagnostic_context::warning_enabled_at | ( | location_t | loc, |
int | opt ) |
Returns whether warning OPT is enabled at LOC.
References diagnostic_report_warnings_p, ggc_alloc(), and line_table.
Referenced by warning_enabled_at().
|
friend |
Client supplied function called after a diagnostic message is displayed (for text-based diagnostic output).
|
friend |
Client supplied function called between disjoint spans of source code, so that the context can print something to indicate that a new span of source code has begun.
|
friend |
Client supplied function to announce a diagnostic (for text-based diagnostic output).
bool diagnostic_context::m_abort_on_error |
Referenced by action_after_output(), diagnostic_abort_on_error(), and initialize().
diagnostic_starter_fn diagnostic_context::m_begin_diagnostic |
void* diagnostic_context::m_client_aux_data |
Referenced by initialize().
|
private |
Referenced by finish(), get_client_data_hooks(), initialize(), and set_client_data_hooks().
int diagnostic_context::m_column_origin |
Referenced by common_handle_option(), converted_column(), initialize(), and json_output_format::on_end_diagnostic().
enum diagnostics_column_unit diagnostic_context::m_column_unit |
Referenced by common_handle_option(), converted_column(), initialize(), and json_from_expanded_location().
|
private |
Referenced by check_max_errors(), diagnostic_count(), and initialize().
struct { ... } diagnostic_context::m_diagnostic_groups |
Referenced by initialize().
struct { ... } diagnostic_context::m_diagrams |
Referenced by finish(), get_diagram_theme(), and initialize().
|
private |
Referenced by create_edit_context(), finish(), get_edit_context(), and initialize().
int diagnostic_context::m_emission_count |
diagnostic_finalizer_fn diagnostic_context::m_end_diagnostic |
|
private |
Referenced by get_escape_format(), initialize(), and set_escape_format().
|
private |
Referenced by initialize(), and set_extra_output_kind().
bool diagnostic_context::m_fatal_errors |
Referenced by action_after_output(), common_handle_option(), and initialize().
|
private |
Referenced by create_edit_context(), finish(), get_file_cache(), initialize(), and initialize_input_context().
|
private |
Referenced by action_after_output(), initialize(), and set_ice_handler_callback().
|
private |
Referenced by finish(), includes_seen_p(), and initialize().
bool diagnostic_context::m_inhibit_notes_p |
Referenced by diagnostic_append_note(), diagnostic_inhibit_notes(), and initialize().
bool diagnostic_context::m_inhibit_warnings |
Referenced by common_handle_option(), and initialize().
void(* diagnostic_context::m_internal_error) (diagnostic_context *, const char *, va_list *) |
Referenced by general_init(), initialize(), and internal_error_function().
unsigned diagnostic_context::m_lang_mask |
location_t diagnostic_context::m_last_location |
Referenced by initialize().
|
private |
Referenced by initialize(), and report_current_module().
|
private |
Referenced by initialize().
json::value *(* diagnostic_context::m_make_json_for_path) (diagnostic_context *, const diagnostic_path *) |
Referenced by json_output_format::on_end_diagnostic(), and tree_diagnostics_defaults().
diagnostic_make_option_name_cb diagnostic_context::m_make_option_name_cb |
diagnostic_make_option_url_cb diagnostic_context::m_make_option_url_cb |
|
private |
Referenced by check_max_errors(), initialize(), and set_max_errors().
|
private |
Referenced by initialize().
int diagnostic_context::m_nesting_depth |
int diagnostic_context::m_opt_permissive |
Referenced by initialize().
struct { ... } diagnostic_context::m_option_callbacks |
Referenced by get_lang_mask(), initialize(), make_option_name(), make_option_url(), option_enabled_p(), and set_option_hooks().
|
private |
Referenced by classify_diagnostic(), finish(), initialize(), option_unspecified_p(), pop_diagnostics(), and push_diagnostics().
diagnostic_option_enabled_cb diagnostic_context::m_option_enabled_cb |
void* diagnostic_context::m_option_state |
|
private |
Referenced by finish(), get_output_format(), initialize(), and set_output_format().
|
private |
Referenced by get_path_format(), initialize(), and set_path_format().
bool diagnostic_context::m_pedantic_errors |
Referenced by common_handle_option(), and initialize().
bool diagnostic_context::m_permissive |
Referenced by initialize().
void(* diagnostic_context::m_print_path) (diagnostic_context *, const diagnostic_path *) |
|
private |
Referenced by action_after_output(), initialize(), and set_report_bug().
|
private |
Referenced by initialize(), and set_set_locations_callback().
bool diagnostic_context::m_show_column |
Referenced by common_handle_option(), general_init(), get_location_text(), initialize(), lhd_print_error_function(), and report_current_module().
|
private |
Referenced by initialize(), and set_show_cwe().
|
private |
Referenced by initialize(), and set_show_option_requested().
|
private |
Referenced by initialize(), set_show_path_depths(), and show_path_depths_p().
|
private |
Referenced by initialize(), and set_show_rules().
diagnostic_source_printing_options diagnostic_context::m_source_printing |
diagnostic_start_span_fn diagnostic_context::m_start_span |
int diagnostic_context::m_tabstop |
Referenced by common_handle_option(), converted_column(), and initialize().
struct { ... } diagnostic_context::m_text_callbacks |
Referenced by initialize().
text_art::theme* diagnostic_context::m_theme |
|
private |
Referenced by finish(), initialize(), and set_urlifier().
bool diagnostic_context::m_warn_system_headers |
Referenced by common_handle_option(), and initialize().
|
private |
Referenced by initialize(), set_warning_as_error_requested(), and warning_as_error_requested_p().
pretty_printer* diagnostic_context::printer |
Referenced by announce_function(), attr_access::array_as_string(), color_init(), common_handle_option(), decls_mismatched_attributes(), default_diagnostic_finalizer(), default_diagnostic_start_span_fn(), default_diagnostic_starter(), default_tree_diagnostic_path_printer(), default_tree_diagnostic_starter(), diagnostic_append_note(), diagnostic_build_prefix(), diagnostic_output_format_init_json(), diagnostic_output_format_init_sarif(), diagnostic_ready_p(), diagnostic_set_caret_max_width(), escaped_string::escape(), fancy_abort(), file_name_as_prefix(), finish(), get_location_text(), initialize(), lhd_print_error_function(), toplev::main(), sarif_builder::make_message_object_for_diagram(), sarif_builder::make_result_object(), json_output_format::on_end_diagnostic(), sarif_result::on_nested_diagnostic(), print_lto_docs_link(), report_current_module(), sarif_ice_notification::sarif_ice_notification(), urls_init(), and verbatim().