GCC Middle and Back End API Reference
|
#include "rich-location.h"
#include "pretty-print.h"
#include "diagnostic-core.h"
#include "diagnostics/diagnostic-info.h"
#include "diagnostics/context.h"
Go to the source code of this file.
Namespaces | |
namespace | diagnostics |
Macros | |
#define | diagnostic_context_auxiliary_data(DC) |
#define | diagnostic_info_auxiliary_data(DI) |
#define | errorcount global_dc->diagnostic_count (diagnostics::kind::error) |
#define | warningcount global_dc->diagnostic_count (diagnostics::kind::warning) |
#define | werrorcount global_dc->diagnostic_count (diagnostics::kind::werror) |
#define | sorrycount global_dc->diagnostic_count (diagnostics::kind::sorry) |
#define | diagnostic_report_warnings_p(DC, LOC) |
Variables | |
diagnostics::context * | global_dc |
const int | CARET_LINE_MARGIN = 10 |
#define diagnostic_context_auxiliary_data | ( | DC | ) |
Various declarations for language-independent diagnostics subroutines. Copyright (C) 2000-2025 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.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/>.
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 diagnostics::context::warning_enabled_at().
#define errorcount global_dc->diagnostic_count (diagnostics::kind::error) |
The number of errors that have been issued so far. Ideally, these would take a diagnostics::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 (diagnostics::kind::sorry) |
Similarly, but for sorrys.
Referenced by seen_error().
#define warningcount global_dc->diagnostic_count (diagnostics::kind::warning) |
Similarly, but for warnings.
Referenced by toplev::main().
#define werrorcount global_dc->diagnostic_count (diagnostics::kind::werror) |
Similarly, but for warnings promoted to errors.
Referenced by toplev::main().
|
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 diagnostics::text_sink::build_prefix(), diagnostics::text_sink::file_name_as_prefix(), and diagnostics::column_policy::get_location_text().
|
inline |
Force diagnostics controlled by OPTIDX to be kind KIND.
References diagnostics::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 diagnostics::text_sink::build_prefix(), diagnostics::html_builder::make_element_for_diagnostic(), and diagnostics::text_sink::on_report_diagnostic().
|
inline |
|
inline |
Diagnostic related functions.
References diagnostics::context::initialize().
Referenced by diagnostic_manager::diagnostic_manager(), diagnostic_manager_debug_dump_location(), general_init(), driver::global_initializations(), main(), main(), main(), and diagnostics::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 diagnostics::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 diagnostics::default_text_starter(), diagnostic_report_current_function(), diagnostics::context::get_any_inlining_info(), diagnostics::text_sink::on_report_diagnostic(), diagnostics::context::report_diagnostic(), set_inlining_locations(), and diagnostics::virt_loc_aware_text_finalizer().
|
inline |
Return the number of locations to be printed in DIAGNOSTIC.
|
inline |
References diagnostics::context::pop_diagnostics().
|
inline |
References diagnostics::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 diagnostics::context::begin_group(), diagnostics::context::end_group(), and diagnostics::context::report_diagnostic().
Referenced by diagnostic_for_asm(), diagnostic_manager::emit_va(), 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, diagnostics::context::get_source_printing_options(), and diagnostics::source_printing_options::max_width.
|
extern |
|
extern |
|
inline |
Override the option index to be used for reporting a diagnostic.
References diagnostics::diagnostic_info::m_option_id.
|
inline |
References gcc_assert, and diagnostics::context::maybe_show_locus().
Referenced by diagnostics::text_sink::append_note(), and diagnostics::default_text_finalizer().
|
inline |
References gcc_assert, and diagnostics::context::maybe_show_locus_as_html().
|
inline |
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 INT_MAX.
Referenced by print_specific_help(), and diagnostics::context::set_caret_max_width().
|
inline |
References global_dc.
Referenced by process_options().
|
inline |
References global_dc, and warning_enabled_at().
Referenced by 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 diagnostics::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(), text_art::dump_to_file(), 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(), lazy_diagnostic_context_path::make_inner_path(), 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().