From 26c9f32fe864f73309818591123b47bc9b0fcfc3 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 14 Apr 2020 09:29:24 -0400 Subject: [PATCH 030/179] FIXME: WIP on binding clusters --- gcc/analyzer/region-model2.h | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/gcc/analyzer/region-model2.h b/gcc/analyzer/region-model2.h index 90ad9343a5d..3758b9bfdef 100644 --- a/gcc/analyzer/region-model2.h +++ b/gcc/analyzer/region-model2.h @@ -1211,6 +1211,70 @@ private: tree m_field; }; +/* A binding within a store. */ + +class binding_key +{ +protected: + binding_key (region2 *region, bool direct) + : m_region (region), m_direct (direct) {} + + region2 *get_region () const { return m_region; } + + bool direct_p () const { return m_direct; } + bool default_p () const { return !m_direct; } + +private: + region2 *m_region; + bool m_direct; /* vs default. */ +}; + +class concrete_binding : public binding_key +{ +public: + typedef unsigned offset_t; + + concrete_binding (region2 *region, bool direct, offset_t offset) + : binding_key (region, direct), m_offset (offset) + {} + +private: + offset_t m_offset; +}; + +class symbolic_binding : public binding_key +{ +public: + symbolic_binding (region2 *region, bool direct, + region2 *concrete_offset_region) + : binding_key (region, direct), + m_concrete_offset_region (concrete_offset_region) + {} +private: + region2 *m_concrete_offset_region; +}; + +/* All of the bindings within a store for regions that share the same + base region. */ + +class binding_cluster +{ +public: + typedef hash_map map_t; + //typedef typename map_t::iterator iterator_t; + +#if 0 + binding_cluster (); + binding_cluster (const binding_cluster &other); +#endif + + const binding_cluster *bind (const extrinsic_state &ext_state, + const region2 *, const svalue *) const; + +private: + map_t m_map; +}; + /* FIXME. */ class region_model2_manager @@ -1229,6 +1293,15 @@ public: region2 *get_field_region (region2 *parent, tree field, region_model2_context *ctxt); + const concrete_binding * + get_concrete_binding (region2 *region, + bool direct, + concrete_binding::offset_t offset); + + const symbolic_binding * + get_symbolic_binding (region2 *region, bool direct, + region2 *concrete_offset_region); + private: root_region2 m_root_region; @@ -1246,6 +1319,8 @@ private: typedef hash_map fields_map_t; fields_map_t m_fields_map; #endif + + uniq_manager m_binding_key_mgr; }; /* A region_model2 encapsulates a representation of the state of memory, with -- 2.21.0