GCC Middle and Back End API Reference
|
#include "unique-argv.h"
#include "rich-location.h"
#include "pretty-print.h"
#include "diagnostic-core.h"
Go to the source code of this file.
Data Structures | |
struct | diagnostic_info |
struct | diagnostic_info::inlining_info |
class | diagnostic_option_manager |
class | diagnostic_option_classifier |
struct | diagnostic_option_classifier::diagnostic_classification_change_t |
struct | diagnostic_source_printing_options |
class | diagnostic_column_policy |
class | diagnostic_location_print_policy |
class | diagnostic_source_print_policy |
struct | diagnostic_counters |
class | diagnostic_context |
Namespaces | |
namespace | text_art |
Macros | |
#define | diagnostic_context_auxiliary_data(DC) |
#define | diagnostic_info_auxiliary_data(DI) |
#define | errorcount global_dc->diagnostic_count (DK_ERROR) |
#define | warningcount global_dc->diagnostic_count (DK_WARNING) |
#define | werrorcount global_dc->diagnostic_count (DK_WERROR) |
#define | sorrycount global_dc->diagnostic_count (DK_SORRY) |
#define | diagnostic_report_warnings_p(DC, LOC) |
Typedefs | |
typedef void(* | diagnostic_text_starter_fn) (diagnostic_text_output_format &, const diagnostic_info *) |
typedef void(* | diagnostic_start_span_fn) (const diagnostic_location_print_policy &, pretty_printer *, expanded_location) |
typedef void(* | diagnostic_text_finalizer_fn) (diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t) |
Variables | |
diagnostic_context * | global_dc |
const int | CARET_LINE_MARGIN = 10 |
#define diagnostic_context_auxiliary_data | ( | DC | ) |
Extension hooks for client.
#define diagnostic_info_auxiliary_data | ( | DI | ) |
#define diagnostic_report_warnings_p | ( | DC, | |
LOC ) |
Returns nonzero if warnings should be emitted.
Referenced by diagnostic_context::warning_enabled_at().
#define errorcount global_dc->diagnostic_count (DK_ERROR) |
The number of errors that have been issued so far. Ideally, these would take a diagnostic_context as an argument.
Referenced by _fatal_insn(), driver::do_spec_on_infiles(), gimplify_bind_expr(), toplev::main(), driver::maybe_run_linker(), and seen_error().
#define sorrycount global_dc->diagnostic_count (DK_SORRY) |
Similarly, but for sorrys.
Referenced by seen_error().
#define warningcount global_dc->diagnostic_count (DK_WARNING) |
Similarly, but for warnings.
Referenced by toplev::main().
#define werrorcount global_dc->diagnostic_count (DK_WERROR) |
Similarly, but for warnings promoted to errors.
Referenced by toplev::main().
typedef void(* diagnostic_start_span_fn) (const diagnostic_location_print_policy &, pretty_printer *, expanded_location) |
typedef void(* diagnostic_text_finalizer_fn) (diagnostic_text_output_format &, const diagnostic_info *, diagnostic_t) |
typedef void(* diagnostic_text_starter_fn) (diagnostic_text_output_format &, const diagnostic_info *) |
An enum for controlling what units to use for the column number when diagnostics are output, used by the -fdiagnostics-column-unit option. Tabs will be expanded or not according to the value of -ftabstop. The origin (default 1) is controlled by -fdiagnostics-column-origin.
Enumerator | |
---|---|
DIAGNOSTICS_COLUMN_UNIT_DISPLAY | |
DIAGNOSTICS_COLUMN_UNIT_BYTE |
|
extern |
Pure text formatting support functions.
Return a malloc'd string containing MSG formatted a la printf. The caller is responsible for freeing the memory.
Referenced by diagnostic_text_output_format::build_prefix(), diagnostic_text_output_format::file_name_as_prefix(), and diagnostic_column_policy::get_location_text().
void default_diagnostic_start_span_fn | ( | const diagnostic_location_print_policy & | loc_policy, |
pretty_printer * | pp, | ||
expanded_location | exploc ) |
void default_diagnostic_text_finalizer | ( | diagnostic_text_output_format & | text_output, |
const diagnostic_info * | diagnostic, | ||
diagnostic_t | ) |
References diagnostic_show_locus(), diagnostic_output_format::get_context(), diagnostic_output_format::get_printer(), diagnostic_text_output_format::get_source_printing_options(), NULL, pp_flush(), pp_newline(), pp_set_prefix(), and pp_take_prefix().
Referenced by diagnostic_context::initialize(), and tree_diagnostics_defaults().
void void void default_diagnostic_text_starter | ( | diagnostic_text_output_format & | text_output, |
const diagnostic_info * | diagnostic ) |
|
inline |
Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.
References diagnostic_context::m_abort_on_error.
Referenced by setup_core_dumping().
|
inline |
Force diagnostics controlled by OPTIDX to be kind KIND.
References diagnostic_context::classify_diagnostic().
Referenced by control_warning_option(), process_options(), and set_option().
|
inline |
|
inline |
Expand the location of this diagnostic. Use this function for consistency. Parameter WHICH specifies which location. By default, expand the first one.
Referenced by diagnostic_text_output_format::build_prefix(), and diagnostic_text_output_format::on_report_diagnostic().
|
inline |
References diagnostic_context::finish().
Referenced by driver::finalize(), toplev::main(), sarif_builder::make_location_object(), and diagnostic_manager::~diagnostic_manager().
|
extern |
Get a color name for diagnostics of type KIND Result could be NULL.
References diagnostic_kind_color.
Referenced by diagnostic_text_output_format::build_prefix(), diagnostic_text_output_format::print_any_cwe(), diagnostic_text_output_format::print_any_rules(), and diagnostic_text_output_format::print_option_information().
|
inline |
References diagnostic_context::m_inhibit_notes_p.
Referenced by process_options().
|
inline |
Diagnostic related functions.
References diagnostic_context::initialize().
Referenced by diagnostic_manager::diagnostic_manager(), diagnostic_manager_debug_dump_location(), general_init(), driver::global_initializations(), main(), main(), main(), and sarif_builder::make_location_object().
|
inline |
Because we read source files a second time after the frontend did it the first time, we need to know how the frontend handled things like character set conversion and UTF-8 BOM stripping, in order to make everything consistent. This function needs to be called by each frontend that requires non-default behavior, to inform the diagnostics infrastructure how input is to be processed. The default behavior is to do no conversion and not to strip a UTF-8 BOM. The callback should return the input charset to be used to convert the given file's contents to UTF-8, or it should return NULL if no conversion is needed for this file. SHOULD_SKIP_BOM only applies in case no conversion was performed, and if true, it will cause a UTF-8 BOM to be skipped at the beginning of the file. (In case a conversion was performed, the BOM is rather skipped as part of the conversion process.)
References diagnostic_context::initialize_input_context().
|
inline |
Return the location associated to this diagnostic. Parameter WHICH specifies which location. By default, expand the first one.
Referenced by default_diagnostic_text_starter(), diagnostic_report_current_function(), diagnostic_context::get_any_inlining_info(), diagnostic_text_output_format::on_report_diagnostic(), diagnostic_context::report_diagnostic(), set_inlining_locations(), and virt_loc_aware_diagnostic_finalizer().
|
inline |
Return the number of locations to be printed in DIAGNOSTIC.
|
inline |
References diagnostic_context::pop_diagnostics().
|
inline |
References diagnostic_context::push_diagnostics().
|
inline |
Report a diagnostic message (an error or a warning) as specified by DC. This function is *the* subroutine in terms of which front-ends should implement their specific diagnostic handling modules. The 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_context::begin_group(), diagnostic_context::end_group(), and diagnostic_context::report_diagnostic().
Referenced by diagnostic_for_asm(), diagnostic_manager::emit(), and format_string_diagnostic_t::emit_warning_n_va().
|
inline |
Return true if the two locations can be represented within the same caret line. This is used to build a prefix and also to determine whether to print one or two caret lines.
References CARET_LINE_MARGIN, diagnostic_context::m_source_printing, and diagnostic_source_printing_options::max_width.
void diagnostic_set_caret_max_width | ( | diagnostic_context * | context, |
int | value ) |
Set caret_max_width to value.
References diagnostic_context::get_reference_printer(), get_terminal_width(), INT_MAX, diagnostic_context::m_source_printing, output_buffer::m_stream, diagnostic_source_printing_options::max_width, and pp_buffer().
Referenced by common_handle_option(), and diagnostic_context::initialize().
|
extern |
Referenced by diagnostic_context::diagnostic_impl().
|
extern |
Referenced by diagnostic_context::diagnostic_n_impl().
|
inline |
Override the option index to be used for reporting a diagnostic.
References diagnostic_info::option_id.
|
inline |
References gcc_assert, and diagnostic_context::maybe_show_locus().
Referenced by diagnostic_text_output_format::append_note(), and default_diagnostic_text_finalizer().
|
inline |
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.
|
inline |
Client supplied function called after a diagnostic message is displayed (for text-based diagnostic output).
Referenced by diagnostic_text_output_format::on_report_diagnostic(), and tree_diagnostics_defaults().
|
inline |
Client supplied function to announce a diagnostic (for text-based diagnostic output).
Referenced by diagnostic_manager::diagnostic_manager(), diagnostic_text_output_format::on_report_diagnostic(), and tree_diagnostics_defaults().
|
inline |
|
extern |
Generate a URL string describing CWE. The caller is responsible for freeing the string.
Referenced by sarif_builder::make_reporting_descriptor_object_for_cwe_id(), and diagnostic_text_output_format::print_any_cwe().
|
extern |
Get unlocalized string describing KIND.
References diagnostic_kind_text.
Referenced by diagnostic_text_output_format::build_prefix(), diagnostic_counters::dump(), make_rule_id_for_diagnostic_kind(), and json_output_format::on_report_diagnostic().
int get_terminal_width | ( | void | ) |
Return the value of the getenv("COLUMNS") as an integer. If the value is not set to a positive integer, use ioctl to get the terminal width. If it fails, return INT_MAX.
Referenced by diagnostic_set_caret_max_width(), and print_specific_help().
const char * maybe_line_and_column | ( | int | line, |
int | col ) |
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 diagnostic_column_policy::get_location_text(), and diagnostic_text_output_format::report_current_module().
|
extern |
Compute the number of digits in the decimal representation of an integer.
Get the number of digits in the decimal representation of VALUE.
References gcc_assert.
Referenced by dump_location_info().
|
inline |
References global_dc, and diagnostic_context::option_unspecified_p().
Referenced by process_options().
|
inline |
References global_dc, and diagnostic_context::warning_enabled_at().
const int CARET_LINE_MARGIN = 10 |
This is somehow the right-side margin of a caret line, that is, we print at least these many characters after the position pointed at by the caret.
Referenced by diagnostic_same_line().
|
extern |
This diagnostic_context is used by front-ends that directly output diagnostic messages without going through `error', `warning', and similar functions.
Referenced by gcc_rich_location::add_fixit_insert_formatted(), announce_function(), attr_access::array_as_string(), asm_show_source(), auto_diagnostic_group::auto_diagnostic_group(), auto_diagnostic_nesting_level::auto_diagnostic_nesting_level(), auto_override_urlifier::auto_override_urlifier(), diagnostic_for_asm(), do_self_spec(), driver_handle_option(), emit_diagnostic(), emit_diagnostic(), emit_diagnostic_valist(), emit_diagnostic_valist_meta(), format_string_diagnostic_t::emit_warning_n_va(), error(), error_at(), error_at(), error_meta(), error_n(), escaped_string::escape(), fancy_abort(), fatal_error(), driver::finalize(), fnotice(), general_init(), driver::global_initializations(), inform(), inform(), inform_n(), init_asm_output(), init_options_once(), internal_error(), internal_error_function(), internal_error_no_backtrace(), lang_handle_option(), main(), main(), main(), toplev::main(), option_unspecified_p(), pedwarn(), pedwarn(), permerror(), permerror(), permerror_opt(), permerror_opt(), print_lto_docs_link(), process_command(), process_options(), run_gcc(), sorry(), sorry_at(), target_handle_option(), tree_dump_pretty_printer::tree_dump_pretty_printer(), verbatim(), warning(), warning_at(), warning_at(), warning_enabled_at(), warning_meta(), warning_n(), warning_n(), auto_diagnostic_group::~auto_diagnostic_group(), auto_diagnostic_nesting_level::~auto_diagnostic_nesting_level(), and auto_override_urlifier::~auto_override_urlifier().