analyzer: fix false leak reports when merging states [PR97074]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 02:44:07 +0000 (21:44 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 7 Jan 2021 02:44:07 +0000 (21:44 -0500)
commitbe6c485b24f2b47ac85380dd2bea025d353f1f91
tree2283d0408d31fa4edf81fb319fb88275dfb938f4
parentcffe6dd2ce358c2cb550c9fb3c57cec65eee1c93
analyzer: fix false leak reports when merging states [PR97074]

gcc/analyzer/ChangeLog:
PR analyzer/97074
* store.cc (binding_cluster::can_merge_p): Add "out_store" param
and pass to calls to binding_cluster::make_unknown_relative_to.
(binding_cluster::make_unknown_relative_to): Add "out_store"
param.  Use it to mark base regions that are pointed to by
pointers that become unknown as having escaped.
(store::can_merge_p): Pass out_store to
binding_cluster::can_merge_p.
* store.h (binding_cluster::can_merge_p): Add "out_store" param.
(binding_cluster::make_unknown_relative_to): Likewise.
* svalue.cc (region_svalue::implicitly_live_p): New vfunc.
* svalue.h (region_svalue::implicitly_live_p): New vfunc decl.

gcc/testsuite/ChangeLog:
PR analyzer/97074
* gcc.dg/analyzer/pr97074.c: New test.
gcc/analyzer/store.cc
gcc/analyzer/store.h
gcc/analyzer/svalue.cc
gcc/analyzer/svalue.h
gcc/testsuite/gcc.dg/analyzer/pr97074.c [new file with mode: 0644]