]> git.ipfire.org Git - thirdparty/gcc.git/commit
SARIF output: fix diagnostics within C++ member fns [PR122626]
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 17 Nov 2025 19:08:59 +0000 (14:08 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 17 Nov 2025 19:08:59 +0000 (14:08 -0500)
commite55195c4f2f809419c25b9d7c2ffdcc017f010a4
treee10243a94c9493dd76ffbb88c8ba63c9586416b3
parent5ce13174c0cf8271f37ca72d1bfc5560b35448dc
SARIF output: fix diagnostics within C++ member fns [PR122626]

When building hierarchical logical locations, we were stopping traveral
upwards before any TRANSLATION_UNIT_DECL for decls, but not for types,
leading to an assertion failure when producing SARIF output for
diagnostics within C++ member fns.

Fixed thusly.

gcc/testsuite/ChangeLog:
PR analyzer/122626
* g++.dg/analyzer/malloc.C: Add sarif output to verify the fix for
PR analyzer/122626.

gcc/ChangeLog:
PR analyzer/122626
* tree-logical-location.cc
(tree_logical_location_manager::get_parent): Return null when
TYPE_CONTEXT is a TRANSLATION_UNIT_DECL so that we don't fail
the assertion in assert_valid_tree.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/testsuite/g++.dg/analyzer/malloc.C
gcc/tree-logical-location.cc