diff options
| author | David Malcolm <dmalcolm@redhat.com> | 2026-02-06 10:54:52 -0500 |
|---|---|---|
| committer | David Malcolm <dmalcolm@redhat.com> | 2026-02-06 10:54:52 -0500 |
| commit | 498fb8a24516b10897dfbe08bb8f7574b2d28839 (patch) | |
| tree | 64cced41f2b14acb983a896668b40bf41c857adc /libjava/gnu/java/net/protocol/https | |
| parent | 87d9a9fd394f3cab1ab4dd62fa30bab806b03ffc (diff) | |
| download | gcc-498fb8a24516b10897dfbe08bb8f7574b2d28839.zip gcc-498fb8a24516b10897dfbe08bb8f7574b2d28839.tar.gz gcc-498fb8a24516b10897dfbe08bb8f7574b2d28839.tar.bz2 | |
analyzer: use value_range and range_op in eval_condition [PR98447]
PR analyzer/98447 covers a false positive from -fanalyzer.
The root cause is that the analyzer's constraint-handling code
doesn't "know" that if X := Y % 64, then X < 64.
This patch adds some minimal usage of value_range and range_op to
-fanalyzer. It adds a new svalue::maybe_get_value_range vfunc, which
attempts to get a value_range for an svalue (but bails out for awkward
cases), and if value_ranges are available, uses them in eval_condition
to determine if the result is known based on range_op.
Doing so fixes the above false positive, improves a couple of other
tests in the DejaGnu testsuite, and eliminates 31 false +ves in the
analyzer integration testsuite (out of ~2200), along with a slight
speedup to the latter (albeit testing with a debug build of gcc).
A deeper integration with ranger could probably be made, but that is
clearly stage 1 material.
gcc/analyzer/ChangeLog:
PR analyzer/98447
* common.h: Include "value-range.h".
* region-model.cc: Include "value-relation.h" and "range-op.h".
(region_model::eval_condition): Try using range_op to see if we
can get a known boolean from the value_ranges of the operands.
* svalue.cc: Include "value-relation.h" and "range-op.h".
(type_can_have_value_range_p): New.
(svalue::maybe_get_value_range): New.
(constant_svalue::maybe_get_value_range): New.
(unknown_svalue::maybe_get_value_range): New.
(unaryop_svalue::maybe_get_value_range): New.
(binop_svalue::maybe_get_value_range): New.
* svalue.h (svalue::maybe_get_value_range): New vfunc decl.
(constant_svalue::maybe_get_value_range): New decl.
(unknown_svalue::maybe_get_value_range): New decl.
(unaryop_svalue::maybe_get_value_range): New decl.
(binop_svalue::maybe_get_value_range): New decl.
gcc/testsuite/ChangeLog:
PR analyzer/98447
* c-c++-common/analyzer/conditionals-pr98447-1.c: New test.
* c-c++-common/analyzer/conditionals-pr98447-2.c: New test.
* c-c++-common/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c:
Updated for false positive being fixed for C.
* gcc.dg/analyzer/data-model-1.c: Update expected output to
reflect improved output.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'libjava/gnu/java/net/protocol/https')
0 files changed, 0 insertions, 0 deletions
