diff options
author | David Malcolm <dmalcolm@redhat.com> | 2023-08-24 10:24:40 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2023-08-24 10:24:40 -0400 |
commit | 2bad0eeb5573e52c4b7b51546ecffcb17f46eda3 (patch) | |
tree | f89e830add28a5bf0b4ef036c96513a7cba0eea4 /gcc/analyzer/region-model.cc | |
parent | 46cb27e56f36f23cb277f8a5beae05235af05768 (diff) | |
download | gcc-2bad0eeb5573e52c4b7b51546ecffcb17f46eda3.zip gcc-2bad0eeb5573e52c4b7b51546ecffcb17f46eda3.tar.gz gcc-2bad0eeb5573e52c4b7b51546ecffcb17f46eda3.tar.bz2 |
analyzer: handle strlen(BITS_WITHIN) [PR105899]
gcc/analyzer/ChangeLog:
PR analyzer/105899
* region-model.cc (fragment::has_null_terminator): Handle
SK_BITS_WITHIN.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/region-model.cc')
-rw-r--r-- | gcc/analyzer/region-model.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 6574ec1..025b555 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -3357,10 +3357,29 @@ struct fragment } break; + case SK_BITS_WITHIN: + { + const bits_within_svalue *bits_within_sval + = (const bits_within_svalue *)m_sval; + byte_range bytes (0, 0); + if (bits_within_sval->get_bits ().as_byte_range (&bytes)) + { + const svalue *inner_sval = bits_within_sval->get_inner_svalue (); + fragment f (byte_range + (start_read_offset - bytes.get_start_bit_offset (), + std::max<byte_size_t> (bytes.m_size_in_bytes, + available_bytes)), + inner_sval); + return f.has_null_terminator (start_read_offset, out_bytes_read); + } + } + break; + default: // TODO: it may be possible to handle other cases here. - return tristate::TS_UNKNOWN; + break; } + return tristate::TS_UNKNOWN; } static tristate |