mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 12:00:11 -05:00
In our .sarif output from e.g.:
bad-binary-op.c: In function ‘test_4’:
bad-binary-op.c:19:23: error: invalid operands to binary + (have ‘S’ {aka ‘struct s’} and ‘T’ {aka ‘struct t’})
19 | return callee_4a () + callee_4b ();
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
| | |
| | T {aka struct t}
| S {aka struct s}
the labelled ranges are captured in the 'annotations' property of the
'location' object (§3.28.6).
However sarif-replay emits just:
In function 'test_4':
bad-binary-op.c:19:23: error: invalid operands to binary + (have ‘S’ {aka ‘struct s’} and ‘T’ {aka ‘struct t’}) [error]
19 | return callee_4a () + callee_4b ();
| ^
missing the labelled ranges.
This patch adds support to sarif-replay for the 'annotations' property;
with this patch we emit:
In function 'test_4':
bad-binary-op.c:19:23: error: invalid operands to binary + (have ‘S’ {aka ‘struct s’} and ‘T’ {aka ‘struct t’}) [error]
19 | return callee_4a () + callee_4b ();
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
| | |
| | T {aka struct t}
| S {aka struct s}
thus showing the labelled ranges.
Doing so requires adding a new entrypoint to libgdiagnostics:
diagnostic_physical_location_get_file
Given that we haven't yet released a stable version and that
sarif-replay is built together with libgdiagnostics I didn't
bother updating the ABI version.
gcc/ChangeLog:
PR sarif-replay/118881
* doc/libgdiagnostics/topics/physical-locations.rst: Add
diagnostic_physical_location_get_file.
* libgdiagnostics++.h (physical_location::get_file): New wrapper.
(diagnostic::add_location): Likewise.
* libgdiagnostics.cc (diagnostic_manager::get_file_by_name): New.
(diagnostic_physical_location::get_file): New.
(diagnostic_physical_location_get_file): New.
* libgdiagnostics.h (diagnostic_physical_location_get_file): New.
* libgdiagnostics.map (diagnostic_physical_location_get_file): New.
* libsarifreplay.cc (class annotation): New.
(add_any_annotations): New.
(sarif_replayer::handle_result_obj): Collect vectors of
annotations in the calls to handle_location_object and apply them
to "err" and to "note" as appropriate.
(sarif_replayer::handle_thread_flow_location_object): Pass nullptr
for annotations.
(sarif_replayer::handle_location_object): Handle §3.28.6
"annotations" property, using it to populate a new
"out_annotations" param.
gcc/testsuite/ChangeLog:
PR sarif-replay/118881
* sarif-replay.dg/2.1.0-valid/3.28.6-annotations-1.sarif: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
76 lines
2.6 KiB
Plaintext
76 lines
2.6 KiB
Plaintext
# Linker script for libgdiagnostics.so
|
|
# Copyright (C) 2023-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/>. */
|
|
|
|
# The initial release of the library.
|
|
LIBGDIAGNOSTICS_ABI_0
|
|
{
|
|
global:
|
|
# Keep this list in order of decls in header file.
|
|
diagnostic_manager_new;
|
|
diagnostic_manager_release;
|
|
diagnostic_manager_set_tool_name;
|
|
diagnostic_manager_set_full_name;
|
|
diagnostic_manager_set_version_string;
|
|
diagnostic_manager_set_version_url;
|
|
diagnostic_manager_add_text_sink;
|
|
diagnostic_text_sink_set_source_printing_enabled;
|
|
diagnostic_text_sink_set_colorize;
|
|
diagnostic_text_sink_set_labelled_source_colorization_enabled;
|
|
diagnostic_manager_add_sarif_sink;
|
|
diagnostic_manager_write_patch;
|
|
diagnostic_manager_new_file;
|
|
diagnostic_file_set_buffered_content;
|
|
diagnostic_manager_debug_dump_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_debug_dump_location;
|
|
diagnostic_manager_new_logical_location;
|
|
diagnostic_manager_debug_dump_logical_location;
|
|
diagnostic_manager_begin_group;
|
|
diagnostic_manager_end_group;
|
|
diagnostic_begin;
|
|
diagnostic_set_cwe;
|
|
diagnostic_add_rule;
|
|
diagnostic_set_location;
|
|
diagnostic_set_location_with_label;
|
|
diagnostic_add_location;
|
|
diagnostic_add_location_with_label;
|
|
diagnostic_set_logical_location;
|
|
diagnostic_add_fix_it_hint_insert_before;
|
|
diagnostic_add_fix_it_hint_insert_after;
|
|
diagnostic_add_fix_it_hint_replace;
|
|
diagnostic_add_fix_it_hint_delete;
|
|
|
|
diagnostic_add_execution_path;
|
|
diagnostic_manager_new_execution_path;
|
|
diagnostic_take_execution_path;
|
|
diagnostic_execution_path_release;
|
|
diagnostic_execution_path_add_event;
|
|
diagnostic_execution_path_add_event_va;
|
|
|
|
diagnostic_finish;
|
|
diagnostic_finish_va;
|
|
|
|
diagnostic_physical_location_get_file;
|
|
|
|
local: *;
|
|
};
|