GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "intl.h"
#include "diagnostic.h"
#include "diagnostic-color.h"
#include "diagnostic-url.h"
#include "diagnostic-metadata.h"
#include "diagnostic-path.h"
#include "diagnostic-client-data-hooks.h"
#include "diagnostic-format-sarif.h"
#include "diagnostic-format-text.h"
#include "logical-location.h"
#include "edit-context.h"
#include "make-unique.h"
#include "libgdiagnostics.h"
Data Structures | |
class | owned_nullable_string |
class | content_buffer |
struct | diagnostic_file |
struct | diagnostic_physical_location |
struct | diagnostic_logical_location |
class | sink |
struct | diagnostic_text_sink |
class | sarif_sink |
class | impl_diagnostic_client_data_hooks |
class | impl_client_version_info |
struct | diagnostic_manager |
class | impl_rich_location |
class | impl_range_label |
class | impl_rule |
class | libgdiagnostics_path_event |
class | libgdiagnostics_path_thread |
struct | diagnostic_execution_path |
struct | diagnostic |
Macros | |
#define | INCLUDE_MAP |
#define | INCLUDE_VECTOR |
#define | FAIL_IF_NULL(PTR_ARG) |
#define FAIL_IF_NULL | ( | PTR_ARG | ) |
Error-checking at the API boundary.
Referenced by diagnostic_add_execution_path(), diagnostic_add_fix_it_hint_delete(), diagnostic_add_fix_it_hint_insert_after(), diagnostic_add_fix_it_hint_insert_before(), diagnostic_add_fix_it_hint_replace(), diagnostic_add_location(), diagnostic_add_location_with_label(), diagnostic_add_rule(), diagnostic_begin(), diagnostic_execution_path_add_event(), diagnostic_execution_path_add_event_va(), diagnostic_file_set_buffered_content(), diagnostic_finish(), diagnostic_finish_va(), diagnostic_manager_add_sarif_sink(), diagnostic_manager_add_text_sink(), diagnostic_manager_begin_group(), diagnostic_manager_debug_dump_file(), diagnostic_manager_debug_dump_location(), diagnostic_manager_debug_dump_logical_location(), diagnostic_manager_end_group(), diagnostic_manager_new_execution_path(), diagnostic_manager_new_file(), diagnostic_manager_new_location_from_file_and_line(), diagnostic_manager_new_location_from_file_line_column(), diagnostic_manager_new_location_from_range(), diagnostic_manager_new_logical_location(), diagnostic_manager_set_full_name(), diagnostic_manager_set_tool_name(), diagnostic_manager_set_version_string(), diagnostic_manager_set_version_url(), diagnostic_manager_write_patch(), diagnostic_set_cwe(), diagnostic_set_location(), diagnostic_set_logical_location(), diagnostic_take_execution_path(), diagnostic_text_sink_set_colorize(), diagnostic_text_sink_set_labelled_source_colorization_enabled(), diagnostic_text_sink_set_source_printing_enabled(), and sarif_replay_path().
#define INCLUDE_MAP |
C++ implementation of a pure C API for emitting diagnostics. Copyright (C) 2023-2024 Free Software Foundation, Inc. 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/>.
#define INCLUDE_VECTOR |
|
static |
Referenced by diagnostic_execution_path_add_event(), and diagnostic_execution_path_add_event_va().
|
static |
References diagnostic_physical_location::m_inner, and UNKNOWN_LOCATION.
Referenced by diagnostic::add_location(), diagnostic::add_location_with_label(), diagnostic_add_fix_it_hint_delete(), diagnostic_add_fix_it_hint_insert_after(), diagnostic_add_fix_it_hint_insert_before(), diagnostic_add_fix_it_hint_replace(), diagnostic_manager_debug_dump_location(), libgdiagnostics_path_event::get_location(), diagnostic_manager::new_location_from_range(), and diagnostic::set_location().
diagnostic_execution_path * diagnostic_add_execution_path | ( | diagnostic * | diag | ) |
Public entrypoint.
References diagnostic::add_execution_path(), and FAIL_IF_NULL.
void diagnostic_add_fix_it_hint_delete | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc ) |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, diagnostic::get_manager(), diagnostic::get_rich_location(), and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::diagnostic::add_fix_it_hint_delete().
void diagnostic_add_fix_it_hint_insert_after | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc, | ||
const char * | addition ) |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, diagnostic::get_manager(), diagnostic::get_rich_location(), and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::diagnostic::add_fix_it_hint_insert_after().
void diagnostic_add_fix_it_hint_insert_before | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc, | ||
const char * | addition ) |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, diagnostic::get_manager(), diagnostic::get_rich_location(), and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::diagnostic::add_fix_it_hint_insert_before().
void diagnostic_add_fix_it_hint_replace | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc, | ||
const char * | replacement ) |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, diagnostic::get_manager(), diagnostic::get_rich_location(), and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::diagnostic::add_fix_it_hint_replace().
void diagnostic_add_location | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc ) |
Public entrypoint.
References diagnostic::add_location(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, and diagnostic::get_manager().
void diagnostic_add_location_with_label | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc, | ||
const char * | text ) |
Public entrypoint.
References diagnostic::add_location_with_label(), diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, and diagnostic::get_manager().
Referenced by libgdiagnostics::diagnostic::add_location_with_label().
void diagnostic_add_rule | ( | diagnostic * | diag, |
const char * | title, | ||
const char * | url ) |
Public entrypoint.
References diagnostic::add_rule(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::diagnostic::add_rule().
diagnostic * diagnostic_begin | ( | diagnostic_manager * | diag_mgr, |
enum diagnostic_level | level ) |
Public entrypoint.
References FAIL_IF_NULL.
Referenced by libgdiagnostics::manager::begin_diagnostic().
diagnostic_event_id diagnostic_execution_path_add_event | ( | diagnostic_execution_path * | path, |
const diagnostic_physical_location * | physical_loc, | ||
const diagnostic_logical_location * | logical_loc, | ||
unsigned | stack_depth, | ||
const char * | gmsgid, | ||
... ) |
Public entrypoint.
References as_diagnostic_event_id(), and FAIL_IF_NULL.
diagnostic_event_id diagnostic_execution_path_add_event_va | ( | diagnostic_execution_path * | path, |
const diagnostic_physical_location * | physical_loc, | ||
const diagnostic_logical_location * | logical_loc, | ||
unsigned | stack_depth, | ||
const char * | gmsgid, | ||
va_list * | args ) |
Public entrypoint.
References as_diagnostic_event_id(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::execution_path::add_event_va().
void diagnostic_execution_path_release | ( | diagnostic_execution_path * | path | ) |
Public entrypoint.
References path.
Referenced by libgdiagnostics::execution_path::~execution_path().
void diagnostic_file_set_buffered_content | ( | diagnostic_file * | file, |
const char * | buf, | ||
size_t | sz ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_file::set_buffered_content().
Referenced by libgdiagnostics::file::set_buffered_content().
void diagnostic_finish | ( | diagnostic * | diag, |
const char * | gmsgid, | ||
... ) |
Public entrypoint.
References diagnostic_finish_va(), and FAIL_IF_NULL.
Referenced by diagnostic_manager_debug_dump_location().
void diagnostic_finish_va | ( | diagnostic * | diag, |
const char * | gmsgid, | ||
va_list * | args ) |
Public entrypoint.
References diagnostic_manager::emit(), FAIL_IF_NULL, diagnostic_manager::get_client_version_info(), diagnostic::get_manager(), progname, and tool_name.
Referenced by diagnostic_finish(), libgdiagnostics::diagnostic::finish(), and libgdiagnostics::diagnostic::finish_va().
void diagnostic_manager_add_sarif_sink | ( | diagnostic_manager * | diag_mgr, |
FILE * | dst_stream, | ||
const diagnostic_file * | main_input_file, | ||
enum diagnostic_sarif_version | version ) |
Public entrypoint.
References abort, diagnostic_manager::add_sink(), DIAGNOSTIC_SARIF_VERSION_2_1_0, DIAGNOSTIC_SARIF_VERSION_2_2_PRERELEASE, FAIL_IF_NULL, make_unique(), v2_1_0, and v2_2_prerelease_2024_08_08.
Referenced by libgdiagnostics::manager::add_sarif_sink().
diagnostic_text_sink * diagnostic_manager_add_text_sink | ( | diagnostic_manager * | diag_mgr, |
FILE * | dst_stream, | ||
enum diagnostic_colorize | colorize ) |
Public entrypoint.
References diagnostic_manager::add_sink(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::manager::add_text_sink().
void diagnostic_manager_begin_group | ( | diagnostic_manager * | diag_mgr | ) |
Public entrypoint.
References diagnostic_manager::begin_group(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::group::group().
void diagnostic_manager_debug_dump_file | ( | diagnostic_manager * | diag_mgr, |
const diagnostic_file * | file, | ||
FILE * | out ) |
Write a representation of FILE to OUT, for debugging.
References FAIL_IF_NULL, diagnostic_file::get_content(), diagnostic_file::get_name(), and diagnostic_file::get_sarif_source_language().
void diagnostic_manager_debug_dump_location | ( | const diagnostic_manager * | diag_mgr, |
const diagnostic_physical_location * | loc, | ||
FILE * | out ) |
Public entrypoint.
References as_location_t(), diagnostic_finish(), diagnostic_initialize(), expand_location(), FAIL_IF_NULL, diagnostic_text_output_format::get_location_text(), diagnostic_context::m_show_column, and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::manager::debug_dump().
void diagnostic_manager_debug_dump_logical_location | ( | const diagnostic_manager * | diag_mgr, |
const diagnostic_logical_location * | loc, | ||
FILE * | out ) |
Write a representation of LOC to OUT, for debugging.
References DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION, DIAGNOSTIC_LOGICAL_LOCATION_KIND_MEMBER, DIAGNOSTIC_LOGICAL_LOCATION_KIND_MODULE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_NAMESPACE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_PARAMETER, DIAGNOSTIC_LOGICAL_LOCATION_KIND_RETURN_TYPE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_TYPE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_VARIABLE, diagnostic_manager_debug_dump_logical_location(), FAIL_IF_NULL, gcc_unreachable, diagnostic_logical_location::get_external_kind(), diagnostic_logical_location::get_internal_name(), diagnostic_logical_location::get_name_with_scope(), diagnostic_logical_location::get_parent(), and diagnostic_logical_location::get_short_name().
Referenced by libgdiagnostics::manager::debug_dump(), and diagnostic_manager_debug_dump_logical_location().
|
extern |
Public entrypoint.
References diagnostic_manager::end_group(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::group::~group().
diagnostic_manager * diagnostic_manager_new | ( | void | ) |
Public entrypoints.
Public entrypoint for clients to acquire a diagnostic_manager.
diagnostic_execution_path * diagnostic_manager_new_execution_path | ( | diagnostic_manager * | manager | ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_execution_path().
Referenced by libgdiagnostics::manager::new_execution_path().
diagnostic_file * diagnostic_manager_new_file | ( | diagnostic_manager * | diag_mgr, |
const char * | name, | ||
const char * | sarif_source_language ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_file().
Referenced by libgdiagnostics::manager::new_file().
const diagnostic_physical_location * diagnostic_manager_new_location_from_file_and_line | ( | diagnostic_manager * | diag_mgr, |
const diagnostic_file * | file, | ||
diagnostic_line_num_t | linenum ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_location_from_file_and_line().
Referenced by libgdiagnostics::manager::new_location_from_file_and_line().
const diagnostic_physical_location * diagnostic_manager_new_location_from_file_line_column | ( | diagnostic_manager * | diag_mgr, |
const diagnostic_file * | file, | ||
diagnostic_line_num_t | line_num, | ||
diagnostic_column_num_t | column_num ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_location_from_file_line_column().
Referenced by libgdiagnostics::manager::new_location_from_file_line_column().
const diagnostic_physical_location * diagnostic_manager_new_location_from_range | ( | diagnostic_manager * | diag_mgr, |
const diagnostic_physical_location * | loc_caret, | ||
const diagnostic_physical_location * | loc_start, | ||
const diagnostic_physical_location * | loc_end ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_location_from_range().
Referenced by libgdiagnostics::manager::new_location_from_range().
const diagnostic_logical_location * diagnostic_manager_new_logical_location | ( | diagnostic_manager * | diag_mgr, |
enum diagnostic_logical_location_kind_t | kind, | ||
const diagnostic_logical_location * | parent, | ||
const char * | short_name, | ||
const char * | fully_qualified_name, | ||
const char * | decorated_name ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::new_logical_location().
Referenced by libgdiagnostics::manager::new_logical_location().
void diagnostic_manager_release | ( | diagnostic_manager * | diag_mgr | ) |
Public entrypoint for clients to release a diagnostic_manager.
Referenced by libgdiagnostics::manager::~manager().
void diagnostic_manager_set_full_name | ( | diagnostic_manager * | diag_mgr, |
const char * | value ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by libgdiagnostics::manager::set_full_name().
void diagnostic_manager_set_tool_name | ( | diagnostic_manager * | diag_mgr, |
const char * | value ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by libgdiagnostics::manager::set_tool_name().
void diagnostic_manager_set_version_string | ( | diagnostic_manager * | diag_mgr, |
const char * | value ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by libgdiagnostics::manager::set_version_string().
void diagnostic_manager_set_version_url | ( | diagnostic_manager * | diag_mgr, |
const char * | value ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by libgdiagnostics::manager::set_version_url().
void diagnostic_manager_write_patch | ( | diagnostic_manager * | diag_mgr, |
FILE * | dst_stream ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_manager::write_patch().
Referenced by libgdiagnostics::manager::write_patch().
void diagnostic_set_cwe | ( | diagnostic * | diag, |
unsigned | cwe_id ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic::set_cwe().
Referenced by libgdiagnostics::diagnostic::set_cwe().
void diagnostic_set_location | ( | diagnostic * | diag, |
const diagnostic_physical_location * | loc ) |
Public entrypoint.
References diagnostic_manager::assert_valid_diagnostic_physical_location(), FAIL_IF_NULL, diagnostic::get_manager(), and diagnostic::set_location().
Referenced by libgdiagnostics::diagnostic::set_location().
void diagnostic_set_logical_location | ( | diagnostic * | diag, |
const diagnostic_logical_location * | logical_loc ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic::set_logical_location().
Referenced by libgdiagnostics::diagnostic::set_logical_location().
|
static |
References DIAGNOSTIC_LEVEL_ERROR, DIAGNOSTIC_LEVEL_NOTE, DIAGNOSTIC_LEVEL_SORRY, DIAGNOSTIC_LEVEL_WARNING, and gcc_unreachable.
Referenced by diagnostic_manager::emit().
|
extern |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic::take_execution_path().
Referenced by libgdiagnostics::diagnostic::take_execution_path().
void diagnostic_text_sink_set_colorize | ( | diagnostic_text_sink * | text_sink, |
enum diagnostic_colorize | colorize ) |
Public entrypoint.
References FAIL_IF_NULL, and diagnostic_text_sink::set_colorize().
Referenced by libgdiagnostics::text_sink::set_colorize().
void diagnostic_text_sink_set_labelled_source_colorization_enabled | ( | diagnostic_text_sink * | text_sink, |
int | value ) |
Public entrypoint.
References diagnostic_source_printing_options::colorize_source_p, FAIL_IF_NULL, and diagnostic_text_sink::get_source_printing_options().
Referenced by libgdiagnostics::text_sink::set_labelled_source_colorization_enabled().
void diagnostic_text_sink_set_source_printing_enabled | ( | diagnostic_text_sink * | text_sink, |
int | value ) |
Public entrypoint.
References diagnostic_source_printing_options::enabled, FAIL_IF_NULL, and diagnostic_text_sink::get_source_printing_options().
Referenced by libgdiagnostics::text_sink::set_source_printing_enabled().
|
static |
Helper for the linemap code.