analyzer: fix zero-fill of calloc
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 3 Feb 2022 16:15:48 +0000 (11:15 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 3 Feb 2022 22:45:47 +0000 (17:45 -0500)
commit23b2cb628e5da84ad9c5422d5b2b6b2d36318ece
treee337440e61db4833506c34e0b5694b5e8574cd44
parent5a668ec0339c28b0725ded1e80d3276edb76b8b3
analyzer: fix zero-fill of calloc

It turned out that the analyzer wasn't treating calloc regions
as zero-filled, due to binding_cluster::fill_region getting an
unknown value for the byte_size_size_sval, and thus
get_or_create_repeated_svalue returning an unknown_svalue, which
was then used to fill the region.

Fixed thusly.

gcc/analyzer/ChangeLog:
* region-model-impl-calls.cc (region_model::impl_call_calloc): Use
a sized_region when calling zero_fill_region.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/calloc-1.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model-impl-calls.cc
gcc/testsuite/gcc.dg/analyzer/calloc-1.c [new file with mode: 0644]