]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: fix bitfield endianness issues [PR99212,PR101082]
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)
commit21b470a9c976f3db7cce6d58a07c58a58676f93c
treee3a442f439035ad22c9377cff96bead93b7b13a4
parentf018044145eaebb79c693be897de060429636df9
analyzer: fix bitfield endianness issues [PR99212,PR101082]

Looks like my patch for PR analyzer/99212 implicitly assumed
little-endian, which the following patch fixes.

Fixes bitfields-1.c on:
- armeb-none-linux-gnueabihf
- cris-elf
- powerpc64-darwin
- s390-linux-gnu

gcc/analyzer/ChangeLog:
PR analyzer/99212
PR analyzer/101082
* engine.cc: Include "target.h".
(impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
WORDS_BIG_ENDIAN.
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Move support for masking
via ARG0 & CST into...
(region_model_manager::maybe_undo_optimize_bit_field_compare):
...this new function.  Flatten by converting from nested
conditionals to a series of early return statements to reject
failures.  Reject if type is not unsigned_char_type_node.
Handle BYTES_BIG_ENDIAN when determining which bits are bound
in the binding_map.
* region-model.h
(region_model_manager::maybe_undo_optimize_bit_field_compare):
New decl.
* store.cc (bit_range::dump): New function.
* store.h (bit_range::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/engine.cc
gcc/analyzer/region-model-manager.cc
gcc/analyzer/region-model.h
gcc/analyzer/store.cc
gcc/analyzer/store.h