]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: add event kinds for special control flow [PR122544]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 4 Nov 2025 02:42:59 +0000 (21:42 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 4 Nov 2025 02:42:59 +0000 (21:42 -0500)
commit0a2c4b6dd2019d144df49227fce950e10ae62b09
tree25ce7d32abbc93550946629bf48775b0145b9431
parentdf2c1f7c6ba30d4fdb0b06661dbcb764538d5aff
analyzer: add event kinds for special control flow [PR122544]

The SARIF 3.38.8 "kinds" property has some verbs for expressing
control flow, but is missing some of the awkward special cases.

The spec says "If none of these values are appropriate, a SARIF
producer MAY use any value."

This patch adds the following new values:

* "throw" for throwing an exception
* "catch" for catching an exception
* "unwind" for unwinding stack frame(s) during exception-handling
* "setjmp" for calls to setjmp
* "longjmp" for calls to longjmp that rewind the program counter/stack
to the location of a previous setjmp call

gcc/analyzer/ChangeLog:
PR analyzer/122544
* checker-event.cc (catch_cfg_edge_event::get_meaning): New.
(setjmp_event::get_meaning): New.
(rewind_event::get_meaning): New.
(throw_event::get_meaning): New.
(unwind_event::get_meaning): New.
* checker-event.h (catch_cfg_edge_event::get_meaning): New decl.
(setjmp_event::get_meaning): New decl.
(rewind_event::get_meaning): New decl.
(throw_event::get_meaning): New decl.
(unwind_event::get_meaning): New decl.

gcc/ChangeLog:
PR analyzer/122544
* diagnostics/paths.cc (event::meaning::maybe_get_verb_str):
Handle the new verbs.
* diagnostics/paths.h (event::meaning::verb): Add new values
for special control flow operations.
(event::meaning::meaning): Add ctor taking just a verb.

gcc/testsuite/ChangeLog:
PR analyzer/122544
* g++.dg/analyzer/exception-path-1-sarif.py: New test script.
* g++.dg/analyzer/exception-path-1.C: Add SARIF output, and use
the above to check it.
* g++.dg/analyzer/exception-path-unwind-multiple-2-sarif.py: New
test script.
* g++.dg/analyzer/exception-path-unwind-multiple-2.C: Add SARIF
output, and use the above to check it.
* gcc.dg/analyzer/setjmp-3-sarif.py: New test script.
* gcc.dg/analyzer/setjmp-3.c: Add SARIF output, and use
the above to check it.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/checker-event.cc
gcc/analyzer/checker-event.h
gcc/diagnostics/paths.cc
gcc/diagnostics/paths.h
gcc/testsuite/g++.dg/analyzer/exception-path-1-sarif.py [new file with mode: 0644]
gcc/testsuite/g++.dg/analyzer/exception-path-1.C
gcc/testsuite/g++.dg/analyzer/exception-path-unwind-multiple-2-sarif.py [new file with mode: 0644]
gcc/testsuite/g++.dg/analyzer/exception-path-unwind-multiple-2.C
gcc/testsuite/gcc.dg/analyzer/setjmp-3-sarif.py [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/setjmp-3.c