|
GCC Middle and Back End API Reference
|
#include <stdarg.h>#include <stdio.h>

Go to the source code of this file.
Macros | |
| #define | LIBGDIAGNOSTICS_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) |
| #define | LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL(ARG_NUM) |
| #define | LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL(ARG_NUM) |
| #define | LIBGDIAGNOSTICS_PARAM_FORMAT_STRING(FMT_KIND, FMT_ARG_NUM, ARGS_ARG_NUM) |
| #define | LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING(FMT_ARG_NUM, ARGS_ARG_NUM) |
| #define | LIBGDIAGNOSTICS_PARAM_PRINTF_FORMAT_STRING(FMT_ARG_NUM, ARGS_ARG_NUM) |
| #define | LIBDIAGNOSTICS_HAVE_LOGICAL_LOCATION_ACCESSORS |
| #define | LIBDIAGNOSTICS_HAVE_diagnostic_manager_add_sink_from_spec |
| #define | LIBDIAGNOSTICS_HAVE_diagnostic_manager_set_analysis_target |
| #define | LIBDIAGNOSTICS_HAVE_diagnostic_message_buffer |
| #define | LIBDIAGNOSTICS_HAVE_diagnostic_manager_set_debug_physical_locations |
Typedefs | |
| typedef struct diagnostic_manager | diagnostic_manager |
| typedef struct diagnostic_text_sink | diagnostic_text_sink |
| typedef struct diagnostic_file | diagnostic_file |
| typedef struct diagnostic_physical_location | diagnostic_physical_location |
| typedef unsigned int | diagnostic_line_num_t |
| typedef unsigned int | diagnostic_column_num_t |
| typedef struct diagnostic_logical_location | diagnostic_logical_location |
| typedef struct diagnostic | diagnostic |
| typedef struct diagnostic_execution_path | diagnostic_execution_path |
| typedef int | diagnostic_event_id |
| typedef struct diagnostic_message_buffer | diagnostic_message_buffer |
| typedef struct diagnostic_graph | diagnostic_graph |
| typedef struct diagnostic_node | diagnostic_node |
| typedef struct diagnostic_edge | diagnostic_edge |
| #define LIBDIAGNOSTICS_HAVE_diagnostic_manager_add_sink_from_spec |
Attempt to parse SPEC as if an argument to GCC's -fdiagnostics-add-output=OUTPUT-SPEC. If successful, add an output sink to AFFECTED_MGR and return zero. Otherwise, emit a diagnostic to CONTROL_MGR and return non-zero. Added in LIBGDIAGNOSTICS_ABI_2.
| #define LIBDIAGNOSTICS_HAVE_diagnostic_manager_set_analysis_target |
Set the main input file of MGR to be FILE. This affects the <title> of generated HTML and the "role" of the artifact in SARIF output (SARIF v2.1.0 section 3.24.6). Added in LIBGDIAGNOSTICS_ABI_2.
| #define LIBDIAGNOSTICS_HAVE_diagnostic_manager_set_debug_physical_locations |
If non-zero, print debugging information to stderr when creating diagnostic_physical_location instances. Added in LIBGDIAGNOSTICS_ABI_5.
| #define LIBDIAGNOSTICS_HAVE_diagnostic_message_buffer |
Message buffers.
| #define LIBDIAGNOSTICS_HAVE_LOGICAL_LOCATION_ACCESSORS |
Accessors for logical locations (added in LIBGDIAGNOSTICS_ABI_1; you can test for their presence using #ifdef LIBDIAGNOSTICS_HAVE_LOGICAL_LOCATION_ACCESSORS
| #define LIBGDIAGNOSTICS_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) |
A pure C API for emitting diagnostics. Copyright (C) 2023-2026 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/>.
This macro simplifies testing whether we are using gcc, and if it is of a particular minimum version. (Both major & minor numbers are significant.) This macro will evaluate to 0 if we are not using gcc at all.
| #define LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL | ( | ARG_NUM | ) |
| #define LIBGDIAGNOSTICS_PARAM_FORMAT_STRING | ( | FMT_KIND, | |
| FMT_ARG_NUM, | |||
| ARGS_ARG_NUM ) |
| #define LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING | ( | FMT_ARG_NUM, | |
| ARGS_ARG_NUM ) |
Referenced by diagnostic_execution_path_add_event(), diagnostic_execution_path_add_event_va(), diagnostic_finish(), and diagnostic_finish_va().
| #define LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL | ( | ARG_NUM | ) |
| #define LIBGDIAGNOSTICS_PARAM_PRINTF_FORMAT_STRING | ( | FMT_ARG_NUM, | |
| ARGS_ARG_NUM ) |
Referenced by diagnostic_message_buffer_append_printf().
| typedef struct diagnostic diagnostic |
A "diagnostic" is an opaque bundle of state for a particular diagnostic that is being constructed in memory. A diagnostic has a primary location and zero or more secondary locations. For example: | a = (foo && bar) | ~~~~~^~~~~~~ This diagnostic has a single diagnostic_location, with the caret at the first "&", and the start/finish at the parentheses. Contrast with: | a = (foo && bar) | ~~~ ^~ ~~~ This diagnostic has three locations - The primary location (at "&&") has its caret and start location at the first "&" and end at the second "&. - The secondary location for "foo" has its start and finish at the "f" and "o" of "foo"; the caret is not flagged for display, but is perhaps at the "f" of "foo". - Similarly, the other secondary location (for "bar") has its start and finish at the "b" and "r" of "bar"; the caret is not flagged for display, but is perhaps at the"b" of "bar".
| typedef unsigned int diagnostic_column_num_t |
| typedef struct diagnostic_edge diagnostic_edge |
| typedef int diagnostic_event_id |
| typedef struct diagnostic_execution_path diagnostic_execution_path |
Types for working with execution paths.
| typedef struct diagnostic_file diagnostic_file |
Types relating to "physical" source locations i.e. locations within specific files expressed via line/column.
Opaque type describing a particular input file.
| typedef struct diagnostic_graph diagnostic_graph |
Directed graphs.
| typedef unsigned int diagnostic_line_num_t |
Types for storing line and column information in text files. Both libgdiagnostics and emacs number source *lines* starting at 1, but they have differing conventions for *columns*. libgdiagnostics uses a 1-based convention for source columns, whereas Emacs's M-x column-number-mode uses a 0-based convention. For example, an error in the initial, left-hand column of source line 3 is reported by libgdiagnostics as: some-file.c:3:1: error: ...etc... On navigating to the location of that error in Emacs (e.g. via "next-error"), the locus is reported in the Mode Line (assuming M-x column-number-mode) as: some-file.c 10% (3, 0) i.e. "3:1:" in libgdiagnostics corresponds to "(3, 0)" in Emacs.
| typedef struct diagnostic_logical_location diagnostic_logical_location |
An opaque type describing a "logical" source location e.g. "within function 'foo'".
| typedef struct diagnostic_manager diagnostic_manager |
An opaque bundle of state for a client of the library. Has zero of more "sinks" to which diagnostics are emitted. Responsibilities: - location-management - caching of source file content - patch generation.
| typedef struct diagnostic_message_buffer diagnostic_message_buffer |
| typedef struct diagnostic_node diagnostic_node |
| typedef struct diagnostic_physical_location diagnostic_physical_location |
Opaque type representing a key into a database of source locations within a diagnostic_manager. Locations are created by various API calls into the diagnostic_manager expressing source code points and ranges. They persist until the diagnostic_manager is released, which cleans them up. NULL means "UNKNOWN", and can be returned by the manager as a fallback when a problem occurs (e.g. too many locations). A diagnostic_location can be a single point within the source code, such as here (at the the '"' at the start of the string literal): | int i = "foo"; | ^ or be a range with a start and finish, and a "caret" location. | a = (foo && bar) | ~~~~~^~~~~~~ where the caret here is at the first "&", and the start and finish are at the parentheses.
| typedef struct diagnostic_text_sink diagnostic_text_sink |
Types relating to diagnostic output sinks.
| enum diagnostic_colorize |
| enum diagnostic_level |
An enum for discriminating between different kinds of logical location for a diagnostic. Roughly corresponds to logicalLocation's "kind" property in SARIF v2.1.0 (section 3.33.7).
|
extern |
Create and borrow a pointer to an execution path for DIAG. The path is automatically cleaned up when DIAG is finished.
Public entrypoint.
References diagnostic::add_execution_path(), diagnostic_add_execution_path(), and FAIL_IF_NULL.
Referenced by diagnostic_add_execution_path(), and diagnostic_set_location_with_label().
|
extern |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_fix_it_hint_delete(), 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(), diagnostic_add_fix_it_hint_delete(), and diagnostic_set_location_with_label().
|
extern |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_fix_it_hint_insert_after(), 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(), diagnostic_add_fix_it_hint_insert_after(), and diagnostic_set_location_with_label().
|
extern |
Fix-it hints.
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_fix_it_hint_insert_before(), 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(), diagnostic_add_fix_it_hint_insert_before(), and diagnostic_set_location_with_label().
|
extern |
Public entrypoint.
References as_location_t(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_fix_it_hint_replace(), 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(), diagnostic_add_fix_it_hint_replace(), and diagnostic_set_location_with_label().
|
extern |
Add a secondary location to DIAG.
Public entrypoint.
References diagnostic::add_location(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_location(), FAIL_IF_NULL, and diagnostic::get_manager().
Referenced by libgdiagnostics::diagnostic::add_location(), diagnostic_add_location(), and diagnostic_set_location_with_label().
|
extern |
Add a secondary location to DIAG, with a label.
Public entrypoint.
References diagnostic::add_location_with_label(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_location_with_label(), FAIL_IF_NULL, and diagnostic::get_manager().
Referenced by libgdiagnostics::diagnostic::add_location_with_label(), diagnostic_add_location_with_label(), and diagnostic_set_location_with_label().
|
extern |
As diagnostic_add_location_with_label but takes ownership of MSG_BUF. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic::add_location_with_label(), diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_add_location_with_label_via_msg_buf(), FAIL_IF_NULL, and diagnostic::get_manager().
Referenced by libgdiagnostics::diagnostic::add_location_with_label(), diagnostic_add_location_with_label_via_msg_buf(), and diagnostic_message_buffer_append_printf().
|
extern |
Associate this diagnostic with a particular rule that has been violated (such as in a coding standard, or within a specification). The rule must have at least one of a title and a URL, but these can be NULL. A diagnostic can be associated with zero or more rules.
Public entrypoint.
References diagnostic::add_rule(), diagnostic_add_rule(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::diagnostic::add_rule(), and diagnostic_add_rule().
|
extern |
Step-by-step creation of a diagnostic.
Public entrypoint.
References diagnostic::diagnostic(), diagnostic_begin(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::manager::begin_diagnostic(), and diagnostic_begin().
|
extern |
Append an event to the end of PATH.
References diagnostic_execution_path_add_event(), LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL, LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING, and LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL.
|
extern |
Append an event to the end of PATH.
References diagnostic_execution_path_add_event_va(), LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL, LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING, and LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL.
|
extern |
As diagnostic_execution_path_add_event but takes ownership of MSG_BUF. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_execution_path::add_event_via_msg_buf(), as_diagnostic_event_id(), diagnostic_execution_path_add_event_via_msg_buf(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::execution_path::add_event_via_msg_buf(), diagnostic_execution_path_add_event_via_msg_buf(), and diagnostic_message_buffer_append_printf().
|
extern |
Release ownership of PATH, which must not have been taken by a diagnostic.
Public entrypoint.
References diagnostic_execution_path_release().
Referenced by diagnostic_execution_path_release(), diagnostic_set_location_with_label(), and libgdiagnostics::execution_path::~execution_path().
|
extern |
Populate the source-quoting cache for FILE, specifying the given buffer as the content of the file (rather than attempting to read the content from the filesystem).
Public entrypoint.
References diagnostic_file_set_buffered_content(), FAIL_IF_NULL, and diagnostic_file::set_buffered_content().
Referenced by diagnostic_file_set_buffered_content(), and libgdiagnostics::file::set_buffered_content().
|
extern |
Emit DIAG to all sinks of its manager, and release DIAG. Use FMT for the message. Note that this uses gcc's pretty-print format, which is *not* printf. TODO: who is responsible for putting FMT through gettext?
References diagnostic_finish(), LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING, and LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL.
|
extern |
As diagnostic_finish, but with a va_list.
References diagnostic_finish_va(), diagnostic_physical_location_get_file(), LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL, LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING, and LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL.
|
extern |
As diagnostic_finish, but takes ownership of MSG_BUF. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_finish_via_msg_buf(), diagnostic_manager::emit_msg_buf(), FAIL_IF_NULL, diagnostic_manager::get_client_version_info(), diagnostic::get_manager(), progname, and tool_name.
Referenced by diagnostic_finish_via_msg_buf(), diagnostic_message_buffer_append_printf(), and libgdiagnostics::diagnostic::finish_via_msg_buf().
|
extern |
Create and add a new edge within GRAPH. If non-null, then EDGE_ID must be unique within edges in GRAPH; if EDGE_ID is null then a unique id of the form "edge0", "edge1", etc will be used automatically. The new edge is owned by GRAPH. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_add_edge(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::graph::add_edge(), and diagnostic_graph_add_edge().
|
extern |
Create and add a new edge within GRAPH. If non-null, then EDGE_ID must be unique within edges in GRAPH; if EDGE_ID is null then a unique id of the form "edge0", "edge1", etc will be used automatically. Takes ownership of LABEL, if non-null. The new edge is owned by GRAPH. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_graph_add_edge_via_msg_buf(), FAIL_IF_NULL, and pretty_print_token_buffer::to_string().
Referenced by libgdiagnostics::graph::add_edge(), diagnostic_graph_add_edge_via_msg_buf(), and diagnostic_message_buffer_append_printf().
|
extern |
Create and add a new node within GRAPH. NODE_ID must be unique within nodes in GRAPH. The new node is owned by GRAPH. PARENT_NODE can be NULL (for a top-level node in the graph), or non-null for a child node. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_add_node(), and FAIL_IF_NULL.
Referenced by diagnostic_graph_add_node().
|
extern |
Get the edge in GRAPH with the given id, or null. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_get_edge_by_id(), and FAIL_IF_NULL.
Referenced by diagnostic_graph_get_edge_by_id(), and libgdiagnostics::graph::get_edge_by_id().
|
extern |
Get the node in GRAPH with the given id, or null. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_get_node_by_id(), and FAIL_IF_NULL.
Referenced by diagnostic_graph_get_node_by_id(), and libgdiagnostics::graph::get_node_by_id().
|
extern |
Release this graph. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_release().
Referenced by diagnostic_graph_release(), and libgdiagnostics::graph::~graph().
|
extern |
Set the description of GRAPH for use in the value of the SARIF "description" property (SARIF v2.1.0 section 3.39.2). Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph_set_description(), and FAIL_IF_NULL.
Referenced by diagnostic_graph_set_description(), and libgdiagnostics::graph::set_description().
|
extern |
Set the description of GRAPH for use in the value of the SARIF "description" property (SARIF v2.1.0 section 3.39.2). Takes ownership of DESC, if non-null. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_graph_set_description_via_msg_buf(), FAIL_IF_NULL, and pretty_print_token_buffer::to_string().
Referenced by diagnostic_graph_set_description_via_msg_buf(), diagnostic_message_buffer_append_printf(), and libgdiagnostics::graph::set_description().
|
extern |
|
extern |
References diagnostic_logical_location_get_fully_qualified_name(), FAIL_IF_NULL, owned_nullable_string::get_str(), and diagnostic_logical_location::m_fully_qualified_name.
Referenced by diagnostic_logical_location_get_fully_qualified_name(), and libgdiagnostics::logical_location::get_fully_qualified_name().
|
extern |
Public entrypoints for accessing logical location data.
References diagnostic_logical_location_get_kind(), FAIL_IF_NULL, and diagnostic_logical_location::m_kind.
Referenced by diagnostic_logical_location_get_kind(), and libgdiagnostics::logical_location::get_kind().
|
extern |
|
extern |
|
extern |
Add a new output sink to DIAG_MGR, which writes SARIF of the given version to DST_STREAM. The output is not written until DIAG_MGR is released. DST_STREAM is borrowed, and must outlive DIAG_MGR. For the result to be a valid SARIF file according to the schema, DIAG_MGR must have had diagnostic_manager_set_tool_name called on it.
Public entrypoint.
References abort, diagnostic_manager::add_sink(), diagnostic_manager_add_sarif_sink(), DIAGNOSTIC_SARIF_VERSION_2_1_0, DIAGNOSTIC_SARIF_VERSION_2_2_PRERELEASE, FAIL_IF_NULL, diagnostics::sarif_generation_options::m_version, diagnostics::v2_1_0, and diagnostics::v2_2_prerelease_2024_08_08.
Referenced by libgdiagnostics::manager::add_sarif_sink(), and diagnostic_manager_add_sarif_sink().
|
extern |
Public entrypoint.
References diagnostics::context::add_sink(), diagnostic_manager_add_sink_from_spec(), FAIL_IF_NULL, and diagnostic_manager::get_dc().
Referenced by libgdiagnostics::manager::add_sink_from_spec(), and diagnostic_manager_add_sink_from_spec().
|
extern |
Destinations for diagnostics.
Add a new output sink to DIAG_MGR, which writes GCC-style diagnostics to DST_STREAM. Return a borrowed pointer to the sink, which is cleaned up when DIAG_MGR is released. DST_STREAM is borrowed, and must outlive DIAG_MGR. The output for each diagnostic is written and flushed as each diagnostic is finished.
Public entrypoint.
References diagnostic_manager::add_sink(), diagnostic_manager_add_text_sink(), diagnostic_text_sink::diagnostic_text_sink(), and FAIL_IF_NULL.
Referenced by libgdiagnostics::manager::add_text_sink(), and diagnostic_manager_add_text_sink().
|
extern |
Diagnostic groups.
Begin a diagnostic group. All diagnostics emitted within DIAG_MGR after the first one will be treated as notes about the initial diagnostic.
Public entrypoint.
References diagnostic_manager::begin_group(), diagnostic_manager_begin_group(), and FAIL_IF_NULL.
Referenced by diagnostic_manager_begin_group(), and libgdiagnostics::group::group().
|
extern |
Write a representation of FILE to OUT, for debugging.
References diagnostic_manager_debug_dump_file(), FAIL_IF_NULL, diagnostic_file::get_content(), diagnostic_file::get_name(), diagnostic_file::get_sarif_source_language(), and HOST_SIZE_T_PRINT_DEC.
Referenced by diagnostic_manager_debug_dump_file().
|
extern |
Write a representation of LOC to OUT, for debugging.
Public entrypoint.
References as_location_t(), diagnostic_finish(), diagnostic_initialize(), diagnostic_manager_debug_dump_location(), expand_location(), FAIL_IF_NULL, diagnostics::text_sink::get_location_text(), diagnostics::context::m_show_column, and diagnostic_manager::set_line_table_global().
Referenced by libgdiagnostics::manager::debug_dump(), and diagnostic_manager_debug_dump_location().
|
extern |
Write a representation of LOC to OUT, for debugging.
References DIAGNOSTIC_LOGICAL_LOCATION_KIND_ARRAY, DIAGNOSTIC_LOGICAL_LOCATION_KIND_ATTRIBUTE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_COMMENT, DIAGNOSTIC_LOGICAL_LOCATION_KIND_DECLARATION, DIAGNOSTIC_LOGICAL_LOCATION_KIND_DTD, DIAGNOSTIC_LOGICAL_LOCATION_KIND_ELEMENT, DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION, DIAGNOSTIC_LOGICAL_LOCATION_KIND_MEMBER, DIAGNOSTIC_LOGICAL_LOCATION_KIND_MODULE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_NAMESPACE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_OBJECT, DIAGNOSTIC_LOGICAL_LOCATION_KIND_PARAMETER, DIAGNOSTIC_LOGICAL_LOCATION_KIND_PROCESSING_INSTRUCTION, DIAGNOSTIC_LOGICAL_LOCATION_KIND_PROPERTY, DIAGNOSTIC_LOGICAL_LOCATION_KIND_RETURN_TYPE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_TEXT, DIAGNOSTIC_LOGICAL_LOCATION_KIND_TYPE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_VALUE, DIAGNOSTIC_LOGICAL_LOCATION_KIND_VARIABLE, diagnostic_manager_debug_dump_logical_location(), FAIL_IF_NULL, gcc_unreachable, owned_nullable_string::get_str(), diagnostic_logical_location::m_decorated_name, diagnostic_logical_location::m_fully_qualified_name, diagnostic_logical_location::m_kind, diagnostic_logical_location::m_parent, and diagnostic_logical_location::m_short_name.
Referenced by libgdiagnostics::manager::debug_dump(), and diagnostic_manager_debug_dump_logical_location().
|
extern |
Finish a diagnostic group.
Public entrypoint.
References diagnostic_manager_end_group(), diagnostic_manager::end_group(), and FAIL_IF_NULL.
Referenced by diagnostic_manager_end_group(), and libgdiagnostics::group::~group().
|
extern |
Create a new diagnostic_manager. The client needs to call diagnostic_release_manager on it at some point. Note that no output sinks are created by default.
Public entrypoints.
Public entrypoint for clients to acquire a diagnostic_manager.
References diagnostic_manager::diagnostic_manager(), and diagnostic_manager_new().
Referenced by diagnostic_manager_new(), and libgdiagnostics::manager::manager().
|
extern |
Create a new execution path. This is owned by the called and must have either diagnostic_take_execution_path or diagnostic_execution_path_release called on it.
Public entrypoint.
References diagnostic_manager_new_execution_path(), FAIL_IF_NULL, and diagnostic_manager::new_execution_path().
Referenced by diagnostic_manager_new_execution_path(), diagnostic_set_location_with_label(), and libgdiagnostics::manager::new_execution_path().
|
extern |
Location management.
Create a new diagnostic_file * for file NAME. Repeated calls with matching NAMEs will return the same object. If SARIF_SOURCE_LANGUAGE is non-NULL, it specifies a "sourceLanguage" value for the file when use when writing SARIF. See SARIF v2.1.0 Appendix J for suggested values for various programming languages.
Public entrypoint.
References diagnostic_manager_new_file(), FAIL_IF_NULL, and diagnostic_manager::new_file().
Referenced by diagnostic_manager_new_file(), and libgdiagnostics::manager::new_file().
|
extern |
Create a new graph. This is owned by the caller and must have one of diagnostic_manager_take_global_graph, diagnostic_take_graph, or diagnostic_graph_release called on it. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_graph::diagnostic_graph(), diagnostic_manager_new_graph(), and FAIL_IF_NULL.
Referenced by diagnostic_manager_new_graph().
|
extern |
Attempt to create a diagnostic_location representing FILENAME:LINE_NUM, with no column information (thus "the whole line").
Public entrypoint.
References diagnostic_manager_new_location_from_file_and_line(), FAIL_IF_NULL, and diagnostic_manager::new_location_from_file_and_line().
Referenced by diagnostic_manager_new_location_from_file_and_line(), and libgdiagnostics::manager::new_location_from_file_and_line().
|
extern |
Attempt to create a diagnostic_physical_location representing FILENAME:LINE_NUM:COLUMN_NUM.
Public entrypoint.
References diagnostic_manager_new_location_from_file_line_column(), FAIL_IF_NULL, and diagnostic_manager::new_location_from_file_line_column().
Referenced by diagnostic_manager_new_location_from_file_line_column(), and libgdiagnostics::manager::new_location_from_file_line_column().
|
extern |
Attempt to create a diagnostic_physical_location representing a
range within a source file, with a highlighted "caret" location.
All must be within the same file, but they can be on different lines.
For example, consider the location of the binary expression below:
...|__________1111111112222222
...|12345678901234567890123456
...|
521|int sum (int foo, int bar)
522|{
523| return foo + bar;
...| ~~~~^~~~~
524|}
The location's caret is at the "+", line 523 column 15, but starts
earlier, at the "f" of "foo" at column 11. The finish is at the "r"
of "bar" at column 19. Public entrypoint.
References diagnostic_manager_new_location_from_range(), FAIL_IF_NULL, and diagnostic_manager::new_location_from_range().
Referenced by diagnostic_manager_new_location_from_range(), and libgdiagnostics::manager::new_location_from_range().
|
extern |
A bundle of state describing a logical location in the user's source, such as "in function 'foo'". SHORT_NAME can be NULL, or else a string suitable for use by the SARIF logicalLocation "name" property (SARIF v2.1.0 section 3.33.4). FULLY_QUALIFIED_NAME can be NULL or else a string suitable for use by the SARIF logicalLocation "fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). DECORATED_NAME can be NULL or else a string suitable for use by the SARIF logicalLocation "decoratedName" property (SARIF v2.1.0 section 3.33.6).
Public entrypoint.
References diagnostic_manager_new_logical_location(), FAIL_IF_NULL, and diagnostic_manager::new_logical_location().
Referenced by diagnostic_manager_new_logical_location(), and libgdiagnostics::manager::new_logical_location().
|
extern |
Release a diagnostic_manager. This will flush output to all of the output sinks, and clean up.
Public entrypoint for clients to release a diagnostic_manager.
References diagnostic_manager_release().
Referenced by diagnostic_manager_release(), and libgdiagnostics::manager::~manager().
|
extern |
Public entrypoint.
References diagnostic_manager_set_analysis_target(), FAIL_IF_NULL, diagnostic_manager::get_dc(), diagnostic_file::get_name(), and diagnostics::context::set_main_input_filename().
Referenced by diagnostic_manager_set_analysis_target(), and libgdiagnostics::manager::set_analysis_target().
|
extern |
Public entrypoint.
References diagnostic_manager_set_debug_physical_locations(), FAIL_IF_NULL, and diagnostic_manager::set_debug_physical_locations().
Referenced by diagnostic_manager_set_debug_physical_locations(), and libgdiagnostics::manager::set_debug_physical_locations().
|
extern |
Set a string suitable for use as the value of the SARIF "fullName" property (SARIF v2.1.0 section 3.19.9).
Public entrypoint.
References diagnostic_manager_set_full_name(), FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by diagnostic_manager_set_full_name(), and libgdiagnostics::manager::set_full_name().
|
extern |
Optional metadata about the manager.
Set a string suitable for use as the value of the SARIF "name" property (SARIF v2.1.0 section 3.19.8).
Public entrypoint.
References diagnostic_manager_set_tool_name(), FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by diagnostic_manager_set_tool_name(), and libgdiagnostics::manager::set_tool_name().
|
extern |
Set a string suitable for use as the value of the SARIF "version" property (SARIF v2.1.0 section 3.19.13).
Public entrypoint.
References diagnostic_manager_set_version_string(), FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by diagnostic_manager_set_version_string(), and libgdiagnostics::manager::set_version_string().
|
extern |
Set a string suitable for use as the value of the SARIF "informationUri" property (SARIF v2.1.0 section 3.19.17).
Public entrypoint.
References diagnostic_manager_set_version_url(), FAIL_IF_NULL, and diagnostic_manager::get_client_version_info().
Referenced by diagnostic_manager_set_version_url(), and libgdiagnostics::manager::set_version_url().
|
extern |
Report this graph "globally", taking ownership of it. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_manager_take_global_graph(), FAIL_IF_NULL, and diagnostic_manager::take_global_graph().
Referenced by diagnostic_manager_take_global_graph(), and libgdiagnostics::manager::take_global_graph().
|
extern |
Write a patch to DST_STREAM consisting of all fix-it hints on all diagnostics that have been finished on DIAG_MGR.
Public entrypoint.
References diagnostic_manager_write_patch(), FAIL_IF_NULL, and diagnostic_manager::write_patch().
Referenced by diagnostic_manager_write_patch(), and libgdiagnostics::manager::write_patch().
|
extern |
Append a byte to to the buffer. This should be either ASCII, or part of UTF-8 encoded text. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_append_byte(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back_byte().
Referenced by diagnostic_message_buffer_append_byte(), and libgdiagnostics::message_buffer::operator+=().
|
extern |
Append a diagnostic_event_id to the buffer in the form "(1)". Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_append_event_id(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_event_id(), and diagnostic_message_buffer_append_printf().
|
extern |
Append a formatted string to the buffer, using the formatting rules for "printf". The string is assumed to be UTF-8 encoded. Added in LIBGDIAGNOSTICS_ABI_4.
References diagnostic_add_location_with_label_via_msg_buf(), diagnostic_execution_path_add_event_via_msg_buf(), diagnostic_finish_via_msg_buf(), diagnostic_graph_add_edge_via_msg_buf(), diagnostic_graph_set_description_via_msg_buf(), diagnostic_message_buffer_append_event_id(), diagnostic_message_buffer_append_printf(), diagnostic_message_buffer_begin_color(), diagnostic_message_buffer_begin_quote(), diagnostic_message_buffer_begin_url(), diagnostic_message_buffer_dump(), diagnostic_message_buffer_end_color(), diagnostic_message_buffer_end_quote(), diagnostic_message_buffer_end_url(), diagnostic_node_set_label_via_msg_buf(), LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL, LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL, and LIBGDIAGNOSTICS_PARAM_PRINTF_FORMAT_STRING.
|
extern |
Append a UTF-8 encoded null-terminated string to the buffer. Added in LIBGDIAGNOSTICS_ABI_4.
References diagnostic_message_buffer_append_str(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back_text().
Referenced by diagnostic_message_buffer_append_str(), and libgdiagnostics::message_buffer::operator+=().
|
extern |
Append a UTF-8 encoded run of bytes to the buffer. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_append_text(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back_text().
Referenced by diagnostic_message_buffer_append_text().
|
extern |
Begin a run of text to be printed with color. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_begin_color(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_begin_color().
|
extern |
Begin a run of text to be printed in quotes. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_begin_quote(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_begin_quote().
|
extern |
Begin a run of text associated with the given URL. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_begin_url(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by libgdiagnostics::message_buffer::begin_url(), diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_begin_url().
|
extern |
Write a debugging representation of MSG_BUG to OUTF. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_dump(), pp_token_list::dump(), FAIL_IF_NULL, and pretty_print_token_buffer::m_tokens.
Referenced by diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_dump().
|
extern |
End a run of text started with diagnostic_message_buffer_begin_color. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_end_color(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_end_color().
|
extern |
End a run of text started with diagnostic_message_buffer_begin_quote. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_end_quote(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_printf(), and diagnostic_message_buffer_end_quote().
|
extern |
End a run of text started with diagnostic_message_buffer_begin_url. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_end_url(), FAIL_IF_NULL, pretty_print_token_buffer::m_tokens, and pp_token_list::push_back().
Referenced by diagnostic_message_buffer_append_printf(), diagnostic_message_buffer_end_url(), and libgdiagnostics::message_buffer::end_url().
|
extern |
Create a new diagnostic_message_buffer. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer::diagnostic_message_buffer(), and diagnostic_message_buffer_new().
Referenced by diagnostic_message_buffer_new().
|
extern |
Release a diagnostic_message_buffer that hasn't been used. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_message_buffer_release(), and FAIL_IF_NULL.
Referenced by diagnostic_message_buffer_release(), libgdiagnostics::message_buffer::operator=(), and libgdiagnostics::message_buffer::~message_buffer().
|
extern |
Set the label of NODE for use in the value of the SARIF "label" property (SARIF v2.1.0 section 3.40.3). Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_node_set_label(), and FAIL_IF_NULL.
Referenced by diagnostic_node_set_label(), and libgdiagnostics::node::set_label().
|
extern |
Set the label of NODE for use in the value of the SARIF "label" property (SARIF v2.1.0 section 3.40.3). Takes ownership of LABEL, if non-null. Added in LIBGDIAGNOSTICS_ABI_4.
Public entrypoint.
References diagnostic_node_set_label_via_msg_buf(), FAIL_IF_NULL, and pretty_print_token_buffer::to_string().
Referenced by diagnostic_message_buffer_append_printf(), diagnostic_node_set_label_via_msg_buf(), and libgdiagnostics::node::set_label().
|
extern |
Set the physical location of NODE. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_node_set_location(), FAIL_IF_NULL, diagnostic_physical_location::m_inner, and UNKNOWN_LOCATION.
Referenced by diagnostic_node_set_location(), and libgdiagnostics::node::set_location().
|
extern |
Set the logical location of NODE. Added in LIBGDIAGNOSTICS_ABI_3.
Public entrypoint.
References diagnostic_node_set_logical_location(), FAIL_IF_NULL, and impl_logical_location_manager::key_from_ptr().
Referenced by diagnostic_node_set_logical_location(), and libgdiagnostics::node::set_logical_location().
|
extern |
Get the diagnostic_file associated with PHYSICAL_LOC.
Public entrypoint.
References diagnostic_physical_location_get_file(), and diagnostic_physical_location::get_file().
Referenced by diagnostic_finish_va(), diagnostic_physical_location_get_file(), and libgdiagnostics::physical_location::get_file().
|
extern |
Associate this diagnostic with the given ID within the Common Weakness Enumeration.
Public entrypoint.
References diagnostic_set_cwe(), FAIL_IF_NULL, and diagnostic::set_cwe().
Referenced by diagnostic_set_cwe(), and libgdiagnostics::diagnostic::set_cwe().
|
extern |
Set the primary location of DIAG.
Public entrypoint.
References diagnostic_manager::assert_valid_diagnostic_physical_location(), diagnostic_set_location(), FAIL_IF_NULL, diagnostic::get_manager(), and diagnostic::set_location().
Referenced by diagnostic_set_location(), and libgdiagnostics::diagnostic::set_location().
|
extern |
Set the primary location of DIAG, with a label.
References 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_execution_path_release(), diagnostic_manager_new_execution_path(), diagnostic_set_location_with_label(), diagnostic_set_logical_location(), diagnostic_take_execution_path(), LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL, and LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL.
Referenced by diagnostic_set_location_with_label().
|
extern |
Set the logical location of DIAG.
Public entrypoint.
References diagnostic_set_logical_location(), FAIL_IF_NULL, and diagnostic::set_logical_location().
Referenced by diagnostic_set_location_with_label(), diagnostic_set_logical_location(), and libgdiagnostics::diagnostic::set_logical_location().
|
extern |
Set DIAG to use PATH as its execution path, taking ownership of PATH.
Public entrypoint.
References diagnostic_take_execution_path(), FAIL_IF_NULL, and diagnostic::take_execution_path().
Referenced by diagnostic_set_location_with_label(), diagnostic_take_execution_path(), and libgdiagnostics::diagnostic::take_execution_path().
|
extern |
Add this graph to DIAG, transferring ownership to it. Added in LIBGDIAGNOSTICS_ABI_3.
References diagnostic_take_graph(), FAIL_IF_NULL, and diagnostic::take_graph().
Referenced by diagnostic_take_graph(), and libgdiagnostics::diagnostic::take_graph().
|
extern |
Update colorization of text sink.
Public entrypoint.
References diagnostic_text_sink_set_colorize(), FAIL_IF_NULL, and diagnostic_text_sink::set_colorize().
Referenced by diagnostic_text_sink_set_colorize(), and libgdiagnostics::text_sink::set_colorize().
|
extern |
Enable/disable colorization of the characters of source text that are underlined. This should be true for clients that generate range information (so that the ranges of code are colorized), and false for clients that merely specify points within the source code (to avoid e.g. colorizing just the first character in a token, which would look strange). Default: enabled.
Public entrypoint.
References diagnostics::source_printing_options::colorize_source_p, diagnostic_text_sink_set_labelled_source_colorization_enabled(), FAIL_IF_NULL, and diagnostic_text_sink::get_source_printing_options().
Referenced by diagnostic_text_sink_set_labelled_source_colorization_enabled(), and libgdiagnostics::text_sink::set_labelled_source_colorization_enabled().
|
extern |
Functions to manipulate text sinks.
Enable/disable printing of source text in the text sink. Default: enabled.
Public entrypoint.
References diagnostic_text_sink_set_source_printing_enabled(), diagnostics::source_printing_options::enabled, FAIL_IF_NULL, and diagnostic_text_sink::get_source_printing_options().
Referenced by diagnostic_text_sink_set_source_printing_enabled(), and libgdiagnostics::text_sink::set_source_printing_enabled().