]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: implement kf_strncpy [PR105899]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 6 Sep 2023 13:32:01 +0000 (09:32 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 6 Sep 2023 13:32:01 +0000 (09:32 -0400)
commitb51cde34d4e7504e821d935152c0ece0ce0dc74d
tree6ca7d16a8268c7f396fc06cea6c33a285c6dd853
parentb923978a6ec44772a13daf8b8dddfb3333e67bbe
analyzer: implement kf_strncpy [PR105899]

gcc/analyzer/ChangeLog:
PR analyzer/105899
* kf.cc (class kf_strncpy): New.
(kf_strncpy::impl_call_post): New.
(register_known_functions): Register it.
* region-model.cc (region_model::read_bytes): Handle unknown
number of bytes.

gcc/testsuite/ChangeLog:
PR analyzer/105899
* c-c++-common/analyzer/null-terminated-strings-2.c: New test.
* c-c++-common/analyzer/overlapping-buffers.c: Update dg-bogus
directives to avoid clashing with note from <string.h> that might
happen to have the same line number.  Add strpncpy test coverage.
* c-c++-common/analyzer/strncpy-1.c: New test.
* gcc.dg/analyzer/null-terminated-strings-1.c
(test_filled_nonzero): New.
(void test_filled_zero): New.
(test_filled_symbolic): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/kf.cc
gcc/analyzer/region-model.cc
gcc/testsuite/c-c++-common/analyzer/null-terminated-strings-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/analyzer/overlapping-buffers.c
gcc/testsuite/c-c++-common/analyzer/strncpy-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/analyzer/null-terminated-strings-1.c