From f84a8b126f5c2c376e539f17416cfbf21a3b2d63 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 10 Jul 2020 11:20:02 -0400 Subject: [PATCH 297/315] FIXME: move code to new subroutine binding_cluster2::bind_compound_sval --- gcc/analyzer/store2.cc | 88 ++++++++++++++++++++++++------------------ gcc/analyzer/store2.h | 3 ++ 2 files changed, 53 insertions(+), 38 deletions(-) diff --git a/gcc/analyzer/store2.cc b/gcc/analyzer/store2.cc index b4efe5a5a98..e44c4ef95bb 100644 --- a/gcc/analyzer/store2.cc +++ b/gcc/analyzer/store2.cc @@ -433,51 +433,17 @@ binding_cluster2::dump (bool simple) const pp_flush (&pp); } +/* FIXME. */ + void binding_cluster2::bind (store2_manager *mgr, const region2 *reg, const svalue2 *sval, binding_kind kind) { - /* Unpack compound_svals when binding them, so that we bind them - element-wise. */ if (const compound_svalue2 *compound_sval - = sval->dyn_cast_compound_svalue2 ()) + = sval->dyn_cast_compound_svalue2 ()) { - region_offset reg_offset = reg->get_offset (); - if (reg_offset.symbolic_p ()) - { - /* TODO: offset the bound values to be relative to this - region within the cluster. - For now, merely mark it as symbolically touched, and clear - all bindings. */ - m_touched = true; - clobber_region (mgr, reg); - return; - } - - for (map_t::iterator iter = compound_sval->begin (); - iter != compound_sval->end (); ++iter) - { - const binding_key2 *iter_key = (*iter).first; - const svalue2 *iter_sval = (*iter).second; - - if (const concrete_binding2 *concrete_key - = iter_key->dyn_cast_concrete_binding2 ()) - { - bit_offset_t effective_start - = (concrete_key->get_start_bit_offset () - + reg_offset.get_bit_offset ()); - const concrete_binding2 *effective_concrete_key - = mgr->get_concrete_binding (effective_start, - concrete_key->get_size_in_bits (), - iter_key->get_kind ()); - m_map.put (effective_concrete_key, iter_sval); - } - else - gcc_unreachable (); // TODO - if (iter_key->symbolic_p ()) - m_touched = true; - } + bind_compound_sval (mgr, reg, compound_sval); return; } @@ -487,6 +453,52 @@ binding_cluster2::bind (store2_manager *mgr, m_touched = true; } +/* Subroutine of binding_cluster2::bind. + Unpack compound_svals when binding them, so that we bind them + element-wise. */ + +void +binding_cluster2::bind_compound_sval (store2_manager *mgr, + const region2 *reg, + const compound_svalue2 *compound_sval) +{ + region_offset reg_offset = reg->get_offset (); + if (reg_offset.symbolic_p ()) + { + /* TODO: offset the bound values to be relative to this + region within the cluster. + For now, merely mark it as symbolically touched, and clear + all bindings. */ + m_touched = true; + clobber_region (mgr, reg); + return; + } + + for (map_t::iterator iter = compound_sval->begin (); + iter != compound_sval->end (); ++iter) + { + const binding_key2 *iter_key = (*iter).first; + const svalue2 *iter_sval = (*iter).second; + + if (const concrete_binding2 *concrete_key + = iter_key->dyn_cast_concrete_binding2 ()) + { + bit_offset_t effective_start + = (concrete_key->get_start_bit_offset () + + reg_offset.get_bit_offset ()); + const concrete_binding2 *effective_concrete_key + = mgr->get_concrete_binding (effective_start, + concrete_key->get_size_in_bits (), + iter_key->get_kind ()); + m_map.put (effective_concrete_key, iter_sval); + } + else + gcc_unreachable (); // TODO + if (iter_key->symbolic_p ()) + m_touched = true; + } +} + /* FIXME. */ void diff --git a/gcc/analyzer/store2.h b/gcc/analyzer/store2.h index bf27df97d59..d392e2490dc 100644 --- a/gcc/analyzer/store2.h +++ b/gcc/analyzer/store2.h @@ -419,6 +419,9 @@ private: const svalue2 *get_any_value (const binding_key2 *key) const; void get_overlapping_bindings (store2_manager *mgr, const region2 *reg, auto_vec *out); + void bind_compound_sval (store2_manager *mgr, + const region2 *reg, + const compound_svalue2 *compound_sval); const region2 *m_base_region; -- 2.26.2