GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "diagnostic.h"
#include "diagnostic-metadata.h"
#include "diagnostic-path.h"
#include "diagnostic-format.h"
#include "diagnostic-buffer.h"
#include "json.h"
#include "cpplib.h"
#include "logical-location.h"
#include "diagnostic-client-data-hooks.h"
#include "diagnostic-diagram.h"
#include "text-art/canvas.h"
#include "diagnostic-format-sarif.h"
#include "diagnostic-format-text.h"
#include "ordered-hash-map.h"
#include "sbitmap.h"
#include "make-unique.h"
#include "selftest.h"
#include "selftest-diagnostic.h"
#include "selftest-diagnostic-show-locus.h"
#include "selftest-json.h"
#include "text-range-label.h"
#include "pretty-print-format-impl.h"
#include "pretty-print-urlifier.h"
#include "demangle.h"
#include "backtrace.h"
Data Structures | |
class | sarif_artifact_content |
class | sarif_artifact_location |
class | sarif_message |
class | sarif_multiformat_message_string |
class | sarif_log |
class | sarif_run |
class | sarif_tool |
class | sarif_tool_component |
class | sarif_invocation |
class | sarif_artifact |
class | sarif_location_manager |
struct | sarif_location_manager::worklist_item |
class | sarif_result |
class | sarif_location |
class | sarif_physical_location |
class | sarif_region |
class | sarif_location_relationship |
class | sarif_code_flow |
class | sarif_thread_flow |
class | sarif_thread_flow_location |
class | sarif_reporting_descriptor |
class | sarif_reporting_descriptor_reference |
class | sarif_tool_component_reference |
class | sarif_fix |
class | sarif_artifact_change |
class | sarif_replacement |
class | sarif_ice_notification |
class | content_renderer |
class | diagnostic_sarif_format_buffer |
class | sarif_builder |
class | sarif_builder::sarif_token_printer |
struct | bt_closure |
class | sarif_output_format |
class | sarif_stream_output_format |
class | sarif_file_output_format |
Macros | |
#define | INCLUDE_LIST |
#define | INCLUDE_MAP |
#define | INCLUDE_STRING |
#define | INCLUDE_VECTOR |
#define | PWD_PROPERTY_NAME ("PWD") |
#define | FILE_PREFIX ("file://") |
Enumerations | |
enum class | location_relationship_kind { includes , is_included_by , relevant , NUM_KINDS } |
enum class | diagnostic_artifact_role { analysis_target , debug_output_file , result_file , scanned_file , traced_file , NUM_ROLES } |
Functions | |
static std::unique_ptr< json::string > | make_date_time_string_for_current_time () |
static const char * | get_artifact_role_string (enum diagnostic_artifact_role role) |
static const char * | get_string_for_location_relationship_kind (enum location_relationship_kind kind) |
static int | bt_callback (void *data, uintptr_t pc, const char *filename, int lineno, const char *function) |
static const char * | maybe_get_sarif_level (diagnostic_t diag_kind) |
static char * | make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind) |
static char * | make_pwd_uri_str () |
static const char * | maybe_get_sarif_kind (enum logical_location_kind kind) |
std::unique_ptr< sarif_logical_location > | make_sarif_logical_location_object (const logical_location &logical_loc) |
label_text | make_sarif_url_for_event (const sarif_code_flow *code_flow, diagnostic_event_id_t event_id) |
static std::string | escape_braces (const char *text) |
static void | set_string_property_escaping_braces (json::object &obj, const char *property_name, const char *value) |
static const char * | sarif_version_to_url (enum sarif_version version) |
static const char * | sarif_version_to_property (enum sarif_version version) |
static void | sarif_begin_embedded_link (pretty_printer *pp) |
static void | sarif_end_embedded_link (pretty_printer *pp, const char *url) |
static void | diagnostic_output_format_init_sarif (diagnostic_context &context, std::unique_ptr< sarif_output_format > fmt) |
void | diagnostic_output_format_init_sarif_stderr (diagnostic_context &context, const line_maps *line_maps, const char *main_input_filename_, bool formatted, enum sarif_version version) |
diagnostic_output_file | diagnostic_output_format_open_sarif_file (diagnostic_context &context, line_maps *line_maps, const char *base_file_name) |
void | diagnostic_output_format_init_sarif_file (diagnostic_context &context, line_maps *line_maps, const char *main_input_filename_, bool formatted, enum sarif_version version, const char *base_file_name) |
void | diagnostic_output_format_init_sarif_stream (diagnostic_context &context, const line_maps *line_maps, const char *main_input_filename_, bool formatted, enum sarif_version version, FILE *stream) |
std::unique_ptr< diagnostic_output_format > | make_sarif_sink (diagnostic_context &context, const line_maps &line_maps, const char *main_input_filename_, enum sarif_version version, diagnostic_output_file output_file) |
Variables | |
static const char *const | bt_stop [] |
#define FILE_PREFIX ("file://") |
Referenced by make_pwd_uri_str().
#define INCLUDE_LIST |
SARIF output for diagnostics Copyright (C) 2018-2025 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.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/>.
#define INCLUDE_MAP |
#define INCLUDE_STRING |
#define INCLUDE_VECTOR |
#define PWD_PROPERTY_NAME ("PWD") |
The ID value for use in "uriBaseId" properties (SARIF v2.1.0 section 3.4.4) for when we need to express paths relative to PWD.
Referenced by sarif_builder::make_artifact_location_object(), and sarif_builder::make_run_object().
|
strong |
|
strong |
|
static |
A callback function passed to the backtrace_full function.
References json::array::append(), bt_stop, free(), i, bt_closure::m_frames_arr, make_unique(), NULL, and json::array::size().
Referenced by diagnostic_context::action_after_output(), fancy_abort(), and sarif_builder::make_stack_from_backtrace().
|
static |
Populate CONTEXT in preparation for SARIF output (either to stderr, or to a file).
References diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init_sarif_file(), diagnostic_output_format_init_sarif_stderr(), and diagnostic_output_format_init_sarif_stream().
void diagnostic_output_format_init_sarif_file | ( | diagnostic_context & | context, |
line_maps * | line_maps, | ||
const char * | main_input_filename_, | ||
bool | formatted, | ||
enum sarif_version | version, | ||
const char * | base_file_name ) |
Populate CONTEXT in preparation for SARIF output to a file named BASE_FILE_NAME.sarif.
References base_file_name(), diagnostic_output_format_init_sarif(), diagnostic_output_format_open_sarif_file(), gcc_assert, make_unique(), and output_file.
Referenced by diagnostic_output_format_init().
void diagnostic_output_format_init_sarif_stderr | ( | diagnostic_context & | context, |
const line_maps * | line_maps, | ||
const char * | main_input_filename_, | ||
bool | formatted, | ||
enum sarif_version | version ) |
Populate CONTEXT in preparation for SARIF output to stderr.
References diagnostic_output_format_init_sarif(), gcc_assert, and make_unique().
Referenced by diagnostic_output_format_init().
void diagnostic_output_format_init_sarif_stream | ( | diagnostic_context & | context, |
const line_maps * | line_maps, | ||
const char * | main_input_filename_, | ||
bool | formatted, | ||
enum sarif_version | version, | ||
FILE * | stream ) |
Populate CONTEXT in preparation for SARIF output to STREAM.
References diagnostic_output_format_init_sarif(), gcc_assert, and make_unique().
diagnostic_output_file diagnostic_output_format_open_sarif_file | ( | diagnostic_context & | context, |
line_maps * | line_maps, | ||
const char * | base_file_name ) |
Attempt to open BASE_FILE_NAME.sarif for writing. Return a non-null diagnostic_output_file, or return a null diagnostic_output_file and complain to CONTEXT using LINE_MAPS.
References base_file_name(), diagnostic_context::emit_diagnostic_with_group(), fopen, and UNKNOWN_LOCATION.
Referenced by diagnostic_output_format_init_sarif_file(), and gcc::diagnostics_output_spec::sarif_scheme_handler::make_sink().
|
static |
In "3.11.5 Messages with placeholders": "Within both plain text and formatted message strings, the characters "{" and "}" SHALL be represented by the character sequences "{{" and "}}" respectively."
Referenced by set_string_property_escaping_braces().
|
static |
Get a string for ROLE corresponding to the SARIF v2.1.0 section 3.24.6 "roles" property.
References analysis_target, debug_output_file, gcc_unreachable, result_file, scanned_file, and traced_file.
Referenced by sarif_artifact::populate_roles().
|
static |
References gcc_unreachable, includes, is_included_by, and relevant.
Referenced by sarif_location_relationship::lazily_add_kind().
|
static |
Make a JSON string for the current date and time. See SARIF v2.1.0 section 3.9 "Date/time properties". Given that we don't run at the very beginning/end of the process, it doesn't make sense to be more accurate than the current second.
Referenced by sarif_invocation::prepare_to_flush(), and sarif_invocation::sarif_invocation().
|
static |
Get the PWD, or nullptr, as an absolute file-based URI, adding a trailing forward slash (as required by SARIF v2.1.0 section 3.14.14).
References FILE_PREFIX, and gcc_assert.
Referenced by sarif_builder::make_artifact_location_object_for_pwd().
|
static |
Make a string for DIAG_KIND suitable for use a ruleId (SARIF v2.1.0 section 3.27.5) as a fallback for when we don't have anything better to use.
References gcc_assert, and get_diagnostic_kind_text().
Referenced by sarif_builder::make_result_object().
std::unique_ptr< sarif_logical_location > make_sarif_logical_location_object | ( | const logical_location & | logical_loc | ) |
Make a "logicalLocation" object (SARIF v2.1.0 section 3.33) for LOGICAL_LOC, or return nullptr.
References logical_location::get_internal_name(), logical_location::get_kind(), logical_location::get_name_with_scope(), logical_location::get_short_name(), make_unique(), and maybe_get_sarif_kind().
Referenced by sarif_builder::set_any_logical_locs_arr().
std::unique_ptr< diagnostic_output_format > make_sarif_sink | ( | diagnostic_context & | context, |
const line_maps & | line_maps, | ||
const char * | main_input_filename_, | ||
enum sarif_version | version, | ||
diagnostic_output_file | output_file ) |
References make_unique(), and output_file.
Referenced by gcc::diagnostics_output_spec::sarif_scheme_handler::make_sink(), and sarif_sink::sarif_sink().
label_text make_sarif_url_for_event | ( | const sarif_code_flow * | code_flow, |
diagnostic_event_id_t | event_id ) |
References gcc_assert, sarif_code_flow::get_index_within_parent(), sarif_result::get_index_within_parent(), sarif_thread_flow::get_index_within_parent(), sarif_thread_flow_location::get_index_within_parent(), sarif_code_flow::get_parent(), sarif_thread_flow::get_parent(), sarif_thread_flow_location::get_parent(), sarif_code_flow::get_thread_flow_loc_obj(), and diagnostic_event_id_t::known_p().
Referenced by sarif_builder::sarif_token_printer::print_tokens().
|
static |
Attempt to get a string for a logicalLocation's "kind" property (SARIF v2.1.0 section 3.33.7). Return nullptr if unknown.
References gcc_unreachable, LOGICAL_LOCATION_KIND_FUNCTION, LOGICAL_LOCATION_KIND_MEMBER, LOGICAL_LOCATION_KIND_MODULE, LOGICAL_LOCATION_KIND_NAMESPACE, LOGICAL_LOCATION_KIND_PARAMETER, LOGICAL_LOCATION_KIND_RETURN_TYPE, LOGICAL_LOCATION_KIND_TYPE, LOGICAL_LOCATION_KIND_UNKNOWN, and LOGICAL_LOCATION_KIND_VARIABLE.
Referenced by make_sarif_logical_location_object().
|
static |
Attempt to convert DIAG_KIND to a suitable value for the "level" property (SARIF v2.1.0 section 3.27.10). Return nullptr if there isn't one.
Referenced by sarif_builder::make_result_object().
|
static |
Print the start of an embedded link to PP, as per 3.11.6.
References pp_character().
Referenced by sarif_builder::sarif_token_printer::print_tokens().
|
static |
Print the end of an embedded link to PP, as per 3.11.6.
References pp_character(), and pp_string().
Referenced by sarif_builder::sarif_token_printer::print_tokens().
|
static |
Convert VERSION to a value for the "version" property of a "sarifLog" object (SARIF v2.1.0 section 3.13.2).
References gcc_unreachable, v2_1_0, and v2_2_prerelease_2024_08_08.
Referenced by sarif_builder::make_top_level_object().
|
static |
Convert VERSION to a value for the "$schema" property of a "sarifLog" object (SARIF v2.1.0 section 3.13.3).
References gcc_unreachable, v2_1_0, and v2_2_prerelease_2024_08_08.
Referenced by sarif_builder::make_top_level_object().
|
static |
|
static |
Functions at which to stop the backtrace print. It's not particularly helpful to print the callers of these functions.
Referenced by bt_callback(), and bt_callback().