]> git.ipfire.org Git - thirdparty/gcc.git/commit
libgdiagnostics: consolidate logical locations
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 16 Dec 2024 16:22:50 +0000 (11:22 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 16 Dec 2024 16:22:50 +0000 (11:22 -0500)
commit2af541920787e333a25b6524e6b94200f128ba13
tree6ed751d6904c93d9628b6d14ff0131ef1fb67bd1
parent778336e0e4f25745f76a127801dc3bab5e9c1334
libgdiagnostics: consolidate logical locations

This patch updates diagnostic_manager_new_logical_location so
that repeated calls with the same input values yield the same
instance of diagnostic_logical_location.

Doing so allows the path-printing logic to properly consolidate runs of
events, whereas previously it could treat each event as having a
distinct logical location, and thus require them to be printed
separately; this greatly improves the output of sarif-replay when
displaying execution paths.

gcc/ChangeLog:
* doc/libgdiagnostics/topics/logical-locations.rst
(diagnostic_manager_new_logical_location): Add note about repeated
calls.
* libgdiagnostics.cc: Define INCLUDE_MAP.
(class owned_nullable_string): Add copy ctor and move ctor.
(owned_nullable_string::operator<): New.
(diagnostic_logical_location::operator<): New.
(diagnostic_manager::new_logical_location): Use m_logical_locs to
"uniquify" instances, converting it to a std::map.
(diagnostic_manager::logical_locs_map_t): New typedef.
(diagnostic_manager::t m_logical_locs): Convert from a std::vector
to a std::map.
(diagnostic_execution_path::same_function_p): Update comment.

gcc/testsuite/ChangeLog:
* libgdiagnostics.dg/test-logical-location.c: Include <assert.h>.
Verify that creating a diagnostic_logical_location with equal
values yields the same instance.
* sarif-replay.dg/2.1.0-valid/malloc-vs-local-4.c.sarif: New test.
* sarif-replay.dg/2.1.0-valid/signal-1.c.moved.sarif: Update
expected output to show logical location and for consolidation of
events into runs.
* sarif-replay.dg/2.1.0-valid/signal-1.c.sarif: Likewise.
* sarif-replay.dg/2.1.0-valid/spec-example-4.sarif: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/doc/libgdiagnostics/topics/logical-locations.rst
gcc/libgdiagnostics.cc
gcc/testsuite/libgdiagnostics.dg/test-logical-location.c
gcc/testsuite/sarif-replay.dg/2.1.0-valid/malloc-vs-local-4.c.sarif [new file with mode: 0644]
gcc/testsuite/sarif-replay.dg/2.1.0-valid/signal-1.c.moved.sarif
gcc/testsuite/sarif-replay.dg/2.1.0-valid/signal-1.c.sarif
gcc/testsuite/sarif-replay.dg/2.1.0-valid/spec-example-4.sarif