GCC Middle and Back End API Reference
|
#include <text-sink.h>
Static Public Member Functions | |
static const char * | maybe_line_and_column (int line, int col) |
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, enum kind orig_diag_kind) |
bool | includes_seen_p (const line_map_ordinary *map) |
Protected Attributes | |
output_buffer * | m_saved_output_buffer |
column_policy | m_column_policy |
const line_map_ordinary * | m_last_module |
hash_set< location_t, false, location_hash > * | m_includes_seen |
source_printing_options & | m_source_printing |
bool | m_follows_reference_printer |
bool | m_show_nesting |
bool | m_show_locations_in_nesting |
bool | m_show_nesting_levels |
context & | m_context |
std::unique_ptr< pretty_printer > | m_printer |
Subclass of diagnostics::sink for classic text-based output to stderr. Uses diagnostics::context.m_text_callbacks to provide client-specific textual output (e.g. include paths, macro expansions, etc).
|
inline |
diagnostics::text_sink::~text_sink | ( | ) |
class diagnostics::text_sink : public diagnostics::sink.
References _, diagnostics::get_printer(), diagnostics::sink::m_context, m_includes_seen, pp_newline_and_flush(), pp_verbatim(), and progname.
|
overridevirtual |
Implements diagnostics::sink.
References path, and print_path().
void diagnostics::text_sink::append_note | ( | location_t | location, |
const char * | gmsgid, | ||
... ) |
Add a purely textual note with text GMSGID and with LOCATION.
References ap, build_prefix(), diagnostic_set_info(), diagnostic_show_locus(), diagnostics::sink::get_context(), diagnostics::get_printer(), get_source_printing_options(), line_table, diagnostics::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 diagnostics::maybe_unwind_expanded_macro_loc().
char * diagnostics::text_sink::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 diagnostics::get_bullet_point_unichar(), diagnostics::sink::get_context(), i, m_show_nesting, m_show_nesting_levels, pp_formatted_text(), pp_printf(), pp_space, pp_string(), and pp_unicode_character().
Referenced by build_prefix(), and on_report_diagnostic().
char * diagnostics::text_sink::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_indent_prefix(), build_message_string(), colorize_start(), colorize_stop(), diagnostic_expand_location(), free(), gcc_assert, diagnostics::get_color_for_kind(), diagnostics::sink::get_context(), get_location_text(), diagnostics::get_printer(), diagnostics::get_text_for_kind(), diagnostics::last_diagnostic_kind, m_show_nesting, and pp_show_color().
Referenced by append_note(), diagnostics::default_text_starter(), default_tree_diagnostic_text_starter(), and diagnostic_text_sink::text_starter().
|
inlineinherited |
References DEBUG_FUNCTION, and dump().
Referenced by diagnostics::html_sink::dump(), diagnostics::sarif_sink::dump(), dump(), and diagnostics::text_sink::dump().
|
overridevirtual |
Reimplemented from diagnostics::sink.
References DIAGNOSTICS_DUMPING_EMIT_BOOL_FIELD, diagnostics::sink::dump(), diagnostics::dumping::emit_heading(), diagnostics::dumping::emit_none(), m_follows_reference_printer, m_saved_output_buffer, m_show_locations_in_nesting, m_show_nesting, and m_show_nesting_levels.
|
inlineoverridevirtual |
Implements diagnostics::sink.
|
inlinefinaloverridevirtual |
Reimplemented from diagnostics::sink.
References final(), and text_sink().
char * diagnostics::text_sink::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(), diagnostics::get_printer(), and pp_show_color().
Referenced by lhd_print_error_function().
|
finaloverridevirtual |
Implements diagnostics::sink.
References m_follows_reference_printer.
|
inline |
References m_column_policy.
Referenced by report_current_module().
|
inlineinherited |
References m_context.
Referenced by diagnostics::text_sink::append_note(), diagnostics::text_sink::build_indent_prefix(), diagnostics::text_sink::build_prefix(), diagnostics::default_text_finalizer(), diagnostics::text_sink::get_location_text(), lhd_print_error_function(), diagnostics::text_sink::on_report_diagnostic(), diagnostics::text_sink::print_path(), diagnostics::text_sink::show_column_p(), and diagnostics::text_sink::update_printer().
|
inlineinherited |
References m_context.
location_print_policy diagnostics::text_sink::get_location_print_policy | ( | ) | const |
label_text diagnostics::text_sink::get_location_text | ( | const expanded_location & | s | ) | const |
|
inlineinherited |
|
inlineinherited |
References m_printer.
Referenced by diagnostics::default_text_finalizer(), diagnostics::default_text_starter(), default_tree_diagnostic_text_starter(), diagnostics::text_sink::get_location_text(), diagnostics::html_sink::html_sink(), lhd_print_error_function(), diagnostics::sarif_builder::make_location_object(), diagnostics::text_sink::on_report_verbatim(), diagnostics::sarif_sink::sarif_sink(), diagnostic_text_sink::text_starter(), diagnostics::html_sink::update_printer(), and diagnostics::sarif_sink::update_printer().
|
inline |
References m_source_printing.
Referenced by append_note(), diagnostics::default_text_finalizer(), and text_sink().
|
inline |
References m_source_printing.
|
protected |
Only dump the "In file included from..." stack once for each file.
References line_table, m_includes_seen, and map.
Referenced by report_current_module().
|
inlinefinaloverridevirtual |
Implements diagnostics::sink.
References final().
|
finaloverridevirtual |
Implements diagnostics::sink.
|
static |
Helpers for writing lang-specific starters/finalizers for text output.
Return a formatted line and column ':%line:%column'. Elided if line == 0 or col < 0. (A column of 0 may be valid due to the -fdiagnostics-column-origin option.) The result is a statically allocated buffer.
References gcc_checking_assert.
Referenced by diagnostics::column_policy::get_location_text(), and report_current_module().
|
inlineoverridevirtual |
|
overridevirtual |
Implements diagnostics::sink.
References diagnostics::diagram::get_canvas(), diagnostics::get_printer(), pp_flush(), pp_newline(), pp_set_prefix(), pp_take_prefix(), and text_art::canvas::print_to_pp().
|
inlineoverridevirtual |
Implements diagnostics::sink.
|
overridevirtual |
Implementation of diagnostics::sink::on_report_diagnostic vfunc for GCC's standard textual output.
Implements diagnostics::sink.
References build_indent_prefix(), BUILTINS_LOCATION, diagnostic_expand_location(), diagnostic_location(), DIAGNOSTICS_LOG_SCOPE_PRINTF0, diagnostics::sink::get_context(), get_location_text(), diagnostics::sink::get_logger(), diagnostics::get_printer(), diagnostics::sink::m_context, m_show_locations_in_nesting, m_show_nesting, pp_newline(), pp_output_formatted_text(), pp_printf(), pp_set_prefix(), print_any_cwe(), print_any_rules(), print_option_information(), diagnostics::text_finalizer(), and diagnostics::text_starter().
|
finaloverridevirtual |
Reimplemented from diagnostics::sink.
References diagnostics::sink::get_printer(), 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(), free(), diagnostics::get_color_for_kind(), diagnostics::metadata::get_cwe(), diagnostics::get_cwe_url(), diagnostics::get_printer(), diagnostic::m_metadata, 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().
Referenced by on_report_diagnostic().
|
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(), free(), diagnostics::get_color_for_kind(), diagnostics::metadata::get_num_rules(), diagnostics::get_printer(), diagnostics::metadata::get_rule(), diagnostic::m_metadata, diagnostics::metadata::rule::make_description(), diagnostics::metadata::rule::make_url(), 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().
Referenced by on_report_diagnostic().
|
protected |
Print any metadata about the option used to control DIAGNOSTIC to the context's printer, e.g. " [-Werror=uninitialized]".
References colorize_start(), colorize_stop(), free(), diagnostics::get_color_for_kind(), diagnostics::get_printer(), diagnostics::sink::m_context, pp_begin_url(), pp_character(), pp_end_url(), pp_show_color(), pp_string(), and pretty_printer::supports_urls_p().
Referenced by on_report_diagnostic().
void diagnostics::text_sink::print_path | ( | const paths::path & | path | ) |
Print PATH according to the context's path_format.
References DPF_INLINE_EVENTS, DPF_NONE, DPF_SEPARATE_EVENTS, diagnostics::sink::get_context(), diagnostics::paths::path::get_event(), diagnostics::paths::path::get_logical_location_manager(), diagnostics::get_printer(), i, inform(), m_source_printing, diagnostics::paths::path::num_events(), pp_flush(), pp_set_prefix(), pp_show_color(), and pp_take_prefix().
void diagnostics::text_sink::report_current_module | ( | location_t | where | ) |
References _, BUILTINS_LOCATION, get_column_policy(), diagnostics::get_printer(), includes_seen_p(), line_table, m_last_module, map, maybe_line_and_column(), N_, pp_needs_newline(), pp_newline(), pp_verbatim(), and show_column_p().
Referenced by diagnostics::default_text_starter(), and diagnostic_report_current_function().
|
inlinefinaloverridevirtual |
Implements diagnostics::sink.
References final(), and report_global_digraph().
Referenced by report_global_digraph().
|
finaloverridevirtual |
Implements diagnostics::sink.
References gcc_assert, diagnostics::get_printer(), m_saved_output_buffer, and pp_buffer().
|
inlinevirtualinherited |
Reimplemented in diagnostics::html_sink, and diagnostics::sarif_sink.
Referenced by diagnostics::output_format_init().
|
inline |
References m_show_locations_in_nesting.
|
inline |
References m_show_nesting.
|
inline |
References m_show_nesting_levels.
|
inline |
References diagnostics::sink::get_context(), diagnostics::context::m_show_column, and show_column_p().
Referenced by get_location_text(), report_current_module(), and show_column_p().
|
inline |
References m_show_locations_in_nesting.
|
inline |
References m_show_nesting.
|
overridevirtual |
|
protected |
Referenced by get_column_policy(), and text_sink().
|
protectedinherited |
|
protected |
Referenced by dump(), follows_reference_printer_p(), text_sink(), and update_printer().
|
protected |
Referenced by includes_seen_p(), text_sink(), and ~text_sink().
|
protected |
Referenced by report_current_module(), and text_sink().
|
protectedinherited |
|
protected |
Referenced by dump(), set_buffer(), and text_sink().
|
protected |
Referenced by dump(), on_report_diagnostic(), set_show_locations_in_nesting(), and show_locations_in_nesting_p().
|
protected |
Referenced by build_indent_prefix(), build_prefix(), dump(), on_report_diagnostic(), set_show_nesting(), show_nesting_p(), and text_sink().
|
protected |
Referenced by build_indent_prefix(), dump(), set_show_nesting_levels(), and text_sink().
|
protected |
Referenced by get_source_printing_options(), get_source_printing_options(), print_path(), text_sink(), and update_printer().