GCC Middle and Back End API Reference
|
#include <diagnostic-format-text.h>
Protected Member Functions | |
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) |
bool | includes_seen_p (const line_map_ordinary *map) |
Protected Attributes | |
output_buffer * | m_saved_output_buffer |
diagnostic_column_policy | m_column_policy |
const line_map_ordinary * | m_last_module |
hash_set< location_t, false, location_hash > * | m_includes_seen |
bool | m_follows_reference_printer |
bool | m_show_nesting |
bool | m_show_locations_in_nesting |
bool | m_show_nesting_levels |
diagnostic_context & | m_context |
std::unique_ptr< pretty_printer > | m_printer |
Classic text-based output of diagnostics. Copyright (C) 2023-2024 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com>. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Subclass of diagnostic_output_format for classic text-based output to stderr. Uses diagnostic_context.m_text_callbacks to provide client-specific textual output (e.g. include paths, macro expansions, etc).
|
inline |
diagnostic_text_output_format::~diagnostic_text_output_format | ( | ) |
class diagnostic_text_output_format : public diagnostic_output_format.
References _, pp_newline_and_flush(), pp_verbatim(), and progname.
|
overridevirtual |
Implements diagnostic_output_format.
References print_path().
void diagnostic_text_output_format::append_note | ( | location_t | location, |
const char * | gmsgid, | ||
... ) |
Add a purely textual note with text GMSGID and with LOCATION.
References ap, diagnostic_set_info(), diagnostic_show_locus(), line_table, diagnostic_context::m_inhibit_notes_p, pp_destroy_prefix(), pp_format(), pp_newline(), pp_output_formatted_text(), pp_set_prefix(), and pp_take_prefix().
Referenced by maybe_unwind_expanded_macro_loc().
char * diagnostic_text_output_format::build_indent_prefix | ( | bool | with_bullet | ) | const |
Return a malloc'd string for use as a prefix to show indentation. If m_show_nesting is false, or we're at the top-level, then the result will be the empty string. If m_show_nesting, then the result will contain indentation to show the nesting level, then either a bullet point (if WITH_BULLET is true), or a space. The caller is responsible for freeing the memory.
References get_bullet_point_unichar(), i, pp_formatted_text(), pp_printf(), pp_space, pp_string(), and pp_unicode_character().
char * diagnostic_text_output_format::build_prefix | ( | const diagnostic_info & | diagnostic | ) | const |
Return a malloc'd string describing a location and the severity of the diagnostic, e.g. "foo.c:42:10: error: ". If m_show_nesting, then the above will be preceded by indentation to show the level, and a bullet point. The caller is responsible for freeing the memory.
References _, build_message_string(), colorize_start(), colorize_stop(), diagnostic_expand_location(), diagnostic_get_color_for_kind(), DK_LAST_DIAGNOSTIC_KIND, free(), gcc_assert, get_diagnostic_kind_text(), and pp_show_color().
Referenced by default_diagnostic_text_starter(), default_tree_diagnostic_text_starter(), and diagnostic_text_sink::on_begin_text_diagnostic().
|
inlineinherited |
References diagnostic_output_format::dump().
Referenced by diagnostic_output_format::dump(), dump(), json_output_format::dump(), sarif_file_output_format::dump(), and sarif_output_format::dump().
|
overridevirtual |
Reimplemented from diagnostic_output_format.
References diagnostic_output_format::dump().
char * diagnostic_text_output_format::file_name_as_prefix | ( | const char * | f | ) | const |
Same as build_prefix, but only the source FILE is given.
References build_message_string(), colorize_start(), colorize_stop(), and pp_show_color().
Referenced by lhd_print_error_function().
|
finaloverridevirtual |
Implements diagnostic_output_format.
|
inline |
References m_column_policy.
|
inlineinherited |
|
inlineinherited |
diagnostic_location_print_policy diagnostic_text_output_format::get_location_print_policy | ( | ) | const |
label_text diagnostic_text_output_format::get_location_text | ( | const expanded_location & | s | ) | const |
References diagnostic_column_policy::get_location_text(), and pp_show_color().
Referenced by diagnostic_manager_debug_dump_location().
|
inlineinherited |
References diagnostic_output_format::m_printer.
Referenced by diagnostic_text_format_buffer::clear(), default_diagnostic_text_finalizer(), default_diagnostic_text_starter(), default_tree_diagnostic_text_starter(), diagnostic_text_format_buffer::flush(), lhd_print_error_function(), sarif_builder::make_location_object(), diagnostic_text_sink::on_begin_text_diagnostic(), and sarif_output_format::update_printer().
|
protected |
Only dump the "In file included from..." stack once for each file.
References hash_set< KeyId, Lazy, Traits >::add(), line_table, and map.
|
inlinefinaloverridevirtual |
Implements diagnostic_output_format.
|
finaloverridevirtual |
Implements diagnostic_output_format.
|
inlineoverridevirtual |
Implements diagnostic_output_format.
|
overridevirtual |
Implements diagnostic_output_format.
References diagnostic_diagram::get_canvas(), NULL, pp_flush(), pp_newline(), pp_set_prefix(), and pp_take_prefix().
|
inlineoverridevirtual |
Implements diagnostic_output_format.
|
overridevirtual |
Implementation of diagnostic_output_format::on_report_diagnostic vfunc for GCC's standard textual output.
Implements diagnostic_output_format.
References diagnostic_expand_location(), diagnostic_location(), diagnostic_text_finalizer(), diagnostic_text_starter(), pp_newline(), pp_output_formatted_text(), pp_printf(), and pp_set_prefix().
|
finaloverridevirtual |
Reimplemented from diagnostic_output_format.
References pp_format_verbatim(), and pp_newline_and_flush().
|
protected |
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_get_color_for_kind(), free(), get_cwe_url(), NULL, pp_begin_url(), pp_character(), pp_end_url(), pp_printf(), pp_set_prefix(), pp_show_color(), pp_string(), pp_take_prefix(), and pretty_printer::supports_urls_p().
|
protected |
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_get_color_for_kind(), free(), 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(), and pretty_printer::supports_urls_p().
|
protected |
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_get_color_for_kind(), free(), pp_begin_url(), pp_character(), pp_end_url(), pp_show_color(), pp_string(), and pretty_printer::supports_urls_p().
void diagnostic_text_output_format::print_path | ( | const diagnostic_path & | path | ) |
Print PATH according to the context's path_format.
References DPF_INLINE_EVENTS, DPF_NONE, DPF_SEPARATE_EVENTS, i, inform(), NULL, pp_flush(), pp_set_prefix(), pp_show_color(), and pp_take_prefix().
void diagnostic_text_output_format::report_current_module | ( | location_t | where | ) |
References _, BUILTINS_LOCATION, line_table, map, maybe_line_and_column(), N_, NULL, pp_needs_newline(), pp_newline(), and pp_verbatim().
Referenced by default_diagnostic_text_starter(), and diagnostic_report_current_function().
|
finaloverridevirtual |
Implements diagnostic_output_format.
References gcc_assert, diagnostic_text_format_buffer::m_output_buffer, and pp_buffer().
|
inline |
References m_show_locations_in_nesting.
|
inline |
References m_show_nesting.
|
inline |
References m_show_nesting_levels.
|
inline |
References diagnostic_output_format::get_context(), and diagnostic_context::m_show_column.
|
inline |
References m_show_locations_in_nesting.
|
inline |
References m_show_nesting.
|
overridevirtual |
Implements diagnostic_output_format.
References pretty_printer::get_url_format(), and pp_show_color().
|
protected |
Referenced by get_column_policy().
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
Referenced by set_show_locations_in_nesting(), and show_locations_in_nesting_p().
|
protected |
Referenced by set_show_nesting(), and show_nesting_p().
|
protected |
Referenced by set_show_nesting_levels().