GCC Middle and Back End API Reference
|
Go to the source code of this file.
Data Structures | |
struct | diagnostic_info |
struct | diagnostic_info::inlining_info |
class | diagnostic_output_format |
class | diagnostic_text_output_format |
class | diagnostic_option_classifier |
struct | diagnostic_option_classifier::diagnostic_classification_change_t |
struct | diagnostic_source_printing_options |
class | diagnostic_context |
Namespaces | |
namespace | text_art |
namespace | json |
Macros | |
#define | diagnostic_context_auxiliary_data(DC) (DC)->m_client_aux_data |
#define | diagnostic_info_auxiliary_data(DI) (DI)->x_data |
#define | diagnostic_format_decoder(DC) ((DC)->printer->format_decoder) |
#define | diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule) |
#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_starter_fn) (diagnostic_context *, const diagnostic_info *) |
typedef void(* | diagnostic_start_span_fn) (diagnostic_context *, expanded_location) |
typedef void(* | diagnostic_finalizer_fn) (diagnostic_context *, const diagnostic_info *, diagnostic_t) |
typedef int(* | diagnostic_option_enabled_cb) (int, unsigned, void *) |
typedef char *(* | diagnostic_make_option_name_cb) (const diagnostic_context *, int, diagnostic_t, diagnostic_t) |
typedef char *(* | diagnostic_make_option_url_cb) (const diagnostic_context *, int, unsigned) |
Variables | |
diagnostic_context * | global_dc |
const int | CARET_LINE_MARGIN = 10 |
Same as pp_format_decoder. Works on 'diagnostic_context *'.
Referenced by tree_diagnostics_defaults().
Same as output_prefixing_rule. Works on 'diagnostic_context *'.
Referenced by common_handle_option().
Returns nonzero if warnings should be emitted.
Referenced by diagnostic_context::warning_enabled_at().
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().
Similarly, but for sorrys.
Referenced by seen_error().
#define warningcount global_dc->diagnostic_count (DK_WARNING) |
Similarly, but for warnings.
Referenced by toplev::main().
Similarly, but for warnings promoted to errors.
Referenced by toplev::main().
typedef void(* diagnostic_finalizer_fn) (diagnostic_context *, const diagnostic_info *, diagnostic_t) |
typedef char *(* diagnostic_make_option_name_cb) (const diagnostic_context *, int, diagnostic_t, diagnostic_t) |
typedef char *(* diagnostic_make_option_url_cb) (const diagnostic_context *, int, unsigned) |
typedef void(* diagnostic_start_span_fn) (diagnostic_context *, expanded_location) |
typedef void(* diagnostic_starter_fn) (diagnostic_context *, const diagnostic_info *) |
Forward declarations.
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 |
Return a malloc'd string containing MSG formatted a la printf. The caller is responsible for freeing the memory.
References ap, ggc_alloc(), and msg.
Referenced by diagnostic_build_prefix(), file_name_as_prefix(), and diagnostic_context::get_location_text().
void default_diagnostic_finalizer | ( | diagnostic_context * | context, |
const diagnostic_info * | diagnostic, | ||
diagnostic_t | ) |
References diagnostic_show_locus(), ggc_alloc(), NULL, pp_flush(), pp_newline(), pp_set_prefix(), pp_take_prefix(), and diagnostic_context::printer.
Referenced by diagnostic_context::initialize(), and tree_diagnostics_defaults().
void default_diagnostic_start_span_fn | ( | diagnostic_context * | context, |
expanded_location | exploc ) |
References diagnostic_context::get_location_text(), ggc_alloc(), pp_newline(), pp_string(), and diagnostic_context::printer.
Referenced by diagnostic_context::initialize().
void default_diagnostic_starter | ( | diagnostic_context * | context, |
const diagnostic_info * | diagnostic ) |
References diagnostic_build_prefix(), diagnostic_location(), diagnostic_report_current_module(), ggc_alloc(), pp_set_prefix(), and diagnostic_context::printer.
Referenced by diagnostic_context::initialize().
|
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 |
References diagnostic_context::action_after_output(), and ggc_alloc().
Referenced by diagnostic_context::error_recursion(), and diagnostic_context::report_diagnostic().
|
extern |
|
extern |
Return a malloc'd string describing a location and the severity of the diagnostic, e.g. "foo.c:42:10: error: ". The caller is responsible for freeing the memory.
References _, build_message_string(), colorize_start(), colorize_stop(), diagnostic_expand_location(), diagnostic_kind_color, diagnostic_kind_text, DK_LAST_DIAGNOSTIC_KIND, gcc_assert, diagnostic_context::get_location_text(), ggc_alloc(), pp_show_color, and diagnostic_context::printer.
Referenced by default_diagnostic_starter(), default_tree_diagnostic_starter(), and diagnostic_append_note().
|
inline |
References diagnostic_context::check_max_errors(), and ggc_alloc().
Referenced by diagnostic_context::report_diagnostic().
|
inline |
Force diagnostics controlled by OPTIDX to be kind KIND.
References diagnostic_context::classify_diagnostic(), and ggc_alloc().
Referenced by control_warning_option(), process_options(), and set_option().
|
inline |
References diagnostic_context::color_init().
Referenced by common_handle_option(), driver_handle_option(), driver::global_initializations(), init_options_once(), main(), and run_gcc().
|
inline |
Expand the location of this diagnostic. Use this function for consistency. Parameter WHICH specifies which location. By default, expand the first one.
References ggc_alloc().
Referenced by diagnostic_build_prefix().
|
inline |
Client supplied function called after a diagnostic message is displayed (for text-based diagnostic output).
Referenced by diagnostic_text_output_format::on_end_diagnostic(), and tree_diagnostics_defaults().
|
inline |
References diagnostic_context::finish().
Referenced by driver::finalize(), toplev::main(), and sarif_ice_handler().
|
extern |
Get a color name for diagnostics of type KIND Result could be NULL.
References diagnostic_kind_color.
|
inline |
References diagnostic_context::m_inhibit_notes_p.
Referenced by process_options().
|
inline |
Diagnostic related functions.
References ggc_alloc(), and diagnostic_context::initialize().
Referenced by general_init(), driver::global_initializations(), main(), main(), and main().
|
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.
References ggc_alloc().
Referenced by default_diagnostic_starter(), diagnostic_report_current_function(), diagnostic_context::get_any_inlining_info(), diagnostic_context::report_diagnostic(), set_inlining_locations(), and virt_loc_aware_diagnostic_finalizer().
|
inline |
Return the number of locations to be printed in DIAGNOSTIC.
References ggc_alloc().
|
extern |
Set the output format for CONTEXT to FORMAT, using BASE_FILE_NAME for file-based output formats.
References base_file_name(), diagnostic_output_format_init_json_file(), diagnostic_output_format_init_json_stderr(), diagnostic_output_format_init_sarif_file(), diagnostic_output_format_init_sarif_stderr(), DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE, DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR, DIAGNOSTICS_OUTPUT_FORMAT_SARIF_FILE, DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR, DIAGNOSTICS_OUTPUT_FORMAT_TEXT, gcc_unreachable, and ggc_alloc().
Referenced by common_handle_option(), and driver_handle_option().
|
extern |
Populate CONTEXT in preparation for JSON output to a file named BASE_FILE_NAME.gcc.json.
References base_file_name(), diagnostic_output_format_init_json(), ggc_alloc(), and diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init().
|
extern |
Populate CONTEXT in preparation for JSON output to stderr.
References diagnostic_output_format_init_json(), ggc_alloc(), and diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init().
|
extern |
Populate CONTEXT in preparation for SARIF output to a file named BASE_FILE_NAME.sarif.
References base_file_name(), diagnostic_output_format_init_sarif(), ggc_alloc(), and diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init().
|
extern |
Populate CONTEXT in preparation for SARIF output to stderr.
References diagnostic_output_format_init_sarif(), ggc_alloc(), and diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init().
|
extern |
Populate CONTEXT in preparation for SARIF output to STREAM.
References diagnostic_output_format_init_sarif(), ggc_alloc(), and diagnostic_context::set_output_format().
|
inline |
Override the option index to be used for reporting a diagnostic.
References ggc_alloc(), and diagnostic_info::option_index.
|
inline |
References diagnostic_context::pop_diagnostics().
|
inline |
References diagnostic_context::push_diagnostics().
|
inline |
Returns whether the diagnostic framework has been intialized already and is ready for use.
References global_dc, and diagnostic_context::printer.
|
inline |
References diagnostic_context::report_current_module().
Referenced by default_diagnostic_starter(), and diagnostic_report_current_function().
|
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 ggc_alloc(), and diagnostic_context::report_diagnostic().
Referenced by diagnostic_for_asm(), 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, ggc_alloc(), 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 get_terminal_width(), ggc_alloc(), INT_MAX, diagnostic_context::m_source_printing, diagnostic_source_printing_options::max_width, pp_buffer, and diagnostic_context::printer.
Referenced by common_handle_option(), and diagnostic_context::initialize().
|
extern |
|
extern |
|
inline |
References gcc_assert, ggc_alloc(), and diagnostic_context::maybe_show_locus().
Referenced by default_diagnostic_finalizer(), and diagnostic_append_note().
|
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 to announce a diagnostic (for text-based diagnostic output).
Referenced by diagnostic_text_output_format::on_begin_diagnostic(), and tree_diagnostics_defaults().
|
inline |
References diagnostic_context::urls_init().
Referenced by common_handle_option(), driver_handle_option(), driver::global_initializations(), init_options_once(), main(), and run_gcc().
|
extern |
Pure text formatting support functions.
Same as diagnostic_build_prefix, but only the source FILE is given.
References build_message_string(), colorize_start(), colorize_stop(), ggc_alloc(), pp_show_color, and diagnostic_context::printer.
Referenced by lhd_print_error_function().
|
extern |
Generate a URL string describing CWE. The caller is responsible for freeing the string.
References ggc_alloc().
Referenced by sarif_builder::make_reporting_descriptor_object_for_cwe_id(), and diagnostic_context::print_any_cwe().
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.
References ggc_alloc(), INT_MAX, and NULL.
Referenced by diagnostic_set_caret_max_width(), and print_specific_help().
|
extern |
Generate a JSON object for LOC.
References diagnostic_context::converted_column(), DIAGNOSTICS_COLUMN_UNIT_BYTE, DIAGNOSTICS_COLUMN_UNIT_DISPLAY, expand_location(), gcc_assert, ggc_alloc(), i, INT_MIN, diagnostic_context::m_column_unit, json::object::set_integer(), and json::object::set_string().
Referenced by default_tree_make_json_for_path(), json_from_fixit_hint(), and json_from_location_range().
|
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, and ggc_alloc().
Referenced by dump_location_info().
|
inline |
References global_dc, and diagnostic_context::option_unspecified_p().
Referenced by diagnostic_context::diagnostic_enabled(), and 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(), gcc_rich_location::add_location_if_nearby(), announce_function(), attr_access::array_as_string(), asm_show_source(), auto_diagnostic_group::auto_diagnostic_group(), decls_mismatched_attributes(), diagnostic_for_asm(), diagnostic_impl(), diagnostic_n_impl(), diagnostic_ready_p(), do_self_spec(), driver_handle_option(), format_string_diagnostic_t::emit_warning_n_va(), escaped_string::escape(), fancy_abort(), driver::finalize(), fnotice(), general_init(), driver::global_initializations(), init_asm_output(), init_options_once(), internal_error_function(), lang_handle_option(), main(), toplev::main(), main(), main(), option_unspecified_p(), print_lto_docs_link(), process_command(), process_options(), run_gcc(), target_handle_option(), verbatim(), warning_enabled_at(), and auto_diagnostic_group::~auto_diagnostic_group().