diff options
author | David Malcolm <dmalcolm@redhat.com> | 2021-06-28 19:18:06 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2021-06-28 19:18:06 -0400 |
commit | 7c6b354b92b38f31cd2399fbdbc9d6f837881480 (patch) | |
tree | 7341fcbb487ebc635454396d8b06bc145a6b378a /gcc/analyzer/store.h | |
parent | 40c64c9ea565230817f08b5e66a30a1c94ec880c (diff) | |
download | gcc-7c6b354b92b38f31cd2399fbdbc9d6f837881480.zip gcc-7c6b354b92b38f31cd2399fbdbc9d6f837881480.tar.gz gcc-7c6b354b92b38f31cd2399fbdbc9d6f837881480.tar.bz2 |
analyzer: introduce byte_range and use to simplify dumps
gcc/analyzer/ChangeLog:
* analyzer.h (byte_offset_t): New typedef.
* store.cc (bit_range::dump_to_pp): Dump as a byte range if
possible.
(bit_range::as_byte_range): New.
(byte_range::dump_to_pp): New.
* store.h (class byte_range): New forward decl.
(struct bit_range): Add comment.
(bit_range::as_byte_range): New decl.
(struct byte_range): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/store.h')
-rw-r--r-- | gcc/analyzer/store.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h index ca9ff69..e0c60e1 100644 --- a/gcc/analyzer/store.h +++ b/gcc/analyzer/store.h @@ -196,6 +196,7 @@ private: hash_set<const svalue *> m_mutable_at_unknown_call_svals; }; +class byte_range; class concrete_binding; /* An enum for discriminating between "direct" vs "default" levels of @@ -267,6 +268,8 @@ private: enum binding_kind m_kind; }; +/* A concrete range of bits. */ + struct bit_range { bit_range (bit_offset_t start_bit_offset, bit_size_t size_in_bits) @@ -308,10 +311,32 @@ struct bit_range static bool from_mask (unsigned HOST_WIDE_INT mask, bit_range *out); + bool as_byte_range (byte_range *out) const; + bit_offset_t m_start_bit_offset; bit_size_t m_size_in_bits; }; +/* A concrete range of bytes. */ + +struct byte_range +{ + byte_range (byte_offset_t start_byte_offset, byte_size_t size_in_bytes) + : m_start_byte_offset (start_byte_offset), + m_size_in_bytes (size_in_bytes) + {} + + void dump_to_pp (pretty_printer *pp) const; + + byte_offset_t get_last_byte_offset () const + { + return m_start_byte_offset + m_size_in_bytes - 1; + } + + byte_offset_t m_start_byte_offset; + byte_size_t m_size_in_bytes; +}; + /* Concrete subclass of binding_key, for describing a concrete range of bits within the binding_map (e.g. "bits 8-15"). */ |