summaryrefslogtreecommitdiff
path: root/gcc/analyzer/region-model.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2021-07-21 17:24:08 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2021-07-21 17:24:08 -0400
commite0a7a6752dad7848eb4b29b826a551c0992256ec (patch)
tree81a2f099b94604fbc59132682e0e095a89d8b96f /gcc/analyzer/region-model.h
parent6bbad96cd44774bc199b256dbf4260b25b87c7db (diff)
downloadgcc-e0a7a6752dad7848eb4b29b826a551c0992256ec.tar.gz
analyzer: fix issues with phi handling
The analyzer's state purging code was overzealously purging state for ssa names that might be used within phi nodes, leading to false positives from -Wanalyzer-use-of-uninitialized-value. This patch updates phi handling in the analyzer to fix these issues. gcc/analyzer/ChangeLog: * region-model.cc (region_model::handle_phi): Add "old_state" param and use it. (region_model::update_for_phis): Update so that all of the phi stmts are effectively handled simultaneously, rather than in order. * region-model.h (region_model::handle_phi): Add "old_state" param. * state-purge.cc (self_referential_phi_p): Replace with... (name_used_by_phis_p): ...this new function. (state_purge_per_ssa_name::process_point): Update to use the above, so that all phi stmts at a basic block are effectively considered simultaneously, and only consider the phi arguments for the pertinent in-edge. * supergraph.cc (cfg_superedge::get_phi_arg_idx): New. (cfg_superedge::get_phi_arg): Use the above. * supergraph.h (cfg_superedge::get_phi_arg_idx): New decl. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/explode-2.c: Remove xfail. * gcc.dg/analyzer/explode-2a.c: Remove expected leak warning on while stmt. * gcc.dg/analyzer/phi-2.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/region-model.h')
-rw-r--r--gcc/analyzer/region-model.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 734ec601237..cc39929db26 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -582,6 +582,7 @@ class region_model
region_model_context *ctxt);
void handle_phi (const gphi *phi, tree lhs, tree rhs,
+ const region_model &old_state,
region_model_context *ctxt);
bool maybe_update_for_edge (const superedge &edge,