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 "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.def"
Data Structures | |
class | sarif_invocation |
class | sarif_result |
class | sarif_ice_notification |
class | sarif_thread_flow |
class | sarif_builder |
class | sarif_output_format |
class | sarif_stream_output_format |
class | sarif_file_output_format |
Macros | |
#define | INCLUDE_VECTOR |
#define | DEFINE_DIAGNOSTIC_KIND(K, T, C) (T), |
#define | PWD_PROPERTY_NAME ("PWD") |
#define | FILE_PREFIX ("file://") |
#define | SARIF_SCHEMA "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json" |
#define | SARIF_VERSION "2.1.0" |
#define FILE_PREFIX ("file://") |
#define INCLUDE_VECTOR |
SARIF output for diagnostics Copyright (C) 2018-2024 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 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().
#define SARIF_SCHEMA "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json" |
Referenced by sarif_builder::make_top_level_object().
#define SARIF_VERSION "2.1.0" |
Referenced by sarif_builder::make_top_level_object().
|
static |
Populate CONTEXT in preparation for SARIF output (either to stderr, or to a file).
References diagnostic_context::m_print_path, pp_show_color, diagnostic_context::printer, sarif_ice_handler(), diagnostic_context::set_ice_handler_callback(), diagnostic_context::set_show_cwe(), diagnostic_context::set_show_option_requested(), and diagnostic_context::set_show_rules().
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, |
bool | formatted, | ||
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(), ggc_alloc(), and diagnostic_context::set_output_format().
Referenced by diagnostic_output_format_init().
void diagnostic_output_format_init_sarif_stderr | ( | diagnostic_context * | context, |
bool | formatted ) |
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().
void diagnostic_output_format_init_sarif_stream | ( | diagnostic_context * | context, |
bool | formatted, | ||
FILE * | stream ) |
Populate CONTEXT in preparation for SARIF output to STREAM.
References diagnostic_output_format_init_sarif(), ggc_alloc(), and diagnostic_context::set_output_format().
Get the PWD, or NULL, 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, gcc_assert, ggc_alloc(), and NULL.
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 diagnostic_kind_text, gcc_assert, and ggc_alloc().
Referenced by sarif_builder::make_result_object().
json::object * 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 NULL.
References ggc_alloc(), and maybe_get_sarif_kind().
Referenced by sarif_builder::set_any_logical_locs_arr().
|
static |
Attempt to get a string for a logicalLocation's "kind" property (SARIF v2.1.0 section 3.33.7). Return NULL 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, LOGICAL_LOCATION_KIND_VARIABLE, and NULL.
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 NULL if there isn't one.
References ggc_alloc(), and NULL.
Referenced by sarif_builder::make_result_object().
|
static |
Callback for diagnostic_context::ice_handler_cb for when an ICE occurs.
References diagnostic_finish(), fnotice(), and ggc_alloc().
Referenced by diagnostic_output_format_init_sarif().