]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: add sarif properties for bounds checking diagnostics
authorDavid Malcolm <dmalcolm@redhat.com>
Sat, 16 Dec 2023 21:19:36 +0000 (16:19 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Sat, 16 Dec 2023 21:19:36 +0000 (16:19 -0500)
commit7abc7aae564e63173fbaa14805e3dddea7f6a160
treedb2c2763f512ae22a920aecf8ff06c313d765fa5
parent30d9a3a69841b13ac01397cf879a043c39409572
analyzer: add sarif properties for bounds checking diagnostics

As a followup to r14-6057-g12b67d1e13b3cf, add SARIF property bags
for -Wanalyzer-out-of-bounds, to help with debugging these warnings.
This was very helpful with PR analyzer/112792.

gcc/analyzer/ChangeLog:
* analyzer.cc: Include "tree-pretty-print.h" and
"diagnostic-event-id.h".
(tree_to_json): New.
(diagnostic_event_id_to_json): New.
(bit_offset_to_json): New.
(byte_offset_to_json): New.
* analyzer.h (tree_to_json): New decl.
(diagnostic_event_id_to_json): New decl.
(bit_offset_to_json): New decl.
(byte_offset_to_json): New decl.
* bounds-checking.cc: Include "diagnostic-format-sarif.h".
(out_of_bounds::maybe_add_sarif_properties): New.
(concrete_out_of_bounds::maybe_add_sarif_properties): New.
(concrete_past_the_end::maybe_add_sarif_properties): New.
(symbolic_past_the_end::maybe_add_sarif_properties): New.
* region-model.cc (region_to_value_map::to_json): New.
(region_model::to_json): New.
* region-model.h (region_to_value_map::to_json): New decl.
(region_model::to_json): New decl.
* store.cc (bit_range::to_json): New.
(byte_range::to_json): New.
* store.h (bit_range::to_json): New decl.
(byte_range::to_json): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/analyzer.cc
gcc/analyzer/analyzer.h
gcc/analyzer/bounds-checking.cc
gcc/analyzer/region-model.cc
gcc/analyzer/region-model.h
gcc/analyzer/store.cc
gcc/analyzer/store.h