From e9f84beaddea856266ace2197929b866e3f38794 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Wed, 6 May 2020 12:50:05 -0400
Subject: [PATCH 100/251] FIXME: make all svalue2 and region2 ptrs const,
 except in manager

---
 gcc/analyzer/checker-path.h         |   2 +-
 gcc/analyzer/constraint-manager2.cc |  53 +-
 gcc/analyzer/constraint-manager2.h  |  31 +-
 gcc/analyzer/diagnostic-manager.cc  |  14 +-
 gcc/analyzer/engine.cc              |  10 +-
 gcc/analyzer/program-state.cc       |  49 +-
 gcc/analyzer/program-state.h        |  26 +-
 gcc/analyzer/region-model2.cc       | 746 ++++++++++++++--------------
 gcc/analyzer/region-model2.h        | 392 ++++++++-------
 gcc/analyzer/store2.cc              |  48 +-
 gcc/analyzer/store2.h               |  38 +-
 11 files changed, 734 insertions(+), 675 deletions(-)

diff --git a/gcc/analyzer/checker-path.h b/gcc/analyzer/checker-path.h
index 8dcc5246dfa..72c8444c743 100644
--- a/gcc/analyzer/checker-path.h
+++ b/gcc/analyzer/checker-path.h
@@ -209,7 +209,7 @@ public:
     return m_dst_state.m_region_model->get_lvalue (expr, ctxt);
   }
 
-  region2* get_lvalue2 (tree expr, region_model2_context *ctxt) const
+  const region2* get_lvalue2 (tree expr, region_model2_context *ctxt) const
   {
     gcc_assert (m_dst_state.m_region_model2);
     return m_dst_state.m_region_model2->get_lvalue (expr, ctxt);
diff --git a/gcc/analyzer/constraint-manager2.cc b/gcc/analyzer/constraint-manager2.cc
index 87c7fe92593..03fe15ba286 100644
--- a/gcc/analyzer/constraint-manager2.cc
+++ b/gcc/analyzer/constraint-manager2.cc
@@ -179,7 +179,7 @@ equiv_class2::equiv_class2 (const equiv_class2 &other)
   m_vars (other.m_vars.length ())
 {
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
   FOR_EACH_VEC_ELT (other.m_vars, i, sval)
     m_vars.quick_push (sval);
 }
@@ -192,7 +192,7 @@ equiv_class2::print (pretty_printer *pp) const
 {
   pp_character (pp, '{');
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
   FOR_EACH_VEC_ELT (m_vars, i, sval)
     {
       if (i > 0)
@@ -215,7 +215,7 @@ equiv_class2::hash () const
 {
   inchash::hash hstate;
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
 
   inchash::add_expr (m_constant, hstate);
   // TODO:
@@ -240,7 +240,7 @@ equiv_class2::operator== (const equiv_class2 &other)
     return false;
 
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
   FOR_EACH_VEC_ELT (m_vars, i, sval)
     if (sval != other.m_vars[i])
       return false;
@@ -252,7 +252,7 @@ equiv_class2::operator== (const equiv_class2 &other)
 /* Add SID to this equiv_class2, using CM to check if it's a constant.  */
 
 void
-equiv_class2::add (svalue2 *sval)
+equiv_class2::add (const svalue2 *sval)
 {
   gcc_assert (sval);
   if (tree cst = sval->maybe_get_constant ())
@@ -271,13 +271,13 @@ equiv_class2::add (svalue2 *sval)
    a possible leak).  */
 
 bool
-equiv_class2::del (svalue2 *sval)
+equiv_class2::del (const svalue2 *sval)
 {
   gcc_assert (sval);
   gcc_assert (sval != m_cst_sval);
 
   int i;
-  svalue2 *iv;
+  const svalue2 *iv;
   FOR_EACH_VEC_ELT (m_vars, i, iv)
     {
       if (iv == sval)
@@ -296,7 +296,7 @@ equiv_class2::del (svalue2 *sval)
 /* Get a representative member of this class, for handling cases
    where the IDs can change mid-traversal.  */
 
-svalue2 *
+const svalue2 *
 equiv_class2::get_representative () const
 {
   if (m_cst_sval)
@@ -638,9 +638,9 @@ debug (const constraint_manager2 &cm)
    Return false if the constraint contradicts existing knowledge.  */
 
 bool
-constraint_manager2::add_constraint (svalue2 * lhs,
+constraint_manager2::add_constraint (const svalue2 *lhs,
 				     enum tree_code op,
-				     svalue2 * rhs)
+				     const svalue2 *rhs)
 {
   equiv_class2_id lhs_ec_id = get_or_add_equiv_class2 (lhs);
   equiv_class2_id rhs_ec_id = get_or_add_equiv_class2 (rhs);
@@ -680,7 +680,7 @@ constraint_manager2::add_constraint (equiv_class2_id lhs_ec_id,
 	const equiv_class2 &rhs_ec_obj = rhs_ec_id.get_obj (*this);
 
 	int i;
-	svalue2 *sval;
+	const svalue2 *sval;
 	FOR_EACH_VEC_ELT (rhs_ec_obj.m_vars, i, sval)
 	  lhs_ec_obj.add (sval);
 
@@ -761,8 +761,8 @@ constraint_manager2::add_constraint_internal (equiv_class2_id lhs_id,
       /* The following can potentially add EQ_EXPR facts, which could lead
 	 to ECs being merged, which would change the meaning of the EC IDs.
 	 Hence we need to do this via representatives.  */
-      svalue2 * lhs = lhs_id.get_obj (*this).get_representative ();
-      svalue2 * rhs = rhs_id.get_obj (*this).get_representative ();
+      const svalue2 *lhs = lhs_id.get_obj (*this).get_representative ();
+      const svalue2 *rhs = rhs_id.get_obj (*this).get_representative ();
 
       /* We have LHS </<= RHS */
 
@@ -835,7 +835,7 @@ constraint_manager2::add_constraint_internal (equiv_class2_id lhs_id,
 		      tree constant;
 		      if (r.constrained_to_single_element (&constant))
 			{
-			  svalue2 * cst_sval
+			  const svalue2 *cst_sval
 			    = m_mgr->get_or_create_constant_svalue2 (constant);
 			  add_constraint
 			    (rhs_id, EQ_EXPR,
@@ -868,7 +868,7 @@ constraint_manager2::add_constraint_internal (equiv_class2_id lhs_id,
 		      tree constant;
 		      if (r.constrained_to_single_element (&constant))
 			{
-			  svalue2 * cst_sval
+			  const svalue2 *cst_sval
 			    = m_mgr->get_or_create_constant_svalue2 (constant);
 			  add_constraint
 			    (lhs_id, EQ_EXPR,
@@ -892,7 +892,7 @@ constraint_manager2::add_constraint_internal (equiv_class2_id lhs_id,
    if found, write the id to *OUT and return true, otherwise return false.  */
 
 bool
-constraint_manager2::get_equiv_class2_by_svalue2 (svalue2 *sval,
+constraint_manager2::get_equiv_class2_by_svalue2 (const svalue2 *sval,
 						  equiv_class2_id *out) const
 {
   /* TODO: should we have a map, rather than these searches?  */
@@ -901,7 +901,7 @@ constraint_manager2::get_equiv_class2_by_svalue2 (svalue2 *sval,
   FOR_EACH_VEC_ELT (m_equiv_class2es, i, ec)
     {
       int j;
-      svalue2 *iv;
+      const svalue2 *iv;
       FOR_EACH_VEC_ELT (ec->m_vars, j, iv)
 	if (iv == sval)
 	  {
@@ -916,7 +916,7 @@ constraint_manager2::get_equiv_class2_by_svalue2 (svalue2 *sval,
    return the ID of the class.  */
 
 equiv_class2_id
-constraint_manager2::get_or_add_equiv_class2 (svalue2 *sval)
+constraint_manager2::get_or_add_equiv_class2 (const svalue2 *sval)
 {
   equiv_class2_id result (-1);
 
@@ -1057,9 +1057,9 @@ constraint_manager2::eval_condition (equiv_class2_id lhs_ec,
    LHS and RHS if they aren't already in equiv_class2es.  */
 
 tristate
-constraint_manager2::eval_condition (svalue2 *lhs,
+constraint_manager2::eval_condition (const svalue2 *lhs,
 				     enum tree_code op,
-				     svalue2 *rhs)
+				     const svalue2 *rhs)
 {
   return eval_condition (get_or_add_equiv_class2 (lhs),
 			 op,
@@ -1081,7 +1081,7 @@ constraint_manager2::purge (const purge_criteria2 &p, purge_stats2 *stats)
       equiv_class2 *ec = m_equiv_class2es[ec_idx];
 
       int i;
-      svalue2 *pv;
+      const svalue2 *pv;
       bool delete_ec = false;
       FOR_EACH_VEC_ELT (ec->m_vars, i, pv)
 	{
@@ -1319,7 +1319,7 @@ public:
   : m_cm_b (cm_b), m_out (out)
   {}
 
-  void on_fact (svalue2 *lhs, enum tree_code code, svalue2 *rhs)
+  void on_fact (const svalue2 *lhs, enum tree_code code, const svalue2 *rhs)
     FINAL OVERRIDE
   {
     if (m_cm_b->eval_condition (lhs, code, rhs).is_true ())
@@ -1401,10 +1401,11 @@ clean_merger_input (const constraint_manager2 &cm_in,
 	  cleaned_ec.m_cst_sval = out->get_sval_for_constant (cst);
 	}
       unsigned var_idx;
-      svalue2 **var_in_sval;
+      const svalue2 **var_in_sval;
       FOR_EACH_VEC_ELT (ec->m_vars, var_idx, var_in_sval)
 	{
-	  svalue2 *var_m_sval = map_sval_to_m.get_dst_for_src (*var_in_sval);
+	  const svalue2 *var_m_sval
+	    = map_sval_to_m.get_dst_for_src (*var_in_sval);
 	  if (!var_m_sval.null_p ())
 	    cleaned_ec.m_vars.safe_push (var_m_sval);
 	}
@@ -1449,7 +1450,7 @@ constraint_manager2::for_each_fact (fact2_visitor *visitor) const
       if (ec->m_cst_sval)
 	{
 	  unsigned i;
-	  svalue2 *sval;
+	  const svalue2 *sval;
 	  FOR_EACH_VEC_ELT (ec->m_vars, i, sval)
 	    visitor->on_fact (ec->m_cst_sval, EQ_EXPR, sval);
 	}
@@ -1501,7 +1502,7 @@ constraint_manager2::validate () const
       gcc_assert (ec);
 
       int j;
-      svalue2 *sval;
+      const svalue2 *sval;
       FOR_EACH_VEC_ELT (ec->m_vars, j, sval)
 	gcc_assert (sval);
       if (ec->m_constant)
diff --git a/gcc/analyzer/constraint-manager2.h b/gcc/analyzer/constraint-manager2.h
index 0b849e1876c..dc83d7c90e1 100644
--- a/gcc/analyzer/constraint-manager2.h
+++ b/gcc/analyzer/constraint-manager2.h
@@ -31,7 +31,7 @@ class purge_criteria2
 {
 public:
   virtual ~purge_criteria2 () {}
-  virtual bool should_purge_p (svalue2 *sval) const = 0;
+  virtual bool should_purge_p (const svalue2 *sval) const = 0;
 };
 
 /* An equivalence class within a constraint manager: a set of
@@ -47,12 +47,12 @@ public:
   hashval_t hash () const;
   bool operator== (const equiv_class2 &other);
 
-  void add (svalue2 *sval);
-  bool del (svalue2 *sval);
+  void add (const svalue2 *sval);
+  bool del (const svalue2 *sval);
 
   tree get_any_constant () const { return m_constant; }
 
-  svalue2 *get_representative () const;
+  const svalue2 *get_representative () const;
 
   void canonicalize ();
 
@@ -62,10 +62,10 @@ public:
      different zeroes, for different types); these are just for the last
      constant added.  */
   tree m_constant;
-  svalue2 *m_cst_sval;
+  const svalue2 *m_cst_sval;
 
   // TODO: should this be a set rather than a vec?
-  auto_vec<svalue2 *> m_vars;
+  auto_vec<const svalue2 *> m_vars;
 };
 
 /* The various kinds of constraint.  */
@@ -150,7 +150,9 @@ class fact2_visitor
 {
  public:
   virtual ~fact2_visitor () {}
-  virtual void on_fact (svalue2 *lhs, enum tree_code, svalue2 *rhs) = 0;
+  virtual void on_fact (const svalue2 *lhs,
+			enum tree_code,
+			const svalue2 *rhs) = 0;
 };
 
 /* A collection of equivalence classes and constraints on them.
@@ -192,26 +194,29 @@ public:
     return *m_equiv_class2es[idx];
   }
 
-  equiv_class2 &get_equiv_class2 (svalue2 *sval)
+  equiv_class2 &get_equiv_class2 (const svalue2 *sval)
   {
     equiv_class2_id ec_id = get_or_add_equiv_class2 (sval);
     return ec_id.get_obj (*this);
   }
 
-  bool add_constraint (svalue2 *lhs, enum tree_code op, svalue2 *rhs);
+  bool add_constraint (const svalue2 *lhs,
+		       enum tree_code op,
+		       const svalue2 *rhs);
 
   bool add_constraint (equiv_class2_id lhs_ec_id,
 		       enum tree_code op,
 		       equiv_class2_id rhs_ec_id);
 
-  bool get_equiv_class2_by_svalue2 (svalue2 *sval, equiv_class2_id *out) const;
-  equiv_class2_id get_or_add_equiv_class2 (svalue2 *sval);
+  bool get_equiv_class2_by_svalue2 (const svalue2 *sval,
+				    equiv_class2_id *out) const;
+  equiv_class2_id get_or_add_equiv_class2 (const svalue2 *sval);
   tristate eval_condition (equiv_class2_id lhs,
 			   enum tree_code op,
 			   equiv_class2_id rhs);
-  tristate eval_condition (svalue2 *lhs,
+  tristate eval_condition (const svalue2 *lhs,
 			   enum tree_code op,
-			   svalue2 *rhs);
+			   const svalue2 *rhs);
 
   void purge (const purge_criteria2 &p, purge_stats2 *stats);
 
diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 054baa42f44..be39037e01f 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -856,7 +856,7 @@ public:
 			state_machine::state_t src_sm_val,
 			state_machine::state_t dst_sm_val,
 			tree dst_rep,
-			svalue2 *dst_origin_sval) FINAL OVERRIDE
+			const svalue2 *dst_origin_sval) FINAL OVERRIDE
   {
     const exploded_node *src_node = m_eedge.m_src;
     const program_point &src_point = src_node->get_point ();
@@ -951,13 +951,13 @@ for_each_state_change2 (const program_state &src_state,
 #if 1
 	  // FIXME: we can compare them now
 	  // FIXME: do we want to sort them first, then emit events?
-	  svalue2 *sval = (*iter).first;
+	  const svalue2 *sval = (*iter).first;
 	  tree dst_rep = dst_state.get_representative_tree2 (sval);
 	  state_machine::state_t dst_sm_val = (*iter).second.m_state;
 	  state_machine::state_t src_sm_val = src_smap.get_state (sval);
 	  if (dst_sm_val != src_sm_val)
 	    {
-	      svalue2 *origin_sval = (*iter).second.m_origin;
+	      const svalue2 *origin_sval = (*iter).second.m_origin;
 	      if (visitor->on_state_change (sm, src_sm_val, dst_sm_val,
 					    dst_rep, origin_sval))
 		return true;
@@ -980,14 +980,14 @@ for_each_state_change2 (const program_state &src_state,
 		  >= src_state.m_region_model->get_stack_depth ())
 		continue;
 	      tentative_region_model_context ctxt;
-	      svalue2 *src_sval
+	      const svalue2 *src_sval
 		= src_state.m_region_model2->get_rvalue (*dst_pv, &ctxt);
 	      if (src_val == NULL || ctxt.had_errors_p ())
 		continue;
 	      state_machine::state_t src_sm_val = src_smap.get_state (src_sval);
 	      if (dst_sm_val != src_sm_val)
 		{
-		  svalue2 *dst_origin_sval = (*iter).second.m_origin;
+		  const svalue2 *dst_origin_sval = (*iter).second.m_origin;
 		  if (visitor->on_state_change (sm, src_sm_val, dst_sm_val,
 						dst_rep, dst_origin_sval))
 		    return true;
@@ -1406,9 +1406,9 @@ diagnostic_manager::prune_for_sm_diagnostic (checker_path *path,
 		   bulletproofing against cases where they can't have lvalues by
 		   using tentative_region_model_context.  */
 		tentative_region_model2_context ctxt;
-		region2 *state_var_reg
+		const region2 *state_var_reg
 		  = state_change->get_lvalue2 (state_change->m_var, &ctxt);
-		region2 *var_reg = state_change->get_lvalue2 (var, &ctxt);
+		const region2 *var_reg = state_change->get_lvalue2 (var, &ctxt);
 		ctxt_had_errors = ctxt.had_errors_p ();
 		same_region = (state_var_reg == var_reg && !ctxt.had_errors_p ());
 	      }
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index abd4b8eb105..c3af9e1059c 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -477,15 +477,15 @@ public:
     impl_region_model2_context old_ctxt
       (m_eg, m_enode_for_diag, NULL, NULL/*m_enode->get_state ()*/,
        m_change, stmt);
-    svalue2 *var_old_sval
+    const svalue2 *var_old_sval
       = m_old_state->m_region_model2->get_rvalue (var, &old_ctxt);
 
     impl_region_model2_context new_ctxt (m_eg, m_enode_for_diag,
 					 m_old_state, m_new_state,
 					 m_change, NULL);
-    svalue2 *var_new_sval
+    const svalue2 *var_new_sval
       = m_new_state->m_region_model2->get_rvalue (var, &new_ctxt);
-    svalue2 *origin_new_sval
+    const svalue2 *origin_new_sval
       = m_new_state->m_region_model2->get_rvalue (origin, &new_ctxt);
 
     state_machine::state_t current = m_old_smap->get_state (var_old_sval);
@@ -518,7 +518,7 @@ public:
     state_machine::state_t current;
     if (var)
       {
-	svalue2 *var_old_sval
+	const svalue2 *var_old_sval
 	  = m_old_state->m_region_model2->get_rvalue (var, &old_ctxt);
 	current = m_old_smap->get_state (var_old_sval);
       }
@@ -555,7 +555,7 @@ public:
     return expr;
 #else
     gcc_assert (m_new_state);
-    svalue2 *sval = m_new_state->m_region_model2->get_rvalue (expr, NULL);
+    const svalue2 *sval = m_new_state->m_region_model2->get_rvalue (expr, NULL);
     /* Find trees for all regions storing the value.  */
     auto_vec<path_var> pvs;
     m_new_state->m_region_model2->get_path_vars_for_svalue (sval, &pvs);
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc
index e14811367a2..7a28b2cc0b8 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -631,7 +631,7 @@ sm_state_map2::print (const state_machine &sm, const region_model2 *model,
       if (!first)
 	pp_string (pp, ", ");
       first = false;
-      svalue2 *sval = (*iter).first;
+      const svalue2 *sval = (*iter).first;
       sval->dump_to_pp (pp, false);
 
       entry_t e = (*iter).second;
@@ -727,7 +727,7 @@ sm_state_map2::operator== (const sm_state_map2 &other) const
        iter != m_map.end ();
        ++iter)
     {
-      svalue2 *sval = (*iter).first;
+      const svalue2 *sval = (*iter).first;
       entry_t e = (*iter).second;
       entry_t *other_slot = const_cast <map_t &> (other.m_map).get (sval);
       if (other_slot == NULL)
@@ -745,7 +745,7 @@ sm_state_map2::operator== (const sm_state_map2 &other) const
    States default to the start state.  */
 
 state_machine::state_t
-sm_state_map2::get_state (svalue2 *sval) const
+sm_state_map2::get_state (const svalue2 *sval) const
 {
   gcc_assert (sval);
 
@@ -758,8 +758,8 @@ sm_state_map2::get_state (svalue2 *sval) const
 
 /* Get the "origin" svalue2 for any state of SVAL.  */
 
-svalue2 *
-sm_state_map2::get_origin (svalue2 *sval) const
+const svalue2 *
+sm_state_map2::get_origin (const svalue2 *sval) const
 {
   gcc_assert (sval);
 
@@ -776,9 +776,9 @@ sm_state_map2::get_origin (svalue2 *sval) const
 
 void
 sm_state_map2::set_state (region_model2 *model,
-			  svalue2 *sval,
+			  const svalue2 *sval,
 			  state_machine::state_t state,
-			  svalue2 *origin)
+			  const svalue2 *origin)
 {
   if (model == NULL)
     return;
@@ -810,10 +810,10 @@ sm_state_map2::set_state (region_model2 *model,
 bool
 sm_state_map2::set_state (const equiv_class2 &ec,
 			  state_machine::state_t state,
-			  svalue2 *origin)
+			  const svalue2 *origin)
 {
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
   bool any_changed = false;
   FOR_EACH_VEC_ELT (ec.m_vars, i, sval)
     any_changed |= impl_set_state (sval, state, origin);
@@ -824,8 +824,9 @@ sm_state_map2::set_state (const equiv_class2 &ec,
    Return true if the state changed.  */
 
 bool
-sm_state_map2::impl_set_state (svalue2 *sval, state_machine::state_t state,
-			       svalue2 *origin)
+sm_state_map2::impl_set_state (const svalue2 *sval,
+			       state_machine::state_t state,
+			       const svalue2 *origin)
 {
   if (get_state (sval) == state)
     return false;
@@ -998,7 +999,7 @@ sm_state_map2::on_cast (svalue_id src_sid,
 /* Purge state from SID (in response to a call to an unknown function).  */
 
 void
-sm_state_map2::on_unknown_change (svalue2 *sval)
+sm_state_map2::on_unknown_change (const svalue2 *sval)
 {
   impl_set_state (sval, (state_machine::state_t)0, NULL);
 }
@@ -1742,7 +1743,7 @@ program_state::get_representative_tree (svalue_id sid) const
 /* FIXME.  */
 
 tree
-program_state::get_representative_tree2 (svalue2 *sval) const
+program_state::get_representative_tree2 (const svalue2 *sval) const
 {
   gcc_assert (m_region_model2);
   return m_region_model2->get_representative_tree (sval);
@@ -2390,9 +2391,9 @@ test_sm_state_map2 ()
   {
     region_model2_manager mgr;
     region_model2 model (&mgr);
-    svalue2 *x_sval = model.get_rvalue (x, NULL);
-    svalue2 *y_sval = model.get_rvalue (y, NULL);
-    svalue2 *z_sval = model.get_rvalue (z, NULL);
+    const svalue2 *x_sval = model.get_rvalue (x, NULL);
+    const svalue2 *y_sval = model.get_rvalue (y, NULL);
+    const svalue2 *z_sval = model.get_rvalue (z, NULL);
 
     sm_state_map2 map;
     ASSERT_TRUE (map.is_empty_p ());
@@ -2416,9 +2417,9 @@ test_sm_state_map2 ()
   {
     region_model2_manager mgr;
     region_model2 model (&mgr);
-    svalue2 *x_sval = model.get_rvalue (x, NULL);
-    svalue2 *y_sval = model.get_rvalue (y, NULL);
-    svalue2 *z_sval = model.get_rvalue (z, NULL);
+    const svalue2 *x_sval = model.get_rvalue (x, NULL);
+    const svalue2 *y_sval = model.get_rvalue (y, NULL);
+    const svalue2 *z_sval = model.get_rvalue (z, NULL);
 
     sm_state_map2 map;
     ASSERT_TRUE (map.is_empty_p ());
@@ -2440,8 +2441,8 @@ test_sm_state_map2 ()
   {
     region_model2_manager mgr;
     region_model2 model (&mgr);
-    svalue2 *y_sval = model.get_rvalue (y, NULL);
-    svalue2 *z_sval = model.get_rvalue (z, NULL);
+    const svalue2 *y_sval = model.get_rvalue (y, NULL);
+    const svalue2 *z_sval = model.get_rvalue (z, NULL);
 
     sm_state_map2 map0;
     sm_state_map2 map1;
@@ -2471,9 +2472,9 @@ test_sm_state_map2 ()
 
     region_model2_manager mgr;
     region_model2 model (&mgr);
-    svalue2 *x_sval = model.get_rvalue (x, NULL);
-    svalue2 *y_sval = model.get_rvalue (y, NULL);
-    svalue2 *z_sval = model.get_rvalue (z, NULL);
+    const svalue2 *x_sval = model.get_rvalue (x, NULL);
+    const svalue2 *y_sval = model.get_rvalue (y, NULL);
+    const svalue2 *z_sval = model.get_rvalue (z, NULL);
 
     map1.impl_set_state (x_sval, 2, NULL);
     map1.impl_set_state (y_sval, 3, NULL);
diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h
index b2fcfcaee70..513f470f585 100644
--- a/gcc/analyzer/program-state.h
+++ b/gcc/analyzer/program-state.h
@@ -239,7 +239,7 @@ public:
     }
 
     entry_t (state_machine::state_t state,
-	     svalue2 *origin)
+	     const svalue2 *origin)
     : m_state (state), m_origin (origin)
     {}
 
@@ -254,9 +254,9 @@ public:
     }
 
     state_machine::state_t m_state;
-    svalue2 *m_origin;
+    const svalue2 *m_origin;
   };
-  typedef hash_map <svalue2 *, entry_t> map_t;
+  typedef hash_map <const svalue2 *, entry_t> map_t;
   typedef map_t::iterator iterator_t;
 
   sm_state_map2 ();
@@ -277,19 +277,19 @@ public:
     return !(*this == other);
   }
 
-  state_machine::state_t get_state (svalue2 *sval) const;
-  svalue2 *get_origin (svalue2 *sval) const;
+  state_machine::state_t get_state (const svalue2 *sval) const;
+  const svalue2 *get_origin (const svalue2 *sval) const;
 
   void set_state (region_model2 *model,
-		  svalue2 *sval,
+		  const svalue2 *sval,
 		  state_machine::state_t state,
-		  svalue2 *origin);
+		  const svalue2 *origin);
   bool set_state (const equiv_class2 &ec,
 		  state_machine::state_t state,
-		  svalue2 *origin);
-  bool impl_set_state (svalue2 *sval,
+		  const svalue2 *origin);
+  bool impl_set_state (const svalue2 *sval,
 		       state_machine::state_t state,
-		       svalue2 *origin);
+		       const svalue2 *origin);
 
   void set_global_state (state_machine::state_t state);
   state_machine::state_t get_global_state () const;
@@ -313,7 +313,7 @@ public:
 		svalue_id dst_sid);
 #endif
 
-  void on_unknown_change (svalue2 *sval);
+  void on_unknown_change (const svalue2 *sval);
 
 #if 0
   void validate (const state_machine &sm, int num_svalues) const;
@@ -385,7 +385,7 @@ public:
   void remap_svalue_ids (const svalue_id_map &map);
 
   tree get_representative_tree (svalue_id sid) const;
-  tree get_representative_tree2 (svalue2 *sval) const;
+  tree get_representative_tree2 (const svalue2 *sval) const;
 
   bool can_purge_p (const extrinsic_state &ext_state,
 		    svalue_id sid)
@@ -464,7 +464,7 @@ public:
 				state_machine::state_t src_sm_val,
 				state_machine::state_t dst_sm_val,
 				tree dst_rep,
-				svalue2 *dst_origin_sval) = 0;
+				const svalue2 *dst_origin_sval) = 0;
 };
 
 extern bool for_each_state_change2 (const program_state &src_state,
diff --git a/gcc/analyzer/region-model2.cc b/gcc/analyzer/region-model2.cc
index d9c4fffa68c..c7fe5f2e458 100644
--- a/gcc/analyzer/region-model2.cc
+++ b/gcc/analyzer/region-model2.cc
@@ -129,9 +129,9 @@ class impl_constraint_manager : public constraint_manager
     return new impl_constraint_manager (*this, model);
   }
 
-  tree maybe_get_constant (svalue2 *sval) const FINAL OVERRIDE
+  tree maybe_get_constant (const svalue2 *sval) const FINAL OVERRIDE
   {
-    svalue2 *svalue2 = m_model->get_svalue2 (sid);
+    const svalue2 *svalue2 = m_model->get_svalue2 (sid);
     return svalue2->maybe_get_constant ();
   }
 
@@ -350,7 +350,7 @@ region_svalue2::merge_values (const region_svalue2 &region2_sval_a,
      region2s, then the merged ptr has to be "unknown".  */
   if (a_reg_in_m != b_reg_in_m)
     {
-      svalue2 *merged_sval = new unknown_svalue2 (type);
+      const svalue2 *merged_sval = new unknown_svalue2 (type);
       *merged_sval = merger->m_merged_model->add_svalue2 (merged_sval);
       return;
     }
@@ -409,7 +409,7 @@ region_svalue2::merge_values (const region_svalue2 &region2_sval_a,
     }
 
   /* Two different non-NULL pointers?  Merge to unknown.  */
-  svalue2 *merged_sval = new unknown_svalue2 (type);
+  const svalue2 *merged_sval = new unknown_svalue2 (type);
   *merged_sval = merger->m_merged_model->add_svalue2 (merged_sval);
   return;
 }
@@ -420,13 +420,13 @@ region_svalue2::merge_values (const region_svalue2 &region2_sval_a,
    pointers.  */
 
 tristate
-region_svalue2::eval_condition (region_svalue2 *lhs,
+region_svalue2::eval_condition (const region_svalue2 *lhs,
 				enum tree_code op,
-				region_svalue2 *rhs)
+				const region_svalue2 *rhs)
 {
   /* See if they point to the same region2.  */
-  region2 *lhs_reg = lhs->get_pointee ();
-  region2 *rhs_reg = rhs->get_pointee ();
+  const region2 *lhs_reg = lhs->get_pointee ();
+  const region2 *rhs_reg = rhs->get_pointee ();
   bool ptr_equality = lhs_reg == rhs_reg;
   /* TODO: what about child region2s where the child is the first child
      (or descendent)?
@@ -517,7 +517,7 @@ constant_svalue2::merge_values (const constant_svalue2 &cst_sval_a,
 {
   tree cst_a = cst_sval_a.get_constant ();
   tree cst_b = cst_sval_b.get_constant ();
-  svalue2 *merged_sval;
+  const svalue2 *merged_sval;
   if (cst_a == cst_b)
     {
       /* If they are the same constant, merge as that constant value.  */
@@ -540,9 +540,9 @@ constant_svalue2::merge_values (const constant_svalue2 &cst_sval_a,
    constants.  */
 
 tristate
-constant_svalue2::eval_condition (constant_svalue2 *lhs,
-				 enum tree_code op,
-				 constant_svalue2 *rhs)
+constant_svalue2::eval_condition (const constant_svalue2 *lhs,
+				  enum tree_code op,
+				  const constant_svalue2 *rhs)
 {
   tree lhs_const = lhs->get_constant ();
   tree rhs_const = rhs->get_constant ();
@@ -588,7 +588,7 @@ constant_svalue2::get_child_sval (region2 *parent ATTRIBUTE_UNUSED,
      constant.
 
      Handle this case by using an unknown value.  */
-  svalue2 *unknown_sval = new unknown_svalue2 (child->get_type ());
+  const svalue2 *unknown_sval = new unknown_svalue2 (child->get_type ());
   return model.add_svalue2 (unknown_sval);
 }
 #endif
@@ -978,7 +978,7 @@ region2::get_base_region () const
 }
 
 region_offset
-region2::get_offset ()
+region2::get_offset () const
 {
   if(!m_cached_offset)
     m_cached_offset = new region_offset (calc_offset ());
@@ -1085,14 +1085,15 @@ region2::calc_offset () const
 	       pointer svalue.  */
 	    const symbolic_region2 *symbolic_region
 	      = (const symbolic_region2 *)iter_region;
-	    svalue2 *sval = symbolic_region->get_pointer ();
+	    const svalue2 *sval = symbolic_region->get_pointer ();
 	    switch (sval->get_kind ())
 	      {
 	      default:
 		gcc_unreachable ();
 	      case svalue2::SK_BINOP:
 		{
-		  binop_svalue2 *binop_sval = as_a <binop_svalue2 *> (sval);
+		  const binop_svalue2 *binop_sval
+		    = as_a <const binop_svalue2 *> (sval);
 		  switch (binop_sval->get_op ())
 		    {
 		    default:
@@ -1106,8 +1107,8 @@ region2::calc_offset () const
 			   things via element indices, rather than via byte offsets.  */
 			/* Perhaps instead we should capture this as an offset relative
 			   to a base region in region_offset?  */
-			svalue2 *ptr = binop_sval->get_arg0 ();
-			svalue2 *offset = binop_sval->get_arg1 ();
+			const svalue2 *ptr = binop_sval->get_arg0 ();
+			const svalue2 *offset = binop_sval->get_arg1 ();
 			gcc_unreachable ();
 		      }
 		    }
@@ -1136,14 +1137,14 @@ region2::get_representative_path_var () const
    for some kinds of casts).  */
 #if 0
 void
-region2::set_value (region_model2 &model, region2 *lhs_reg, svalue2 *rhs_sval,
+region2::set_value (region_model2 &model, region2 *lhs_reg, const svalue2 *rhs_sval,
 		    region_model2_context *ctxt)
 {
   gcc_unreachable ();
   /* Handle some kinds of casting.  */
   if (m_type)
     {
-      svalue2 *sval = model.get_svalue2 (rhs_sval);
+      const svalue2 *sval = model.get_svalue2 (rhs_sval);
       if (sval->get_type ())
 	rhs_sval = model.maybe_cast (m_type, rhs_sval, ctxt);
 
@@ -1334,7 +1335,7 @@ region2::get_inherited_child_sval (region2 *child,
       /* Clone the parent's value, so that attempts to update it
 	 (e.g giving a specific value to an inherited "uninitialized"
 	 value) touch the child, and not the parent.  */
-      svalue2 *this_value = model.get_svalue2 (m_sval_id);
+      const svalue2 *this_value = model.get_svalue2 (m_sval_id);
       svalue2_id new_child_sval
 	= this_value->get_child_sval (this, child, model, ctxt);
       if (ctxt)
@@ -1353,7 +1354,7 @@ region2::get_inherited_child_sval (region2 *child,
    and arrays recursively.  */
 
 void
-region_model2::copy_region (region2 *dst_reg, region2 *src_reg,
+region_model2::copy_region (const region2 *dst_reg, const region2 *src_reg,
 			    region_model2_context *ctxt)
 {
   gcc_assert (dst_reg);
@@ -1361,12 +1362,12 @@ region_model2::copy_region (region2 *dst_reg, region2 *src_reg,
   if (dst_reg == src_reg)
     return;
 
-  svalue2 *sval = get_store_value (src_reg);
+  const svalue2 *sval = get_store_value (src_reg);
   set_value (dst_reg, sval, ctxt);
 
 #if 0
   /* Copy across any value for the src region2 itself.  */
-  svalue2 *sval = src_reg->get_value (*this, true, ctxt);
+  const svalue2 *sval = src_reg->get_value (*this, true, ctxt);
   set_value (dst_reg, sid, ctxt);
 
   if (dst_reg->get_kind () != src_reg->get_kind ())
@@ -1620,7 +1621,7 @@ region2::get_view (tree type, region_model2 *model) const
 
 /* region2's ctor.  */
 
-region2::region2 (unsigned id, region2 *parent, tree type)
+region2::region2 (unsigned id, const region2 *parent, tree type)
 : m_id (id), m_parent (parent), m_type (type), m_cached_offset (NULL)
 {
   gcc_assert (type == NULL_TREE || TYPE_P (type));
@@ -1871,10 +1872,10 @@ frame_region2::add_to_hash (inchash::hash &hstate) const
 }
 #endif
 
-region2 *
+const region2 *
 frame_region2::get_region_for_local (region_model2_manager *mgr,
 				     tree expr,
-				     region_model2_context */*ctxt*/)
+				     region_model2_context */*ctxt*/) const
 {
   // TODO: could also check that VAR_DECLs are locals
   gcc_assert (TREE_CODE (expr) == PARM_DECL
@@ -1882,11 +1883,15 @@ frame_region2::get_region_for_local (region_model2_manager *mgr,
 	      || TREE_CODE (expr) == SSA_NAME
 	      || TREE_CODE (expr) == RESULT_DECL);
 
-  if (region2 **slot = m_locals.get (expr))
+  /* Ideally we'd use mutable here.  */
+  // TODO: when is it available?
+  map_t &mutable_locals = const_cast <map_t &> (m_locals);
+
+  if (region2 **slot = mutable_locals.get (expr))
     return *slot;
   decl_region2 *reg
     = new decl_region2 (mgr->alloc_region_id (), this, expr);
-  m_locals.put (expr, reg);
+  mutable_locals.put (expr, reg);
   return reg;
 }
 
@@ -2136,7 +2141,7 @@ stack_region2::get_value_by_name (tree identifier,
   FOR_EACH_VEC_ELT (m_frame_regs, i, frame_reg)
     {
       frame_region2 *frame = model.get_region2<frame_region2> (*frame_reg);
-      svalue2 *sval = frame->get_value_by_name (identifier, model);
+      const svalue2 *sval = frame->get_value_by_name (identifier, model);
       if (!sid.null_p ())
 	return sid;
     }
@@ -2473,13 +2478,13 @@ root_region2::get_value_by_name (tree identifier,
 {
   if (stack_region2 *stack = get_stack_region2 (&model))
     {
-      svalue2 *sval = stack->get_value_by_name (identifier, model);
+      const svalue2 *sval = stack->get_value_by_name (identifier, model);
       if (!sid.null_p ())
 	return sid;
     }
   if (map_region2 *globals = get_globals_region2 (&model))
     {
-      svalue2 *sval = globals->get_value_by_name (identifier, model);
+      const svalue2 *sval = globals->get_value_by_name (identifier, model);
       if (!sid.null_p ())
 	return sid;
     }
@@ -2784,7 +2789,7 @@ region_model2_manager::~region_model2_manager ()
    creating the constant_svalue2 if necessary.
    The constant_svalue2 instances are reused, based on pointer equality
    of trees  */
-svalue2 *
+const svalue2 *
 region_model2_manager::get_or_create_constant_svalue2 (tree cst_expr)
 {
   gcc_assert (cst_expr);
@@ -2798,7 +2803,7 @@ region_model2_manager::get_or_create_constant_svalue2 (tree cst_expr)
   // TODO: cst equality vs tree pointer equality?
 }
 
-svalue2 *
+const svalue2 *
 region_model2_manager::get_or_create_initial_value (const region2 *reg)
 {
   if (initial_svalue2 **slot = m_initial_values_map.get (reg))
@@ -2808,12 +2813,12 @@ region_model2_manager::get_or_create_initial_value (const region2 *reg)
   return initial_sval;
 }
 
-svalue2 *
-region_model2_manager::get_ptr_svalue2 (tree ptr_type, region2 *pointee)
+const svalue2 *
+region_model2_manager::get_ptr_svalue2 (tree ptr_type, const region2 *pointee)
 {
   /* If this is a symbolic region from dereferencing a pointer, and the types
      match, then return the original pointer.  */
-  if (symbolic_region2 *sym_reg = pointee->dyn_cast_symbolic_region2 ())
+  if (const symbolic_region2 *sym_reg = pointee->dyn_cast_symbolic_region2 ())
     if (ptr_type == sym_reg->get_pointer ()->get_type ())
       return sym_reg->get_pointer ();
 
@@ -2825,9 +2830,9 @@ region_model2_manager::get_ptr_svalue2 (tree ptr_type, region2 *pointee)
   return sval;
 }
 
-svalue2 *
+const svalue2 *
 region_model2_manager::maybe_fold_unaryop (tree type, enum tree_code op,
-					   svalue2 *arg)
+					   const svalue2 *arg)
 {
   /* Constants.  */
   if (tree cst = arg->maybe_get_constant ())
@@ -2836,11 +2841,11 @@ region_model2_manager::maybe_fold_unaryop (tree type, enum tree_code op,
   return NULL;
 }
 
-svalue2 *
+const svalue2 *
 region_model2_manager::get_or_create_unaryop (tree type, enum tree_code op,
-					      svalue2 *arg)
+					      const svalue2 *arg)
 {
-  if (svalue2 *folded = maybe_fold_unaryop  (type, op, arg))
+  if (const svalue2 *folded = maybe_fold_unaryop  (type, op, arg))
     return folded;
   unaryop_svalue2::key_t key (type, op, arg);
   if (unaryop_svalue2 **slot = m_unaryop_values_map.get (key))
@@ -2850,9 +2855,9 @@ region_model2_manager::get_or_create_unaryop (tree type, enum tree_code op,
   return unaryop_sval;
 }
 
-svalue2 *
+const svalue2 *
 region_model2_manager::maybe_fold_binop (tree type, enum tree_code op,
-					 svalue2 *arg0, svalue2 *arg1)
+					 const svalue2 *arg0, const svalue2 *arg1)
 {
   tree cst0 = arg0->maybe_get_constant ();
   tree cst1 = arg1->maybe_get_constant ();
@@ -2896,11 +2901,11 @@ region_model2_manager::maybe_fold_binop (tree type, enum tree_code op,
   return NULL;
 }
 
-svalue2 *
+const svalue2 *
 region_model2_manager::get_or_create_binop (tree type, enum tree_code op,
-					    svalue2 *arg0, svalue2 *arg1)
+					    const svalue2 *arg0, const svalue2 *arg1)
 {
-  if (svalue2 *folded = maybe_fold_binop (type, op, arg0, arg1))
+  if (const svalue2 *folded = maybe_fold_binop (type, op, arg0, arg1))
     return folded;
   binop_svalue2::key_t key (type, op, arg0, arg1);
   if (binop_svalue2 **slot = m_binop_values_map.get (key))
@@ -2914,7 +2919,7 @@ region_model2_manager::get_or_create_binop (tree type, enum tree_code op,
 
 /* FIXME.  */
 
-function_region2 *
+const function_region2 *
 region_model2_manager::get_region_for_fndecl (tree fndecl,
 					      region_model2_context */*ctxt*/)
 {
@@ -2931,7 +2936,7 @@ region_model2_manager::get_region_for_fndecl (tree fndecl,
 
 /* FIXME.  */
 
-label_region2 *
+const label_region2 *
 region_model2_manager::get_region_for_label (tree label,
 					     region_model2_context *ctxt)
 {
@@ -2944,7 +2949,7 @@ region_model2_manager::get_region_for_label (tree label,
   tree fndecl = DECL_CONTEXT (label);
   gcc_assert (fndecl && TREE_CODE (fndecl) == FUNCTION_DECL);
 
-  function_region2 *func_reg = get_region_for_fndecl (fndecl, ctxt);
+  const function_region2 *func_reg = get_region_for_fndecl (fndecl, ctxt);
   label_region2 *reg
     = new label_region2 (alloc_region_id (), func_reg, label);
   m_labels_map.put (label, reg);
@@ -2953,7 +2958,7 @@ region_model2_manager::get_region_for_label (tree label,
 
 /* FIXME.  */
 
-decl_region2 *
+const decl_region2 *
 region_model2_manager::get_region_for_global (tree expr,
 					      region_model2_context */*ctxt*/)
 {
@@ -2970,8 +2975,8 @@ region_model2_manager::get_region_for_global (tree expr,
 
 /* FIXME.  */
 
-region2 *
-region_model2_manager::get_field_region (region2 *parent, tree field,
+const region2 *
+region_model2_manager::get_field_region (const region2 *parent, tree field,
 					 region_model2_context */*ctxt*/)
 {
   // FIXME: should only alloc_region_id if consolidation fails
@@ -2981,10 +2986,10 @@ region_model2_manager::get_field_region (region2 *parent, tree field,
 
 /* FIXME.  */
 
-region2 *
-region_model2_manager::get_element_region (region2 *parent,
+const region2 *
+region_model2_manager::get_element_region (const region2 *parent,
 					   tree element_type,
-					   svalue2 *index,
+					   const svalue2 *index,
 					   region_model2_context */*ctxt*/)
 {
   // FIXME: should only alloc_region_id if consolidation fails
@@ -2995,10 +3000,10 @@ region_model2_manager::get_element_region (region2 *parent,
 
 /* FIXME.  */
 
-region2 *
-region_model2_manager::get_offset_region (region2 *parent,
+const region2 *
+region_model2_manager::get_offset_region (const region2 *parent,
 					  tree type,
-					  svalue2 *byte_offset,
+					  const svalue2 *byte_offset,
 					  region_model2_context */*ctxt*/)
 {
   /* If BYTE_OFFSET is zero and the types match, return PARENT.  */
@@ -3014,8 +3019,8 @@ region_model2_manager::get_offset_region (region2 *parent,
 
 /* FIXME.  */
 
-frame_region2 *
-region_model2_manager::get_frame_region (frame_region2 *calling_frame,
+const frame_region2 *
+region_model2_manager::get_frame_region (const frame_region2 *calling_frame,
 					 function *fun)
 {
   int index = calling_frame ? calling_frame->get_index () + 1 : 0;
@@ -3028,8 +3033,8 @@ region_model2_manager::get_frame_region (frame_region2 *calling_frame,
 
 /* FIXME.  */
 
-region2 *
-region_model2_manager::get_symbolic_region (svalue2 *sval)
+const region2 *
+region_model2_manager::get_symbolic_region (const svalue2 *sval)
 {
   // FIXME: should only alloc_region_id if consolidation fails
   region2 *reg
@@ -3039,7 +3044,7 @@ region_model2_manager::get_symbolic_region (svalue2 *sval)
 
 /* FIXME.  */
 
-string_region2 *
+const string_region2 *
 region_model2_manager::get_region_for_string (tree string_cst)
 {
   gcc_assert (TREE_CODE (string_cst) == STRING_CST);
@@ -3061,7 +3066,7 @@ region_model2_manager::get_region_for_string (tree string_cst)
    since any diagnostics we might issue will have questionable
    validity.  */
 
-region2 *
+const region2 *
 region_model2_manager::
 get_region2_for_unexpected_tree_code (region_model2_context *ctxt,
 				      tree t,
@@ -3078,7 +3083,7 @@ get_region2_for_unexpected_tree_code (region_model2_context *ctxt,
 
 /* FIXME.  */
 
-region2 *
+const region2 *
 region_model2_manager::create_region_for_heap_alloc ()
 {
   // FIXME: should this be a symbolic region??
@@ -3093,8 +3098,8 @@ region_model2_manager::create_region_for_heap_alloc ()
 
 /* FIXME.  */
 
-region2 *
-region_model2_manager::create_region_for_alloca (frame_region2 *frame)
+const region2 *
+region_model2_manager::create_region_for_alloca (const frame_region2 *frame)
 {
   region2 *reg = new alloca_region2 (alloc_region_id (), frame);
   m_managed_dynamic_regions.safe_push (reg);
@@ -3137,7 +3142,7 @@ region_model2 &
 region_model2::operator= (const region_model2 &other)
 {
   unsigned i;
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   region2 *region2;
 
   /* Delete existing content.  */
@@ -3205,7 +3210,7 @@ region_model2::hash () const
   hashval_t result = 0;
   int i;
 
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   FOR_EACH_VEC_ELT (m_svalue2s, i, svalue2)
     result ^= svalue2->hash ();
 
@@ -3227,7 +3232,7 @@ region_model2::print (pretty_printer *pp) const
   int i;
 
   pp_string (pp, "svalue2s: [");
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   FOR_EACH_VEC_ELT (m_svalue2s, i, svalue2)
     {
       if (i > 0)
@@ -3253,7 +3258,7 @@ region_model2::print (pretty_printer *pp) const
 /* Print the svalue2 with id SID to PP.  */
 
 void
-region_model2::print_svalue2 (svalue2 *sval, pretty_printer *pp) const
+region_model2::print_svalue2 (const svalue2 *sval, pretty_printer *pp) const
 {
   get_svalue2 (sid)->print (*this, sid, pp);
 }
@@ -3278,7 +3283,7 @@ region_model2::dump_dot_to_pp (pretty_printer *pp) const
 
   int i;
 
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   FOR_EACH_VEC_ELT (m_svalue2s, i, svalue2)
     svalue2->dump_dot_to_pp (*this, svalue2_id::from_int (i), pp);
 
@@ -3333,7 +3338,7 @@ region_model2::dump_to_pp (pretty_printer *pp, bool summarize) const
   /* Dump stack.  */
   pp_printf (pp, "stack depth: %i", get_stack_depth ());
   pp_newline (pp);
-  for (frame_region2 *iter_frame = m_current_frame; iter_frame;
+  for (const frame_region2 *iter_frame = m_current_frame; iter_frame;
        iter_frame = iter_frame->get_calling_frame ())
     {
       pp_printf (pp, "  frame (index %i): ", iter_frame->get_index ());
@@ -3356,7 +3361,7 @@ region_model2::dump_to_pp (pretty_printer *pp, bool summarize) const
       if (iter != m_store_map.begin ())
 	pp_string (pp, ", ");
       region2 *reg = (*iter).first;
-      svalue2 *sval = (*iter).second;
+      const svalue2 *sval = (*iter).second;
       reg->dump_to_pp (pp, summarize);
       pp_string (pp, ": ");
       sval->dump_to_pp (pp, summarize);
@@ -3436,11 +3441,11 @@ region_model2::dump_to_pp (pretty_printer *pp, bool summarize) const
   pp_string (pp, "svalue2s:");
   pp_newline (pp);
   int i;
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   FOR_EACH_VEC_ELT (m_svalue2s, i, svalue2)
     {
       pp_string (pp, "  ");
-      svalue2 *sval = svalue2_id::from_int (i);
+      const svalue2 *sval = svalue2_id::from_int (i);
       print_svalue2 (sid, pp);
       pp_newline (pp);
     }
@@ -3531,17 +3536,18 @@ region_model2::dump_summary_of_rep_path_vars (pretty_printer *pp,
       region2 *child_region2 = get_region2 (child_reg);
       if (!child_region2)
 	continue;
-      svalue2 *sval = child_region2->get_value_direct ();
+      const svalue2 *sval = child_region2->get_value_direct ();
       if (sid.null_p ())
 	continue;
-      svalue2 *sval = get_svalue2 (sid);
+      const svalue2 *sval = get_svalue2 (sid);
       switch (sval->get_kind ())
 	{
 	default:
 	  gcc_unreachable ();
 	case SK_REGION2:
 	  {
-	    region_svalue2 *region2_sval = as_a <region_svalue2 *> (sval);
+	    const region_svalue2 *region2_sval
+	      = as_a <const region_svalue2 *> (sval);
 	    region2_id pointee_reg = region2_sval->get_pointee ();
 	    gcc_assert (!pointee_reg.null_p ());
 	    tree pointee = get_representative_path_var (pointee_reg).m_tree;
@@ -3566,7 +3572,8 @@ region_model2::dump_summary_of_rep_path_vars (pretty_printer *pp,
 	  break;
 	case SK_POISONED:
 	  {
-	    poisoned_svalue2 *poisoned_sval = as_a <poisoned_svalue2 *> (sval);
+	    const poisoned_svalue2 *poisoned_sval
+	      = as_a <const poisoned_svalue2 *> (sval);
 	    enum poison_kind pkind = poisoned_sval->get_poison_kind ();
 	    if (pkind == POISON_KIND_UNINIT)
 	      uninit_trees.safe_push (pv->m_tree);
@@ -3618,7 +3625,7 @@ region_model2::validate () const
   if (stack_region2)
     {
       svalue2_id stack_value_sval = stack_region2->get_value_direct ();
-      svalue2 *stack_value = get_svalue2 (stack_value_sval);
+      const svalue2 *stack_value = get_svalue2 (stack_value_sval);
       gcc_assert (stack_value->get_kind () == SK_POISONED);
       poisoned_svalue2 *subclass = stack_value->dyn_cast_poisoned_svalue2 ();
       gcc_assert (subclass);
@@ -3679,7 +3686,7 @@ region_model2::on_gassign (const supernode */*snode*/,
   tree lhs = gimple_assign_lhs (assign);
   tree rhs1 = gimple_assign_rhs1 (assign);
 
-  region2 *lhs_reg = get_lvalue (lhs, ctxt);
+  const region2 *lhs_reg = get_lvalue (lhs, ctxt);
 
   enum tree_code op = gimple_assign_rhs_code (assign);
   switch (op)
@@ -3722,10 +3729,10 @@ region_model2::on_gassign (const supernode */*snode*/,
 	tree ptr = rhs1;
 	tree offset = gimple_assign_rhs2 (assign);
 
-	svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
-	svalue2 *offset_sval = get_rvalue (offset, ctxt);
+	const svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
+	const svalue2 *offset_sval = get_rvalue (offset, ctxt);
 
-	svalue2 *sval_binop
+	const svalue2 *sval_binop
 	      = m_mgr->get_or_create_binop (TREE_TYPE (lhs), op,
 					    ptr_sval, offset_sval);
 	set_value (lhs_reg, sval_binop, ctxt);
@@ -3734,7 +3741,7 @@ region_model2::on_gassign (const supernode */*snode*/,
 	  = get_or_create_pointer_plus_expr (TREE_TYPE (TREE_TYPE (ptr)),
 					     ptr_sval, offset_sval,
 					     ctxt);
-	svalue2 *element_ptr_sval
+	const svalue2 *element_ptr_sval
 	  = get_or_create_ptr_svalue2 (TREE_TYPE (ptr), element_reg);
 	set_value (lhs_reg, element_ptr_sval, ctxt);
 #endif
@@ -3767,7 +3774,7 @@ region_model2::on_gassign (const supernode */*snode*/,
     case VAR_DECL: /* LHS = VAR; */
     case PARM_DECL:/* LHS = VAR; */
       {
-	svalue2 *rhs_sval = get_rvalue (rhs1, ctxt);
+	const svalue2 *rhs_sval = get_rvalue (rhs1, ctxt);
 	set_value (lhs_reg, rhs_sval, ctxt);
       }
       break;
@@ -3777,8 +3784,8 @@ region_model2::on_gassign (const supernode */*snode*/,
     case FLOAT_EXPR:
     case NOP_EXPR:
       {
-	svalue2 *rhs_sval = get_rvalue (rhs1, ctxt);
-	svalue2 *sval_unaryop
+	const svalue2 *rhs_sval = get_rvalue (rhs1, ctxt);
+	const svalue2 *sval_unaryop
 	  = m_mgr->get_or_create_unaryop (TREE_TYPE (lhs), op, rhs_sval);
 	set_value (lhs_reg, sval_unaryop, ctxt);
       }
@@ -3794,8 +3801,8 @@ region_model2::on_gassign (const supernode */*snode*/,
 	tree rhs2 = gimple_assign_rhs2 (assign);
 
 	// TODO: constraints between svalue2s
-	svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
-	svalue2 *rhs2_sval = get_rvalue (rhs2, ctxt);
+	const svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
+	const svalue2 *rhs2_sval = get_rvalue (rhs2, ctxt);
 
 	tristate t = eval_condition (rhs1_sval, op, rhs2_sval);
 	if (t.is_known ())
@@ -3808,7 +3815,7 @@ region_model2::on_gassign (const supernode */*snode*/,
 	else
 	  {
 	    // TODO: symbolic value for binop
-	    svalue2 *sval_binop
+	    const svalue2 *sval_binop
 	      = m_mgr->get_or_create_binop (TREE_TYPE (lhs), op,
 					    rhs1_sval, rhs2_sval);
 	    set_value (lhs_reg, sval_binop, ctxt);
@@ -3820,8 +3827,8 @@ region_model2::on_gassign (const supernode */*snode*/,
     case BIT_NOT_EXPR:
       {
 	/* Unary ops.  */
-	svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
-	svalue2 *sval_unaryop
+	const svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
+	const svalue2 *sval_unaryop
 	  = m_mgr->get_or_create_unaryop (TREE_TYPE (lhs), op,
 					rhs1_sval);
 	set_value (lhs_reg, sval_unaryop, ctxt);
@@ -3844,10 +3851,10 @@ region_model2::on_gassign (const supernode */*snode*/,
 	/* Binary ops.  */
 	tree rhs2 = gimple_assign_rhs2 (assign);
 
-	svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
-	svalue2 *rhs2_sval = get_rvalue (rhs2, ctxt);
+	const svalue2 *rhs1_sval = get_rvalue (rhs1, ctxt);
+	const svalue2 *rhs2_sval = get_rvalue (rhs2, ctxt);
 
-	svalue2 *sval_binop
+	const svalue2 *sval_binop
 	  = m_mgr->get_or_create_binop (TREE_TYPE (lhs), op,
 					rhs1_sval, rhs2_sval);
 	set_value (lhs_reg, sval_binop, ctxt);
@@ -3906,11 +3913,11 @@ region_model2::on_gcall (const supernode *snode,
       if (is_named_call_p (callee_fndecl, "malloc", call, 1))
 	{
 	  tree size_arg = gimple_call_arg (call, 0);
-	  svalue2 *size_sval = get_rvalue (size_arg, ctxt);
+	  const svalue2 *size_sval = get_rvalue (size_arg, ctxt);
 	  region2 *new_reg = create_region_for_heap_alloc (size_sval);
 	  if (lhs_reg)
 	    {
-	      svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
+	      const svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
 	      set_value (lhs_reg, ptr_sval, ctxt);
 	    }
 	  else
@@ -3922,11 +3929,11 @@ region_model2::on_gcall (const supernode *snode,
       else if (is_named_call_p (callee_fndecl, "__builtin_alloca", call, 1))
 	{
 	  tree size_arg = gimple_call_arg (call, 0);
-	  svalue2 *size_sval = get_rvalue (size_arg, ctxt);
+	  const svalue2 *size_sval = get_rvalue (size_arg, ctxt);
 	  region2 *new_reg = create_region_for_alloca (size_sval);
 	  if (lhs_reg)
 	    {
-	      svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
+	      const svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
 	      set_value (lhs_reg, ptr_sval, ctxt);
 	    }
 	  return true;
@@ -3934,7 +3941,7 @@ region_model2::on_gcall (const supernode *snode,
       else if (is_named_call_p (callee_fndecl, "strlen", call, 1))
 	{
 	  tree arg = gimple_call_arg (call, 0);
-	  svalue2 *arg_sval = get_rvalue (arg, ctxt);
+	  const svalue2 *arg_sval = get_rvalue (arg, ctxt);
 	  region2 *buf_reg = deref_rvalue (arg_sval, ctxt);
 	  if (string_region2 *str_reg = buf_reg->dyn_cast_string_region2 ())
 	    {
@@ -3943,7 +3950,7 @@ region_model2::on_gcall (const supernode *snode,
 	      int sizeof_cst = TREE_STRING_LENGTH (str_cst);
 	      int strlen_cst = sizeof_cst - 1;
 	      tree t_cst = build_int_cst (lhs_type, strlen_cst);
-	      svalue2 *result_sval
+	      const svalue2 *result_sval
 		= m_mgr->get_or_create_constant_svalue2 (t_cst);
 	      set_value (lhs_reg, result_sval, ctxt);
 	      return true;
@@ -3980,7 +3987,7 @@ region_model2::on_gcall (const supernode *snode,
 bool
 region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
 {
-  region2 *lhs_reg;
+  const region2 *lhs_reg;
   tree lhs_type = NULL_TREE;
   if (tree lhs = gimple_call_lhs (call))
     {
@@ -4002,7 +4009,7 @@ region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
   if (tree callee_fndecl = get_fndecl_for_call (call, ctxt))
     {
       /* Get any left-hand side for the destination of the result.  */
-      region2 *lhs_reg = NULL;
+      const region2 *lhs_reg = NULL;
       tree lhs_type = NULL_TREE;
       if (tree lhs = gimple_call_lhs (call))
 	{
@@ -4013,11 +4020,11 @@ region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
       if (is_named_call_p (callee_fndecl, "malloc", call, 1))
 	{
 	  tree size_arg = gimple_call_arg (call, 0);
-	  svalue2 *size_sval = get_rvalue (size_arg, ctxt);
-	  region2 *new_reg = create_region_for_heap_alloc (size_sval);
+	  const svalue2 *size_sval = get_rvalue (size_arg, ctxt);
+	  const region2 *new_reg = create_region_for_heap_alloc (size_sval);
 	  if (lhs_reg)
 	    {
-	      svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
+	      const svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
 	      set_value (lhs_reg, ptr_sval, ctxt);
 	    }
 	  else
@@ -4029,11 +4036,11 @@ region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
       else if (is_named_call_p (callee_fndecl, "__builtin_alloca", call, 1))
 	{
 	  tree size_arg = gimple_call_arg (call, 0);
-	  svalue2 *size_sval = get_rvalue (size_arg, ctxt);
-	  region2 *new_reg = create_region_for_alloca (size_sval);
+	  const svalue2 *size_sval = get_rvalue (size_arg, ctxt);
+	  const region2 *new_reg = create_region_for_alloca (size_sval);
 	  if (lhs_reg)
 	    {
-	      svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
+	      const svalue2 *ptr_sval = m_mgr->get_ptr_svalue2 (lhs_type, new_reg);
 	      set_value (lhs_reg, ptr_sval, ctxt);
 	    }
 	  return true;
@@ -4046,7 +4053,7 @@ region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
 	  if (lhs_reg)
 	    {
 	      tree initial_arg = gimple_call_arg (call, 0);
-	      svalue2 *sval = get_rvalue (initial_arg, ctxt);
+	      const svalue2 *sval = get_rvalue (initial_arg, ctxt);
 	      set_value (lhs_reg, sval, ctxt);
 	    }
 	  return false;
@@ -4054,16 +4061,17 @@ region_model2::on_call_pre (const gcall *call, region_model2_context *ctxt)
       else if (is_named_call_p (callee_fndecl, "strlen", call, 1))
 	{
 	  tree arg = gimple_call_arg (call, 0);
-	  svalue2 *arg_sval = get_rvalue (arg, ctxt);
-	  region2 *buf_reg = deref_rvalue (arg_sval, ctxt);
-	  if (string_region2 *str_reg = buf_reg->dyn_cast_string_region2 ())
+	  const svalue2 *arg_sval = get_rvalue (arg, ctxt);
+	  const region2 *buf_reg = deref_rvalue (arg_sval, ctxt);
+	  if (const string_region2 *str_reg
+		= buf_reg->dyn_cast_string_region2 ())
 	    {
 	      tree str_cst = str_reg->get_string_cst ();
 	      /* TREE_STRING_LENGTH is sizeof, not strlen.  */
 	      int sizeof_cst = TREE_STRING_LENGTH (str_cst);
 	      int strlen_cst = sizeof_cst - 1;
 	      tree t_cst = build_int_cst (lhs_type, strlen_cst);
-	      svalue2 *result_sval
+	      const svalue2 *result_sval
 		= m_mgr->get_or_create_constant_svalue2 (t_cst);
 	      set_value (lhs_reg, result_sval, ctxt);
 	      return true;
@@ -4141,8 +4149,8 @@ region_model2::on_call_post (const gcall *call,
     if (is_named_call_p (callee_fndecl, "free", call, 1))
       {
 	tree ptr = gimple_call_arg (call, 0);
-	svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
-	if (region_svalue2 *ptr_to_region2_sval
+	const svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
+	if (region_const svalue2 *ptr_to_region2_sval
 	    = ptr_sval->dyn_cast_region_svalue2 ())
 	  {
 	    /* If the ptr points to an underlying heap region2, delete it,
@@ -4231,18 +4239,18 @@ public:
       bind_cluster->for_each_value (handle_sval_cb, this);
   }
 
-  static void handle_sval_cb (svalue2 *sval, reachable_region2s *this_ptr)
+  static void handle_sval_cb (const svalue2 *sval, reachable_region2s *this_ptr)
   {
     this_ptr->handle_sval (sval);
   }
 
   /* If SVAL is a pointer, add the pointee.  */
 
-  void handle_sval (svalue2 *sval)
+  void handle_sval (const svalue2 *sval)
   {
-    if (region_svalue2 *ptr = sval->dyn_cast_region_svalue2 ())
+    if (const region_svalue2 *ptr = sval->dyn_cast_region_svalue2 ())
       {
-	region2 *pointee = ptr->get_pointee ();
+	const region2 *pointee = ptr->get_pointee ();
 	/* Use const-ness of pointer type to affect mutability.  */
 	bool ptr_is_mutable = true;
 	if (ptr->get_type ()
@@ -4346,10 +4354,11 @@ region_model2::handle_unrecognized_call (const gcall *call,
 	  }
 
 	tree parm = gimple_call_arg (call, arg_idx);
-	svalue2 *parm_sval = get_rvalue (parm, ctxt);
-	if (region_svalue2 *parm_ptr = parm_sval->dyn_cast_region_svalue2 ())
+	const svalue2 *parm_sval = get_rvalue (parm, ctxt);
+	if (const region_svalue2 *parm_ptr
+	      = parm_sval->dyn_cast_region_svalue2 ())
 	  {
-	    region2 *pointee_reg = parm_ptr->get_pointee ();
+	    const region2 *pointee_reg = parm_ptr->get_pointee ();
 	    bool is_mutable = true;
 	    if (param_type
 		&& TREE_CODE (param_type) == POINTER_TYPE
@@ -4374,9 +4383,9 @@ region_model2::handle_unrecognized_call (const gcall *call,
      "foo *" svalue2 was reachable.  If we don't purge it, the temporary will
      be reported as a leak.  */
   int i;
-  svalue2 *svalue2;
+  const svalue2 *svalue2;
   FOR_EACH_VEC_ELT (m_svalue2s, i, svalue2)
-    if (region_svalue2 *ptr = svalue2->dyn_cast_region_svalue2 ())
+    if (region_const svalue2 *ptr = svalue2->dyn_cast_region_svalue2 ())
       {
 	region2 *pointee_reg = ptr->get_pointee ();
 	if (reachable_region2s.mutable_p (pointee_reg))
@@ -4423,8 +4432,8 @@ region_model2::on_setjmp (const gcall *call, const exploded_node *enode,
   if (buf)
     {
       setjmp_record r (enode, call);
-      svalue2 *sval = new setjmp_svalue2 (r, buf->get_type ());
-      svalue2 *new_sval = add_svalue2 (sval);
+      const svalue2 *sval = new setjmp_svalue2 (r, buf->get_type ());
+      const svalue2 *new_sval = add_svalue2 (sval);
       set_value (buf_reg, new_sval, ctxt);
     }
 
@@ -4432,7 +4441,7 @@ region_model2::on_setjmp (const gcall *call, const exploded_node *enode,
   if (tree lhs = gimple_call_lhs (call))
     {
       tree zero = build_int_cst (TREE_TYPE (lhs), 0);
-      svalue2 *new_sval = get_or_create_constant_svalue2 (zero);
+      const svalue2 *new_sval = get_or_create_constant_svalue2 (zero);
       region2 *lhs_reg = get_lvalue (lhs, ctxt);
       set_value (lhs_reg, new_sval, ctxt);
     }
@@ -4450,7 +4459,7 @@ region_model2::on_longjmp (const gcall *longjmp_call, const gcall *setjmp_call,
 {
   /* Evaluate the val, using the frame of the "longjmp".  */
   tree fake_retval = gimple_call_arg (longjmp_call, 1);
-  svalue2 *fake_retval_sval = get_rvalue (fake_retval, ctxt);
+  const svalue2 *fake_retval_sval = get_rvalue (fake_retval, ctxt);
 
   /* Pop any frames until we reach the stack depth of the function where
      setjmp was called.  */
@@ -4468,13 +4477,13 @@ region_model2::on_longjmp (const gcall *longjmp_call, const gcall *setjmp_call,
     {
       /* Passing 0 as the val to longjmp leads to setjmp returning 1.  */
       tree t_zero = build_int_cst (TREE_TYPE (fake_retval), 0);
-      svalue2 *zero_sval = get_or_create_constant_svalue2 (t_zero);
+      const svalue2 *zero_sval = get_or_create_constant_svalue2 (t_zero);
       tristate eq_zero = eval_condition (fake_retval_sval, EQ_EXPR, zero_sval);
       /* If we have 0, use 1.  */
       if (eq_zero.is_true ())
 	{
 	  tree t_one = build_int_cst (TREE_TYPE (fake_retval), 1);
-	  svalue2 *one_sval = get_or_create_constant_svalue2 (t_one);
+	  const svalue2 *one_sval = get_or_create_constant_svalue2 (t_one);
 	  fake_retval_sval = one_sval;
 	}
       else
@@ -4508,7 +4517,7 @@ region_model2::handle_phi (const gphi *phi,
       if (VAR_DECL_IS_VIRTUAL_OPERAND (var))
 	return;
 
-  svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
+  const svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
 
   if (is_back_edge && rhs_sval->get_kind () != svalue2::SK_UNKNOWN)
     {
@@ -4538,7 +4547,8 @@ region_model2::handle_phi (const gphi *phi,
 
    Get the id of the region2 for PV within this region_model2,
    emitting any diagnostics to CTXT.  */
-region2 *
+
+const region2 *
 region_model2::get_lvalue_1 (path_var pv,
 			     region_model2_context *ctxt)
 {
@@ -4567,13 +4577,13 @@ region_model2::get_lvalue_1 (path_var pv,
 	gcc_assert (TREE_OPERAND (expr, 3) == NULL_TREE);
 #endif
 
-	region2 *array_reg = get_lvalue (array, ctxt);
-	svalue2 *index_sval = get_rvalue (index, ctxt);
+	const region2 *array_reg = get_lvalue (array, ctxt);
+	const svalue2 *index_sval = get_rvalue (index, ctxt);
 	return m_mgr->get_element_region (array_reg,
 					  TREE_TYPE (TREE_TYPE (array)),
 					  index_sval, ctxt);
 #if 0
-	region2 *base_array_reg = get_region2 (array_reg);
+	const region2 *base_array_reg = get_region2 (array_reg);
 	array_region2 *array_reg  = base_array_reg->dyn_cast_array_region2 ();
 	if (!array_reg)
 	  {
@@ -4604,9 +4614,9 @@ region_model2::get_lvalue_1 (path_var pv,
       {
 	tree ptr = TREE_OPERAND (expr, 0);
 	tree offset = TREE_OPERAND (expr, 1);
-	svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
-	svalue2 *offset_sval = get_rvalue (offset, ctxt);
-	region2 *star_ptr = deref_rvalue (ptr_sval, ctxt);
+	const svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
+	const svalue2 *offset_sval = get_rvalue (offset, ctxt);
+	const region2 *star_ptr = deref_rvalue (ptr_sval, ctxt);
 	return m_mgr->get_offset_region (star_ptr,
 					 TREE_TYPE (TREE_TYPE (ptr)),
 					 offset_sval, ctxt);
@@ -4638,7 +4648,7 @@ region_model2::get_lvalue_1 (path_var pv,
 		    || TREE_CODE (expr) == RESULT_DECL);
 
 	int stack_index = pv.m_stack_depth;
-	frame_region2 *frame = get_frame_at_index (stack_index);
+	const frame_region2 *frame = get_frame_at_index (stack_index);
 	gcc_assert (frame);
 	return frame->get_region_for_local (m_mgr, expr, ctxt);
       }
@@ -4656,7 +4666,7 @@ region_model2::get_lvalue_1 (path_var pv,
 	  return make_region2_for_unexpected_tree_code (ctxt, obj_type,
 						       dump_location_t ());
 #endif
-	region2 *obj_reg = get_lvalue (obj, ctxt);
+	const region2 *obj_reg = get_lvalue (obj, ctxt);
 	return m_mgr->get_field_region (obj_reg, field, ctxt);
       }
       break;
@@ -4664,10 +4674,11 @@ region_model2::get_lvalue_1 (path_var pv,
     case CONST_DECL:
       {
 	tree cst_type = TREE_TYPE (expr);
-	region2 *cst_reg = add_region2_for_type (m_root_reg, cst_type, ctxt);
+	const region2 *cst_reg
+	  = add_region2_for_type (m_root_reg, cst_type, ctxt);
 	if (tree value = DECL_INITIAL (expr))
 	  {
-	    svalue2 *sval = get_rvalue (value, ctxt);
+	    const svalue2 *sval = get_rvalue (value, ctxt);
 	    get_region2 (cst_reg)->set_value (*this, cst_reg, sid, ctxt);
 	  }
 	return cst_reg;
@@ -4700,25 +4711,25 @@ assert_compat_types (tree src_type, tree dst_type)
     gcc_checking_assert (useless_type_conversion_p (src_type, dst_type));
 }
 
-/* Get the id of the region2 for PV within this region_model2,
+/* Get the region2 for PV within this region_model2,
    emitting any diagnostics to CTXT.  */
 
-region2 *
+const region2 *
 region_model2::get_lvalue (path_var pv,
 			   region_model2_context *ctxt)
 {
   if (pv.m_tree == NULL_TREE)
     return NULL;
 
-  region2 *result_reg = get_lvalue_1 (pv, ctxt);
+  const region2 *result_reg = get_lvalue_1 (pv, ctxt);
   assert_compat_types (result_reg->get_type (), TREE_TYPE (pv.m_tree));
   return result_reg;
 }
 
-/* Get the region2 *for EXPR within this region_model2 (assuming the most
+/* Get the region2 for EXPR within this region_model2 (assuming the most
    recent stack frame if it's a local).  */
 
-region2 *
+const region2 *
 region_model2::get_lvalue (tree expr,
 			   region_model2_context *ctxt)
 {
@@ -4730,7 +4741,7 @@ region_model2::get_lvalue (tree expr,
    Get the value of PV within this region_model2,
    emitting any diagnostics to CTXT.  */
 
-svalue2 *
+const svalue2 *
 region_model2::get_rvalue_1 (path_var pv,
 			     region_model2_context *ctxt)
 {
@@ -4742,7 +4753,7 @@ region_model2::get_rvalue_1 (path_var pv,
       {
 	gcc_unreachable ();
 #if 0
-	svalue2 *unknown_sval = new unknown_svalue2 (TREE_TYPE (pv.m_tree));
+	const svalue2 *unknown_sval = new unknown_svalue2 (TREE_TYPE (pv.m_tree));
 	return add_svalue2 (unknown_sval);
 #endif
       }
@@ -4759,7 +4770,7 @@ region_model2::get_rvalue_1 (path_var pv,
 	else if (TREE_CODE (op0) == LABEL_DECL)
 	  return m_mgr->get_svalue2_for_label (TREE_TYPE (expr), op0, ctxt);
 #endif
-	region2 *expr_reg = get_lvalue (op0, ctxt);
+	const region2 *expr_reg = get_lvalue (op0, ctxt);
 	return m_mgr->get_ptr_svalue2 (TREE_TYPE (expr), expr_reg);
       }
       break;
@@ -4770,7 +4781,7 @@ region_model2::get_rvalue_1 (path_var pv,
     case RESULT_DECL:
     case ARRAY_REF:
       {
-	region2 *element_reg = get_lvalue (pv, ctxt);
+	const region2 *element_reg = get_lvalue (pv, ctxt);
 	return get_store_value (element_reg);
       }
 
@@ -4784,9 +4795,9 @@ region_model2::get_rvalue_1 (path_var pv,
 	  tree expr = pv.m_tree;
 	  tree ptr = TREE_OPERAND (expr, 0);
 	  tree offset = TREE_OPERAND (expr, 1);
-	  svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
-	  svalue2 *offset_sval = get_rvalue (offset, ctxt);
-	  svalue2 *sval_binop
+	  const svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
+	  const svalue2 *offset_sval = get_rvalue (offset, ctxt);
+	  const svalue2 *sval_binop
 	    = m_mgr->get_or_create_binop (TREE_TYPE (expr), POINTER_PLUS_EXPR,
 					  ptr_sval, offset_sval);
 	  return sval_binop;
@@ -4798,9 +4809,9 @@ region_model2::get_rvalue_1 (path_var pv,
 	  tree expr = pv.m_tree;
 	  tree arg0 = TREE_OPERAND (expr, 0);
 	  tree arg1 = TREE_OPERAND (expr, 1);
-	  svalue2 *arg0_sval = get_rvalue (arg0, ctxt);
-	  svalue2 *arg1_sval = get_rvalue (arg1, ctxt);
-	  svalue2 *sval_binop
+	  const svalue2 *arg0_sval = get_rvalue (arg0, ctxt);
+	  const svalue2 *arg1_sval = get_rvalue (arg1, ctxt);
+	  const svalue2 *sval_binop
 	    = m_mgr->get_or_create_binop (TREE_TYPE (expr), TREE_CODE (expr),
 					  arg0_sval, arg1_sval);
 	  return sval_binop;
@@ -4809,7 +4820,7 @@ region_model2::get_rvalue_1 (path_var pv,
     case COMPONENT_REF:
     case MEM_REF:
       {
-	region2 *ref_reg = get_lvalue (pv, ctxt);
+	const region2 *ref_reg = get_lvalue (pv, ctxt);
 	return get_store_value (ref_reg);
       }
     }
@@ -4818,14 +4829,14 @@ region_model2::get_rvalue_1 (path_var pv,
 /* Get the value of PV within this region_model2,
    emitting any diagnostics to CTXT.  */
 
-svalue2 *
+const svalue2 *
 region_model2::get_rvalue (path_var pv,
 			   region_model2_context *ctxt)
 {
   if (pv.m_tree == NULL_TREE)
     return NULL;
 
-  svalue2 *result_sval = get_rvalue_1 (pv, ctxt);
+  const svalue2 *result_sval = get_rvalue_1 (pv, ctxt);
 
   assert_compat_types (result_sval->get_type (), TREE_TYPE (pv.m_tree));
 
@@ -4835,7 +4846,7 @@ region_model2::get_rvalue (path_var pv,
 /* Get the value of EXPR within this region_model2 (assuming the most
    recent stack frame if it's a local).  */
 
-svalue2 *
+const svalue2 *
 region_model2::get_rvalue (tree expr,
 			   region_model2_context *ctxt)
 {
@@ -4844,19 +4855,19 @@ region_model2::get_rvalue (tree expr,
 
 /* FIXME.  */
 
-svalue2 *
-region_model2::get_store_value (region2 *reg)
+const svalue2 *
+region_model2::get_store_value (const region2 *reg)
 {
-  svalue2 *sval
+  const svalue2 *sval
     = m_store.get_direct_binding (m_mgr->get_store2_manager (), reg);
   if (sval)
     return sval;
 
   /* Special-case: read at a constant index within a STRING_CST.  */
-  if (offset_region2 *offset_reg = reg->dyn_cast_offset_region2 ())
+  if (const offset_region2 *offset_reg = reg->dyn_cast_offset_region2 ())
     if (tree byte_offset_cst
 	  = offset_reg->get_byte_offset ()->maybe_get_constant ())
-      if (string_region2 *str_reg
+      if (const string_region2 *str_reg
 	  = reg->get_parent_region ()->dyn_cast_string_region2 ())
 	{
 	  tree string_cst = str_reg->get_string_cst ();
@@ -4962,9 +4973,9 @@ build_cast (tree dst_type, tree src_expr)
    of SID as a DST_TYPE and return that value's svalue2_id.  */
 #if 0
 svalue2_id
-region_model2::maybe_cast_1 (tree dst_type, svalue2 *sval)
+region_model2::maybe_cast_1 (tree dst_type, const svalue2 *sval)
 {
-  svalue2 *sval = get_svalue2 (sid);
+  const svalue2 *sval = get_svalue2 (sid);
   tree src_type = sval->get_type ();
   if (src_type == dst_type)
     return sid;
@@ -4984,17 +4995,17 @@ region_model2::maybe_cast_1 (tree dst_type, svalue2 *sval)
 
 	  /* Look for an existing pointer of the correct type within the EC.  */
 	  int i;
-	  svalue2 **equiv_sval;
+	  const svalue2 **equiv_sval;
 	  FOR_EACH_VEC_ELT (ec.m_vars, i, equiv_sval)
 	    {
-	      svalue2 *equiv_val = get_svalue2 (*equiv_sval);
+	      const svalue2 *equiv_val = get_svalue2 (*equiv_sval);
 	      if (equiv_val->get_type () == dst_type)
 		return *equiv_sval;
 	    }
 
 	  /* Otherwise, create a new unknown pointer of the correct type.  */
-	  svalue2 *unknown_sval = new unknown_svalue2 (dst_type);
-	  svalue2 *new_ptr_sval = add_svalue2 (unknown_sval);
+	  const svalue2 *unknown_sval = new unknown_svalue2 (dst_type);
+	  const svalue2 *new_ptr_sval = add_svalue2 (unknown_sval);
 	  m_constraints->add_constraint (sid, EQ_EXPR, new_ptr_sval);
 	  return new_ptr_sval;
 	}
@@ -5009,7 +5020,7 @@ region_model2::maybe_cast_1 (tree dst_type, svalue2 *sval)
     }
 
   /* Otherwise, return a new unknown value.  */
-  svalue2 *unknown_sval = new unknown_svalue2 (dst_type);
+  const svalue2 *unknown_sval = new unknown_svalue2 (dst_type);
   return add_svalue2 (unknown_sval);
 }
 
@@ -5021,10 +5032,10 @@ region_model2::maybe_cast_1 (tree dst_type, svalue2 *sval)
    so that sm-state can be propagated from SID to the result.  */
 
 svalue2_id
-region_model2::maybe_cast (tree dst_type, svalue2 *sval,
+region_model2::maybe_cast (tree dst_type, const svalue2 *sval,
 			  region_model2_context *ctxt)
 {
-  svalue2 *result = maybe_cast_1 (dst_type, sid);
+  const svalue2 *result = maybe_cast_1 (dst_type, sid);
   if (result != sid)
     if (ctxt)
       {
@@ -5071,11 +5082,12 @@ region_model2::get_field_region (region2 *struct_or_union_reg, tree field,
 }
 #endif
 
-/* Get a region2 *for referencing PTR_SVAL, creating a region2 if need be, and
+/* Get a region2 for referencing PTR_SVAL, creating a region2 if need be, and
    potentially generating warnings via CTXT.  */
 
-region2 *
-region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
+const region2 *
+region_model2::deref_rvalue (const svalue2 *ptr_sval,
+			     region_model2_context *ctxt)
 {
   gcc_assert (ptr_sval);
 
@@ -5086,14 +5098,16 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 
     case svalue2::SK_REGION:
       {
-	region_svalue2 *region2_sval = as_a <region_svalue2 *> (ptr_sval);
+	const region_svalue2 *region2_sval
+	  = as_a <const region_svalue2 *> (ptr_sval);
 	return region2_sval->get_pointee ();
       }
 
     case svalue2::SK_BINOP:
 #if 1
       {
-	binop_svalue2 *binop_sval = as_a <binop_svalue2 *> (ptr_sval);
+	const binop_svalue2 *binop_sval
+	  = as_a <const binop_svalue2 *> (ptr_sval);
 	switch (binop_sval->get_op ())
 	  {
 	  case POINTER_PLUS_EXPR:
@@ -5104,9 +5118,9 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 		 things via element indices, rather than via byte offsets.  */
 	      /* Perhaps instead we should capture this as an offset relative
 		 to a base region in region_offset?  */
-	      region2 *parent_region
+	      const region2 *parent_region
 		= deref_rvalue (binop_sval->get_arg0 (), ctxt);
-	      svalue2 *offset = binop_sval->get_arg1 ();
+	      const svalue2 *offset = binop_sval->get_arg1 ();
 	      tree type= TREE_TYPE (ptr_sval->get_type ());
 	      return m_mgr->get_offset_region (parent_region, type, offset,
 					       ctxt);
@@ -5127,8 +5141,8 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 	if (ctxt)
 	  if (tree ptr = get_representative_tree (ptr_sval))
 	    {
-	      poisoned_svalue2 *poisoned_sval
-		= as_a <poisoned_svalue2 *> (ptr_sval);
+	      const poisoned_svalue2 *poisoned_sval
+		= as_a <const poisoned_svalue2 *> (ptr_sval);
 	      enum poison_kind pkind = poisoned_sval->get_poison_kind ();
 	      ctxt->warn (new poisoned_value_diagnostic (ptr, pkind));
 	    }
@@ -5143,7 +5157,7 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 	   FIXME:
 	   We don't know if it on the heap, stack, or a global,
 	   so use the root region2 as parent.  */
-	region2 *new_reg = m_mgr->get_symbolic_region (ptr_sval);
+	const region2 *new_reg = m_mgr->get_symbolic_region (ptr_sval);
 #if 0
 	/* We need to write the region2 back into the pointer,
 	   or we'll get a new, different region2 each time.
@@ -5152,7 +5166,7 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 	   We replace the meaning of the ID rather than simply writing
 	   to PTR's lvalue since there could be several places sharing
 	   the same unknown ptr value.  */
-	svalue2 *ptr_val
+	const svalue2 *ptr_val
 	  = new region_svalue2 (ptr_sval->get_type (), new_reg);
 	replace_svalue2 (ptr_sval, ptr_val);
 #endif
@@ -5174,7 +5188,7 @@ region_model2::deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt)
 region2_id
 region_model2::deref_rvalue (tree ptr, region_model2_context *ctxt)
 {
-  svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
+  const svalue2 *ptr_sval = get_rvalue (ptr, ctxt);
   return deref_rvalue (ptr_sval, ctxt);
 }
 #endif
@@ -5183,7 +5197,7 @@ region_model2::deref_rvalue (tree ptr, region_model2_context *ctxt)
    by RHS_SVAL.  */
 
 void
-region_model2::set_value (region2 *lhs_reg, svalue2 *rhs_sval,
+region_model2::set_value (const region2 *lhs_reg, const svalue2 *rhs_sval,
 			  region_model2_context */*ctxt*/)
 {
   gcc_assert (lhs_reg);
@@ -5198,8 +5212,8 @@ region_model2::set_value (region2 *lhs_reg, svalue2 *rhs_sval,
 void
 region_model2::set_value (tree lhs, tree rhs, region_model2_context *ctxt)
 {
-  region2 *lhs_reg = get_lvalue (lhs, ctxt);
-  svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
+  const region2 *lhs_reg = get_lvalue (lhs, ctxt);
+  const svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
   gcc_assert (lhs_reg);
   gcc_assert (rhs_sval);
   set_value (lhs_reg, rhs_sval, ctxt);
@@ -5208,7 +5222,7 @@ region_model2::set_value (tree lhs, tree rhs, region_model2_context *ctxt)
 /* FIXME.  */
 
 void
-region_model2::clobber_region (region2 *reg)
+region_model2::clobber_region (const region2 *reg)
 {
   m_store.clobber_region (m_mgr->get_store2_manager(), reg);
 }
@@ -5225,9 +5239,9 @@ region_model2::purge_region (const region2 *reg)
    this model.  */
 
 tristate
-region_model2::eval_condition (svalue2 *lhs,
+region_model2::eval_condition (const svalue2 *lhs,
 			       enum tree_code op,
-			       svalue2 *rhs) const
+			       const svalue2 *rhs) const
 {
   /* For now, make no attempt to capture constraints on floating-point
      values.  */
@@ -5251,9 +5265,9 @@ region_model2::eval_condition (svalue2 *lhs,
    without risking creating new ECs.  */
 
 tristate
-region_model2::eval_condition_without_cm (svalue2 *lhs,
+region_model2::eval_condition_without_cm (const svalue2 *lhs,
 					  enum tree_code op,
-					  svalue2 *rhs) const
+					  const svalue2 *rhs) const
 {
   gcc_assert (lhs);
   gcc_assert (rhs);
@@ -5291,8 +5305,8 @@ region_model2::eval_condition_without_cm (svalue2 *lhs,
 	}
 
       /* If we have a pair of region_svalue2s, compare them.  */
-      if (region_svalue2 *lhs_ptr = lhs->dyn_cast_region_svalue2 ())
-	if (region_svalue2 *rhs_ptr = rhs->dyn_cast_region_svalue2 ())
+      if (const region_svalue2 *lhs_ptr = lhs->dyn_cast_region_svalue2 ())
+	if (const region_svalue2 *rhs_ptr = rhs->dyn_cast_region_svalue2 ())
 	  {
 	    tristate res = region_svalue2::eval_condition (lhs_ptr, op, rhs_ptr);
 	    if (res.is_known ())
@@ -5301,19 +5315,19 @@ region_model2::eval_condition_without_cm (svalue2 *lhs,
 	  }
 
       /* If we have a pair of constants, compare them.  */
-      if (constant_svalue2 *cst_lhs = lhs->dyn_cast_constant_svalue2 ())
-	if (constant_svalue2 *cst_rhs = rhs->dyn_cast_constant_svalue2 ())
+      if (const constant_svalue2 *cst_lhs = lhs->dyn_cast_constant_svalue2 ())
+	if (const constant_svalue2 *cst_rhs = rhs->dyn_cast_constant_svalue2 ())
 	  return constant_svalue2::eval_condition (cst_lhs, op, cst_rhs);
 
       /* Handle comparison of a region_svalue2 against zero.  */
 
-      if (region_svalue2 *ptr = lhs->dyn_cast_region_svalue2 ())
-	if (constant_svalue2 *cst_rhs = rhs->dyn_cast_constant_svalue2 ())
+      if (const region_svalue2 *ptr = lhs->dyn_cast_region_svalue2 ())
+	if (const constant_svalue2 *cst_rhs = rhs->dyn_cast_constant_svalue2 ())
 	  if (zerop (cst_rhs->get_constant ()))
 	    {
 	      /* A region_svalue2 is a non-NULL pointer, except in certain
 		 special cases (see the comment for region2::non_null_p.  */
-	      region2 *pointee = ptr->get_pointee ();
+	      const region2 *pointee = ptr->get_pointee ();
 	      if (pointee->non_null_p (*this))
 		{
 		  switch (op)
@@ -5352,8 +5366,8 @@ region_model2::add_constraint (tree lhs, enum tree_code op, tree rhs,
   if (FLOAT_TYPE_P (TREE_TYPE (lhs)) || FLOAT_TYPE_P (TREE_TYPE (rhs)))
     return true;
 
-  svalue2 *lhs_sval = get_rvalue (lhs, ctxt);
-  svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
+  const svalue2 *lhs_sval = get_rvalue (lhs, ctxt);
+  const svalue2 *rhs_sval = get_rvalue (rhs, ctxt);
 
   tristate t_cond = eval_condition (lhs_sval, op, rhs_sval);
 
@@ -5549,7 +5563,7 @@ region_model2::eval_condition (tree lhs,
    Otherwise, return NULL_TREE.  */
 #if 0
 tree
-region_model2::maybe_get_constant (svalue2 *sval) const
+region_model2::maybe_get_constant (const svalue2 *sval) const
 {
   gcc_assert (!sid.null_p ());
   svalue2 *sval = get_svalue2 (sid);
@@ -5573,7 +5587,7 @@ region_model2::add_new_malloc_region2 ()
 /* Attempt to return a tree that represents SVAL, or return NULL_TREE.  */
 
 tree
-region_model2::get_representative_tree (svalue2 *sval) const
+region_model2::get_representative_tree (const svalue2 *sval) const
 {
   if (sval == NULL)
     return NULL_TREE;
@@ -5581,7 +5595,7 @@ region_model2::get_representative_tree (svalue2 *sval) const
   auto_vec<path_var> pvs;
   m_store.get_representative_path_vars (sval, &pvs);
 
-  if (initial_svalue2 *init_sval = sval->dyn_cast_initial_svalue2 ())
+  if (const initial_svalue2 *init_sval = sval->dyn_cast_initial_svalue2 ())
     {
       const region2 *reg = init_sval->get_region ();
       pvs.safe_push (reg->get_representative_path_var ());
@@ -5606,7 +5620,7 @@ region_model2::get_representative_tree (svalue2 *sval) const
       }
 
   /* Handle string literals and various other pointers.  */
-  svalue2 *sval = get_svalue2 (sid);
+  const svalue2 *sval = get_svalue2 (sid);
   if (region_svalue2 *ptr_sval = sval->dyn_cast_region_svalue2 ())
     {
       region2 *reg = ptr_sval->get_pointee ();
@@ -5698,8 +5712,8 @@ region_model2::get_representative_path_var (region2 *reg) const
     }
 
   /* Handle string literals.  */
-  svalue2 *sval = reg->get_value_direct ();
-  if (svalue2 *sval = get_svalue2 (sid))
+  const svalue2 *sval = reg->get_value_direct ();
+  if (const svalue2 *sval = get_svalue2 (sid))
     if (tree cst = sval->maybe_get_constant ())
       if (TREE_CODE (cst) == STRING_CST)
 	return path_var (cst, 0);
@@ -5711,7 +5725,7 @@ region_model2::get_representative_path_var (region2 *reg) const
    path_var instances for them into *OUT.  */
 #if 0
 void
-region_model2::get_path_vars_for_svalue2 (svalue2 *sval, vec<path_var> *out) const
+region_model2::get_path_vars_for_svalue2 (const svalue2 *sval, vec<path_var> *out) const
 {
   unsigned i;
   region2 *region2;
@@ -5731,7 +5745,7 @@ region_model2::set_to_new_unknown_value (region2 *dst_reg, tree type,
 					region_model2_context *ctxt)
 {
   gcc_assert (!dst_reg.null_p ());
-  svalue2 *new_sval = add_svalue2 (new unknown_svalue2 (type));
+  const svalue2 *new_sval = add_svalue2 (new unknown_svalue2 (type));
   set_value (dst_reg, new_sval, ctxt);
 
   // TODO: presumably purge all child region2s too (but do this in set_value?)
@@ -5852,7 +5866,7 @@ region_model2::update_for_call_superedge (const call_superedge &call_edge,
   /* Build a vec of argument svalue2_id, using the current top
      frame for resolving tree expressions.  */
   const gcall *call_stmt = call_edge.get_call_stmt ();
-  auto_vec<svalue2 *> arg_svals (gimple_call_num_args (call_stmt));
+  auto_vec<const svalue2 *> arg_svals (gimple_call_num_args (call_stmt));
 
   for (unsigned i = 0; i < gimple_call_num_args (call_stmt); i++)
     {
@@ -5871,7 +5885,7 @@ region_model2::update_for_return_superedge (const return_superedge &return_edge,
 					    region_model2_context *ctxt)
 {
   /* Get the region2 for the result of the call, within the caller frame.  */
-  region2 *result_dst_reg = NULL;
+  const region2 *result_dst_reg = NULL;
   const gcall *call_stmt = return_edge.get_call_stmt ();
   tree lhs = gimple_call_lhs (call_stmt);
   if (lhs)
@@ -6039,10 +6053,10 @@ region_model2::on_top_level_param (tree param,
 {
   if (POINTER_TYPE_P (TREE_TYPE (param)))
     {
-      region2 *param_reg = get_lvalue (param, ctxt);
-      svalue2 *init_ptr_sval
+      const region2 *param_reg = get_lvalue (param, ctxt);
+      const svalue2 *init_ptr_sval
 	= m_mgr->get_or_create_initial_value (param_reg);
-      region2 *pointee_reg = m_mgr->get_symbolic_region (init_ptr_sval);
+      const region2 *pointee_reg = m_mgr->get_symbolic_region (init_ptr_sval);
       m_store.on_escape_to_unknown_fncall (m_mgr->get_store2_manager (),
 					   pointee_reg);
     }
@@ -6058,8 +6072,8 @@ region_model2::on_top_level_param (tree param,
 
    Return the new frame_region2.  */
 
-region2 *
-region_model2::push_frame (function *fun, vec<svalue2 *> *arg_svals,
+const region2 *
+region_model2::push_frame (function *fun, vec<const svalue2 *> *arg_svals,
 			   region_model2_context *ctxt)
 {
   m_current_frame = m_mgr->get_frame_region (m_current_frame, fun);
@@ -6076,15 +6090,15 @@ region_model2::push_frame (function *fun, vec<svalue2 *> *arg_svals,
 	     rest of the params as uninitialized.  */
 	  if (idx >= arg_svals->length ())
 	    break;
-	  svalue2 *arg_sval = (*arg_svals)[idx];
-	  region2 *parm_reg = get_lvalue (iter_parm, ctxt);
+	  const svalue2 *arg_sval = (*arg_svals)[idx];
+	  const region2 *parm_reg = get_lvalue (iter_parm, ctxt);
 	  set_value (parm_reg, arg_sval, ctxt);
 
 	  /* Also do it for default SSA name (sharing the same value).  */
 	  tree parm_default_ssa = ssa_default_def (fun, iter_parm);
 	  if (parm_default_ssa)
 	    {
-	      region2 *defssa_reg = get_lvalue (parm_default_ssa, ctxt);
+	      const region2 *defssa_reg = get_lvalue (parm_default_ssa, ctxt);
 	      set_value (defssa_reg, arg_sval, ctxt);
 	    }
 	}
@@ -6116,7 +6130,7 @@ region_model2::push_frame (function *fun, vec<svalue2 *> *arg_svals,
 function *
 region_model2::get_current_function () const
 {
-  frame_region2 *frame = get_current_frame ();
+  const frame_region2 *frame = get_current_frame ();
   gcc_assert (frame);
   return frame->get_function ();
 }
@@ -6125,14 +6139,14 @@ region_model2::get_current_function () const
    see the comment for stack_region2::pop_frame.  */
 
 void
-region_model2::pop_frame (region2 *result_dst_reg,
+region_model2::pop_frame (const region2 *result_dst_reg,
 			  bool purge, purge_stats2 *out,
 			  region_model2_context *ctxt)
 {
   gcc_assert (m_current_frame);
 
   /* Evaluate the result, within the callee frame.  */
-  frame_region2 *frame_reg = m_current_frame;
+  const frame_region2 *frame_reg = m_current_frame;
 #if 0
   svalue2_id_set returned_svals;
 #endif
@@ -6160,7 +6174,7 @@ region_model2::pop_frame (region2 *result_dst_reg,
 	      region2_id rid = region2_id::from_int (i);
 	      if (returned_regs.region2_p (rid))
 		{
-		  svalue2 *sval = model->get_region2 (rid)->get_value_direct ();
+		  const svalue2 *sval = model->get_region2 (rid)->get_value_direct ();
 		  returned_svals.add_svalue2 (sid);
 		}
 	    }
@@ -6191,7 +6205,7 @@ region_model2::pop_frame (region2 *result_dst_reg,
 int
 region_model2::get_stack_depth () const
 {
-  frame_region2 *frame = get_current_frame ();
+  const frame_region2 *frame = get_current_frame ();
   if (frame)
     return frame->get_stack_depth ();
   else
@@ -6200,10 +6214,10 @@ region_model2::get_stack_depth () const
 
 /* FIXME.  */
 
-frame_region2 *
+const frame_region2 *
 region_model2::get_frame_at_index (int index) const
 {
-  frame_region2 *frame = get_current_frame ();
+  const frame_region2 *frame = get_current_frame ();
   if (frame)
     {
       gcc_assert (index >= 0);
@@ -6239,7 +6253,7 @@ region_model2::get_function_at_depth (unsigned depth) const
    at the same region2).  */
 #if 0
 void
-region_model2::replace_svalue2 (svalue2 *sval, svalue2 *new_sval)
+region_model2::replace_svalue2 (const svalue2 *sval, const svalue2 *new_sval)
 {
   gcc_assert (!sid.null_p ());
   int idx = sid.as_int ();
@@ -6260,7 +6274,7 @@ class restrict_to_used_svalue2s : public purge_criteria
 public:
   restrict_to_used_svalue2s (const auto_sbitmap &used) : m_used (used) {}
 
-  bool should_purge_p (svalue2 *sval) const FINAL OVERRIDE
+  bool should_purge_p (const svalue2 *sval) const FINAL OVERRIDE
   {
     gcc_assert (!sid.null_p ());
     return !bitmap_bit_p (m_used, sid.as_int ());
@@ -6322,7 +6336,7 @@ region_model2::purge_unused_svalue2s (purge_stats *stats,
   region2 *r;
   FOR_EACH_VEC_ELT (m_region2s, i, r)
     {
-      svalue2 *sval = r->get_value_direct ();
+      const svalue2 *sval = r->get_value_direct ();
       if (!sid.null_p ())
 	bitmap_set_bit (used, sid.as_int ());
     }
@@ -6337,7 +6351,7 @@ region_model2::purge_unused_svalue2s (purge_stats *stats,
     FOR_EACH_VEC_ELT (m_constraints->m_equiv_classes, i, ec)
       {
 	int j;
-	svalue2 **sid;
+	const svalue2 **sid;
 	FOR_EACH_VEC_ELT (ec->m_vars, j, sid)
 	  {
 	    gcc_assert (!sid->null_p ());
@@ -6355,7 +6369,7 @@ region_model2::purge_unused_svalue2s (purge_stats *stats,
   int after_next_unused_new_sval = m_svalue2s.length ();
   for (unsigned i = 0; i < m_svalue2s.length (); i++)
     {
-      svalue2 *src (svalue2_id::from_int (i));
+      const svalue2 *src (svalue2_id::from_int (i));
       if (bitmap_bit_p (used, i))
 	{
 	  if (logger)
@@ -6400,7 +6414,7 @@ region_model2::purge_unused_svalue2s (purge_stats *stats,
     {
       if (logger)
 	{
-	  svalue2 *victim = svalue2_id::from_int (m_svalue2s.length () - 1);
+	  const svalue2 *victim = svalue2_id::from_int (m_svalue2s.length () - 1);
 	  logger->log ("deleting sv%i (was sv%i)",
 		       victim.as_int (),
 		       map.get_src_for_dst (victim).as_int ());
@@ -6521,7 +6535,7 @@ region_model2::poison_any_pointers_to_bad_region2s (const region2_id_set &
 						  enum poison_kind pkind)
 {
   int i;
-  svalue2 *sval;
+  const svalue2 *sval;
   FOR_EACH_VEC_ELT (m_svalue2s, i, sval)
     if (region_svalue2 *ptr_sval = sval->dyn_cast_region_svalue2 ())
       {
@@ -6652,17 +6666,17 @@ region_model2::convert_byte_offset_to_array_index (tree ptr_type,
 
 region2_id
 region_model2::get_or_create_mem_ref (tree type,
-				     svalue2 *ptr_sval,
-				     svalue2 *offset_sval,
+				     const svalue2 *ptr_sval,
+				     const svalue2 *offset_sval,
 				     region_model2_context *ctxt)
 {
-  svalue2 *ptr_sval = get_svalue2 (ptr_sval);
+  const svalue2 *ptr_sval = get_svalue2 (ptr_sval);
   tree ptr_type = ptr_sval->get_type ();
   gcc_assert (ptr_type);
 
   region2 *raw_reg = deref_rvalue (ptr_sval, ctxt);
 
-  svalue2 *offset_sval = get_svalue2 (offset_sval);
+  const svalue2 *offset_sval = get_svalue2 (offset_sval);
   tree offset_type = offset_sval->get_type ();
   gcc_assert (offset_type);
 
@@ -6693,7 +6707,7 @@ region_model2::get_or_create_mem_ref (tree type,
 						      &key_for_raw_reg))
 	    {
 	      /* Convert from offset to index.  */
-	      svalue2 *index_sval
+	      const svalue2 *index_sval
 		= convert_byte_offset_to_array_index (ptr_type, offset_sval);
 	      if (tree index_cst
 		    = get_svalue2 (index_sval)->maybe_get_constant ())
@@ -6705,7 +6719,7 @@ region_model2::get_or_create_mem_ref (tree type,
 		  tree index_rel_to_parent_cst
 		    = wide_int_to_tree (integer_type_node,
 					index_rel_to_parent);
-		  svalue2 *index_sval
+		  const svalue2 *index_sval
 		    = get_or_create_constant_svalue2 (index_rel_to_parent_cst);
 
 		  /* Carry on, using the parent region2 and adjusted index.  */
@@ -6723,7 +6737,7 @@ region_model2::get_or_create_mem_ref (tree type,
   region2 *array_view_reg = get_or_create_view (raw_reg, array_type, ctxt);
   array_region2 *array_reg = get_region2 <array_region2> (array_view_reg);
 
-  svalue2 *index_sval
+  const svalue2 *index_sval
     = convert_byte_offset_to_array_index (ptr_type, offset_sval);
 
   region2 *element_reg
@@ -6740,8 +6754,8 @@ region_model2::get_or_create_mem_ref (tree type,
 
 region2_id
 region_model2::get_or_create_pointer_plus_expr (tree type,
-					       svalue2 *ptr_sval,
-					       svalue2 *offset_in_bytes_sval,
+					       const svalue2 *ptr_sval,
+					       const svalue2 *offset_in_bytes_sval,
 					       region_model2_context *ctxt)
 {
   return get_or_create_mem_ref (type,
@@ -6790,11 +6804,12 @@ region_model2::get_fndecl_for_call (const gcall *call,
   tree fn_ptr = gimple_call_fn (call);
   if (fn_ptr == NULL_TREE)
     return NULL_TREE;
-  svalue2 *fn_ptr_sval = get_rvalue (fn_ptr, ctxt);
-  if (region_svalue2 *fn_ptr_ptr = fn_ptr_sval->dyn_cast_region_svalue2 ())
+  const svalue2 *fn_ptr_sval = get_rvalue (fn_ptr, ctxt);
+  if (const region_svalue2 *fn_ptr_ptr
+	= fn_ptr_sval->dyn_cast_region_svalue2 ())
     {
-      region2 *reg = fn_ptr_ptr->get_pointee ();
-      if (function_region2 *fn_reg = reg->dyn_cast_function_region2 ())
+      const region2 *reg = fn_ptr_ptr->get_pointee ();
+      if (const function_region2 *fn_reg = reg->dyn_cast_function_region2 ())
 	{
 	  tree fn_decl = fn_reg->get_fndecl ();
 	  cgraph_node *node = cgraph_node::get (fn_decl);
@@ -6847,20 +6862,20 @@ region_model2::append_ssa_names_cb (const region2 *base_reg,
 
 /* FIXME.  */
 
-region2 *
-region_model2::create_region_for_heap_alloc (svalue2 *size_in_bytes)
+const region2 *
+region_model2::create_region_for_heap_alloc (const svalue2 *size_in_bytes)
 {
-  region2 *reg = m_mgr->create_region_for_heap_alloc ();
+  const region2 *reg = m_mgr->create_region_for_heap_alloc ();
   record_dynamic_extents (reg, size_in_bytes);
   return reg;
 }
 
 /* FIXME.  */
 
-region2 *
-region_model2::create_region_for_alloca (svalue2 *size_in_bytes)
+const region2 *
+region_model2::create_region_for_alloca (const svalue2 *size_in_bytes)
 {
-  region2 *reg = m_mgr->create_region_for_alloca (m_current_frame);
+  const region2 *reg = m_mgr->create_region_for_alloca (m_current_frame);
   record_dynamic_extents (reg, size_in_bytes);
   return reg;
 }
@@ -6868,10 +6883,11 @@ region_model2::create_region_for_alloca (svalue2 *size_in_bytes)
 /* FIXME.  */
 
 void
-region_model2::record_dynamic_extents (region2 *reg, svalue2 *size_in_bytes)
+region_model2::record_dynamic_extents (const region2 *reg,
+				       const svalue2 *size_in_bytes)
 {
 #if 0
-  svalue2 *extents_sval = m_mgr->get_or_create_extents_svalue2 (reg);
+  const svalue2 *extents_sval = m_mgr->get_or_create_extents_svalue2 (reg);
   add_constraint (extents_sval, EQ_EXPR, size_in_bytes);
   /* TODO: This needs the ability to add constraints in the model based on an
      svalue2.  */
@@ -6945,13 +6961,13 @@ model_merger::dump () const
    Return true if the merger is possible, false otherwise.  */
 
 bool
-model_merger::can_merge_values_p (svalue2 *sval_a,
-				  svalue2 *sval_b,
-				  svalue2 **merged_sval)
+model_merger::can_merge_values_p (const svalue2 *sval_a,
+				  const svalue2 *sval_b,
+				  const svalue2 **merged_sval)
 {
   gcc_assert (merged_sval);
-  svalue2 *sval_a = m_model_a->get_svalue2 (sid_a);
-  svalue2 *sval_b = m_model_b->get_svalue2 (sid_b);
+  const svalue2 *sval_a = m_model_a->get_svalue2 (sid_a);
+  const svalue2 *sval_b = m_model_b->get_svalue2 (sid_b);
 
   /* If both are NULL, then the "values" are trivially mergeable.  */
   if (!sval_a && !sval_b)
@@ -6964,9 +6980,9 @@ model_merger::can_merge_values_p (svalue2 *sval_a,
 
   /* Have they both already been mapped to the same new svalue2_id?
      If so, use it.  */
-  svalue2 *sval_a_in_m
+  const svalue2 *sval_a_in_m
     = m_sval_mapping->m_map_from_a_to_m.get_dst_for_src (sid_a);
-  svalue2 *sval_b_in_m
+  const svalue2 *sval_b_in_m
     = m_sval_mapping->m_map_from_b_to_m.get_dst_for_src (sid_b);
   if (!sid_a_in_m.null_p ()
       && !sid_b_in_m.null_p ()
@@ -6985,7 +7001,7 @@ model_merger::can_merge_values_p (svalue2 *sval_a,
   if (sval_a->get_kind () != sval_b->get_kind ()
       || sval_a->get_kind () == SK_UNKNOWN)
     {
-      svalue2 *merged_sval = new unknown_svalue2 (type);
+      const svalue2 *merged_sval = new unknown_svalue2 (type);
       *merged_sval = m_merged_model->add_svalue2 (merged_sval);
       record_svalue2s (sid_a, sid_b, *merged_sval);
       return true;
@@ -7003,8 +7019,10 @@ model_merger::can_merge_values_p (svalue2 *sval_a,
       {
 	/* If we have two region2 pointers, then we can merge (possibly to
 	   "unknown").  */
-	const region_svalue2 &region2_sval_a = *as_a <region_svalue2 *> (sval_a);
-	const region_svalue2 &region2_sval_b = *as_a <region_svalue2 *> (sval_b);
+	const region_svalue2 &region2_sval_a
+	  = *as_a <const region_svalue2 *> (sval_a);
+	const region_svalue2 &region2_sval_b
+	  = *as_a <const region_svalue2 *> (sval_b);
 	region_svalue2::merge_values (region2_sval_a, region2_sval_b,
 				     merged_sval, type,
 				     this);
@@ -7015,8 +7033,10 @@ model_merger::can_merge_values_p (svalue2 *sval_a,
     case SK_CONSTANT:
       {
 	/* If we have two constants, then we can merge.  */
-	const constant_svalue2 &cst_sval_a = *as_a <constant_svalue2 *> (sval_a);
-	const constant_svalue2 &cst_sval_b = *as_a <constant_svalue2 *> (sval_b);
+	const constant_svalue2 &cst_sval_a
+	  = *as_a <const constant_svalue2 *> (sval_a);
+	const constant_svalue2 &cst_sval_b
+	  = *as_a <const constant_svalue2 *> (sval_b);
 	constant_svalue2::merge_values (cst_sval_a, cst_sval_b,
 				       merged_sval, this);
 	record_svalue2s (sid_a, sid_b, *merged_sval);
@@ -7047,9 +7067,9 @@ model_merger::record_region2s (region2 *a_reg,
    correspond to MERGED_SVAL in the merged model.  */
 
 void
-model_merger::record_svalue2s (svalue2 *a_sval,
-			      svalue2 *b_sval,
-			      svalue2 *merged_sval)
+model_merger::record_svalue2s (const svalue2 *a_sval,
+			      const svalue2 *b_sval,
+			      const svalue2 *merged_sval)
 {
   gcc_assert (m_sval_mapping);
   m_sval_mapping->m_map_from_a_to_m.put (a_sval, merged_sval);
@@ -7180,7 +7200,7 @@ test_tree_cmp_on_constants ()
 void
 assert_condition2 (const location &loc,
 		   region_model2 &model,
-		   svalue2 *lhs, tree_code op, svalue2 *rhs,
+		   const svalue2 *lhs, tree_code op, const svalue2 *rhs,
 		   tristate expected)
 {
   tristate actual = model.eval_condition (lhs, op, rhs);
@@ -7351,7 +7371,7 @@ test_dump_2 ()
 
   /* Verify get_offset for "c.x".  */
   {
-    region2 *c_x_reg = model.get_lvalue (c_x, NULL);
+    const region2 *c_x_reg = model.get_lvalue (c_x, NULL);
     region_offset offset = c_x_reg->get_offset ();
     ASSERT_EQ (offset.get_base_region (), model.get_lvalue (c, NULL));
     ASSERT_EQ (offset.get_bit_offset (), 0);
@@ -7359,7 +7379,7 @@ test_dump_2 ()
 
   /* Verify get_offset for "c.y".  */
   {
-    region2 *c_y_reg = model.get_lvalue (c_y, NULL);
+    const region2 *c_y_reg = model.get_lvalue (c_y, NULL);
     region_offset offset = c_y_reg->get_offset ();
     ASSERT_EQ (offset.get_base_region (), model.get_lvalue (c, NULL));
     ASSERT_EQ (offset.get_bit_offset (), INT_TYPE_SIZE);
@@ -7437,7 +7457,7 @@ test_get_representative_tree ()
   {
     tree string_cst = build_string (4, "foo");
     region_model2 m;
-    svalue2 *str_sval = m.get_rvalue (string_cst, NULL);
+    const svalue2 *str_sval = m.get_rvalue (string_cst, NULL);
     tree rep = m.get_representative_tree (str_sval);
     ASSERT_EQ (rep, string_cst);
   }
@@ -7446,7 +7466,7 @@ test_get_representative_tree ()
   {
     tree string_cst_ptr = build_string_literal (4, "foo");
     region_model2 m;
-    svalue2 *str_sval = m.get_rvalue (string_cst_ptr, NULL);
+    const svalue2 *str_sval = m.get_rvalue (string_cst_ptr, NULL);
     tree rep = m.get_representative_tree (str_sval);
     ASSERT_DUMP_TREE_EQ (rep, "&\"foo\"[0]");
   }
@@ -7476,8 +7496,8 @@ test_unique_constants ()
   tree const_int_42 = build_int_cst (const_int_type_node, 42);
   ASSERT_NE (int_42, const_int_42);
   /* It should have a different const_svalue2.  */
-  svalue2 *int_42_sval = model.get_rvalue (int_42, &ctxt);
-  svalue2 *const_int_42_sval = model.get_rvalue (const_int_42, &ctxt);
+  const svalue2 *int_42_sval = model.get_rvalue (int_42, &ctxt);
+  const svalue2 *const_int_42_sval = model.get_rvalue (const_int_42, &ctxt);
   ASSERT_NE (int_42_sval, const_int_42_sval);
   /* But they should compare as equal.  */
   ASSERT_CONDITION_TRUE2 (model, int_42_sval, EQ_EXPR, const_int_42_sval);
@@ -7497,9 +7517,9 @@ test_svalue2_equality ()
   /* Create pairs instances of the various subclasses of svalue2,
      testing for hash and equality between (this, this) and
      (this, other of same subclass). */
-  svalue2 *ptr_to_r0
+  const svalue2 *ptr_to_r0
     = new region_svalue2 (ptr_type_node, region2_id::from_int (0));
-  svalue2 *ptr_to_r1
+  const svalue2 *ptr_to_r1
     = new region_svalue2 (ptr_type_node, region2_id::from_int (1));
 
   ASSERT_EQ (ptr_to_r0->hash (), ptr_to_r0->hash ());
@@ -7508,8 +7528,8 @@ test_svalue2_equality ()
   ASSERT_NE (ptr_to_r0->hash (), ptr_to_r1->hash ());
   ASSERT_NE (*ptr_to_r0, *ptr_to_r1);
 
-  svalue2 *cst_int_42 = new constant_svalue2 (int_42);
-  svalue2 *cst_int_0 = new constant_svalue2 (int_0);
+  const svalue2 *cst_int_42 = new constant_svalue2 (int_42);
+  const svalue2 *cst_int_0 = new constant_svalue2 (int_0);
 
   ASSERT_EQ (cst_int_42->hash (), cst_int_42->hash ());
   ASSERT_EQ (*cst_int_42, *cst_int_42);
@@ -7517,8 +7537,8 @@ test_svalue2_equality ()
   ASSERT_NE (cst_int_42->hash (), cst_int_0->hash ());
   ASSERT_NE (*cst_int_42, *cst_int_0);
 
-  svalue2 *uninit = new poisoned_svalue2 (POISON_KIND_UNINIT, NULL_TREE);
-  svalue2 *freed = new poisoned_svalue2 (POISON_KIND_FREED, NULL_TREE);
+  const svalue2 *uninit = new poisoned_svalue2 (POISON_KIND_UNINIT, NULL_TREE);
+  const svalue2 *freed = new poisoned_svalue2 (POISON_KIND_FREED, NULL_TREE);
 
   ASSERT_EQ (uninit->hash (), uninit->hash ());
   ASSERT_EQ (*uninit, *uninit);
@@ -7526,8 +7546,8 @@ test_svalue2_equality ()
   ASSERT_NE (uninit->hash (), freed->hash ());
   ASSERT_NE (*uninit, *freed);
 
-  svalue2 *unknown_0 = new unknown_svalue2 (ptr_type_node);
-  svalue2 *unknown_1 = new unknown_svalue2 (ptr_type_node);
+  const svalue2 *unknown_0 = new unknown_svalue2 (ptr_type_node);
+  const svalue2 *unknown_1 = new unknown_svalue2 (ptr_type_node);
   ASSERT_EQ (unknown_0->hash (), unknown_0->hash ());
   ASSERT_EQ (*unknown_0, *unknown_0);
   ASSERT_EQ (*unknown_1, *unknown_1);
@@ -7587,7 +7607,7 @@ test_svalue2_folding ()
 #define NUM_CSTS 10
   tree cst_int[NUM_CSTS];
   region_model2_manager mgr;
-  svalue2 *cst_sval[NUM_CSTS];
+  const svalue2 *cst_sval[NUM_CSTS];
   for (int i = 0; i < NUM_CSTS; i++)
     {
       cst_int[i] = build_int_cst (integer_type_node, i);
@@ -7603,29 +7623,29 @@ test_svalue2_folding ()
 	  ASSERT_NE (cst_sval[i], cst_sval[j]);
 	if (i + j < NUM_CSTS)
 	  {
-	    svalue2 *sum
+	    const svalue2 *sum
 	      = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 					 cst_sval[i], cst_sval[j]);
 	    ASSERT_EQ (sum, cst_sval[i + j]);
 	  }
 	if (i - j >= 0)
 	  {
-	    svalue2 *difference
+	    const svalue2 *difference
 	      = mgr.get_or_create_binop (integer_type_node, MINUS_EXPR,
 					 cst_sval[i], cst_sval[j]);
 	    ASSERT_EQ (difference, cst_sval[i - j]);
 	  }
 	if (i * j < NUM_CSTS)
 	  {
-	    svalue2 *product
+	    const svalue2 *product
 	      = mgr.get_or_create_binop (integer_type_node, MULT_EXPR,
 					 cst_sval[i], cst_sval[j]);
 	    ASSERT_EQ (product, cst_sval[i * j]);
 	  }
-	svalue2 *eq = mgr.get_or_create_binop (integer_type_node, EQ_EXPR,
+	const svalue2 *eq = mgr.get_or_create_binop (integer_type_node, EQ_EXPR,
 					       cst_sval[i], cst_sval[j]);
 	ASSERT_EQ (eq, i == j ? cst_sval[1] : cst_sval [0]);
-	svalue2 *neq = mgr.get_or_create_binop (integer_type_node, NE_EXPR,
+	const svalue2 *neq = mgr.get_or_create_binop (integer_type_node, NE_EXPR,
 						cst_sval[i], cst_sval[j]);
 	ASSERT_EQ (neq, i != j ? cst_sval[1] : cst_sval [0]);
 	// etc
@@ -7636,35 +7656,35 @@ test_svalue2_folding ()
 
   test_region_model2_context ctxt;
   region_model2 model (&mgr);
-  svalue2 *x_init = model.get_rvalue (x, &ctxt);
-  region2 *x_reg = model.get_lvalue (x, &ctxt);
+  const svalue2 *x_init = model.get_rvalue (x, &ctxt);
+  const region2 *x_reg = model.get_lvalue (x, &ctxt);
   ASSERT_EQ (x_init, mgr.get_or_create_initial_value (x_reg));
 
   /* PLUS_EXPR folding.  */
-  svalue2 *x_init_plus_zero
+  const svalue2 *x_init_plus_zero
     = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 			       x_init, cst_sval[0]);
   ASSERT_EQ (x_init_plus_zero, x_init);
-  svalue2 *zero_plus_x_init
+  const svalue2 *zero_plus_x_init
     = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 			       cst_sval[0], x_init);
   ASSERT_EQ (zero_plus_x_init, x_init);
 
   /* MULT_EXPR folding.  */
-  svalue2 *x_init_times_zero
+  const svalue2 *x_init_times_zero
     = mgr.get_or_create_binop (integer_type_node, MULT_EXPR,
 			       x_init, cst_sval[0]);
   ASSERT_EQ (x_init_times_zero, cst_sval[0]);
-  svalue2 *zero_times_x_init
+  const svalue2 *zero_times_x_init
     = mgr.get_or_create_binop (integer_type_node, MULT_EXPR,
 			       cst_sval[0], x_init);
   ASSERT_EQ (zero_times_x_init, cst_sval[0]);
 
-  svalue2 *x_init_times_one
+  const svalue2 *x_init_times_one
     = mgr.get_or_create_binop (integer_type_node, MULT_EXPR,
 			       x_init, cst_sval[1]);
   ASSERT_EQ (x_init_times_one, x_init);
-  svalue2 *one_times_x_init
+  const svalue2 *one_times_x_init
     = mgr.get_or_create_binop (integer_type_node, MULT_EXPR,
 			       cst_sval[1], x_init);
   ASSERT_EQ (one_times_x_init, x_init);
@@ -7673,13 +7693,13 @@ test_svalue2_folding ()
   // TODO: do we want to use the match-and-simplify DSL for this?
 
   /* TODO: Verify that ((x + 1) + 1) == (x + 2).  */
-  svalue2 *x_init_plus_one
+  const svalue2 *x_init_plus_one
     = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 			       x_init, cst_sval[1]);
-  svalue2 *x_init_plus_two
+  const svalue2 *x_init_plus_two
     = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 			       x_init, cst_sval[2]);
-  svalue2 *x_init_plus_one_plus_one
+  const svalue2 *x_init_plus_one_plus_one
     = mgr.get_or_create_binop (integer_type_node, PLUS_EXPR,
 			       x_init_plus_one, cst_sval[1]);
 #if 0
@@ -7689,7 +7709,7 @@ test_svalue2_folding ()
   /* FIXME: do we want to canonicalize binops to put constants on the RHS ?  */
 }
 #if 0
-/* A subclass of purge_criteria for selftests: purge all svalue2 *instances.  */
+/* A subclass of purge_criteria for selftests: purge all const svalue2 *instances.  */
 
 class purge_all_svalue2_ids : public purge_criteria
 {
@@ -7979,11 +7999,11 @@ test_stack_frames ()
   region_model2 model (&mgr);
 
   /* Push stack frame for "parent_fn".  */
-  region2 *parent_frame_reg
+  const region2 *parent_frame_reg
     = model.push_frame (DECL_STRUCT_FUNCTION (parent_fndecl),
 			NULL, &ctxt);
   ASSERT_EQ (model.get_current_frame (), parent_frame_reg);
-  region2 *a_in_parent_reg = model.get_lvalue (a, &ctxt);
+  const region2 *a_in_parent_reg = model.get_lvalue (a, &ctxt);
   model.set_value (a_in_parent_reg,
 		   model.get_rvalue (int_42, &ctxt),
 		   &ctxt);
@@ -7996,10 +8016,10 @@ test_stack_frames ()
 #endif
 
   /* Push stack frame for "child_fn".  */
-  region2 *child_frame_reg
+  const region2 *child_frame_reg
     = model.push_frame (DECL_STRUCT_FUNCTION (child_fndecl), NULL, &ctxt);
   ASSERT_EQ (model.get_current_frame (), child_frame_reg);
-  region2 *x_in_child_reg = model.get_lvalue (x, &ctxt);
+  const region2 *x_in_child_reg = model.get_lvalue (x, &ctxt);
   model.set_value (x_in_child_reg,
 		   model.get_rvalue (int_0, &ctxt),
 		   &ctxt);
@@ -8012,13 +8032,13 @@ test_stack_frames ()
 #endif
 
   /* Point a global pointer at a local in the child frame:  p = &x.  */
-  region2 *p_in_globals_reg = model.get_lvalue (p, &ctxt);
+  const region2 *p_in_globals_reg = model.get_lvalue (p, &ctxt);
   model.set_value (p_in_globals_reg,
 		   mgr.get_ptr_svalue2 (ptr_type_node, x_in_child_reg),
 		   &ctxt);
 
   /* Point another global pointer at p: q = &p.  */
-  region2 *q_in_globals_reg = model.get_lvalue (q, &ctxt);
+  const region2 *q_in_globals_reg = model.get_lvalue (q, &ctxt);
   model.set_value (q_in_globals_reg,
 		   mgr.get_ptr_svalue2 (ptr_type_node, p_in_globals_reg),
 		   &ctxt);
@@ -8065,7 +8085,7 @@ test_stack_frames ()
 
   /* Verify that p (which was pointing at the local "x" in the popped
      frame) has been poisoned.  */
-  svalue2 *new_p_sval = model.get_rvalue (p, &ctxt);
+  const svalue2 *new_p_sval = model.get_rvalue (p, &ctxt);
 #if 0
   ASSERT_EQ (new_p_sval->get_kind (), svalue2::SK_POISONED);
   ASSERT_EQ (new_p_sval->dyn_cast_poisoned_svalue2 ()->get_poison_kind (),
@@ -8074,7 +8094,7 @@ test_stack_frames ()
 
   /* Verify that q still points to p, in spite of the region2
      renumbering.  */
-  svalue2 *new_q_sval = model.get_rvalue (q, &ctxt);
+  const svalue2 *new_q_sval = model.get_rvalue (q, &ctxt);
   ASSERT_EQ (new_q_sval->get_kind (), svalue2::SK_REGION);
   ASSERT_EQ (new_q_sval->dyn_cast_region_svalue2 ()->get_pointee (),
 	     model.get_lvalue (p, &ctxt));
@@ -8084,7 +8104,7 @@ test_stack_frames ()
 
   /* Verify locals in parent frame.  */
   /* Verify "a" still has its value.  */
-  svalue2 *new_a_sval = model.get_rvalue (a, &ctxt);
+  const svalue2 *new_a_sval = model.get_rvalue (a, &ctxt);
   ASSERT_EQ (new_a_sval->get_kind (), svalue2::SK_CONSTANT);
   ASSERT_EQ (new_a_sval->dyn_cast_constant_svalue2 ()->get_constant (),
 	     int_42);
@@ -8121,14 +8141,14 @@ test_get_representative_path_var ()
   auto_vec<svalue2_id> parm_svals;
   for (int depth = 0; depth < 5; depth++)
     {
-      region2 *frame_reg
+      const region2 *frame_reg
 	= model.push_frame (DECL_STRUCT_FUNCTION (fndecl), NULL, NULL);
-      region2 *reg_n = model.get_lvalue (path_var (n, depth), NULL);
+      const region2 *reg_n = model.get_lvalue (path_var (n, depth), NULL);
       parm_regs.safe_push (rid_n);
 
       ASSERT_EQ (model.get_region2 (rid_n)->get_parent (), frame_reg);
 
-      svalue2 *sval_n
+      const svalue2 *sval_n
 	= model.set_to_new_unknown_value (rid_n, integer_type_node, NULL);
       parm_svals.safe_push (sid_n);
     }
@@ -8279,7 +8299,7 @@ test_model_equality_4 ()
 static void
 assert_region_model2s_merge (tree expr, tree val_a, tree val_b,
 			    region_model2 *out_merged_model,
-			    svalue2 **out_merged_svalue2)
+			    const svalue2 **out_merged_svalue2)
 {
   test_region_model2_context ctxt;
   region_model2 model0;
@@ -8296,7 +8316,7 @@ assert_region_model2s_merge (tree expr, tree val_a, tree val_b,
   /* They should be mergeable.  */
   ASSERT_TRUE (model0.can_merge_with_p (model1, out_merged_model));
 
-  svalue2 *merged_svalue2_sval = out_merged_model->get_rvalue (expr, &ctxt);
+  const svalue2 *merged_svalue2_sval = out_merged_model->get_rvalue (expr, &ctxt);
   *out_merged_svalue2 = out_merged_model->get_svalue2 (merged_svalue2_sval);
 }
 
@@ -8367,7 +8387,7 @@ test_state_merging ()
 	       DECL_STRUCT_FUNCTION (test_fndecl));
     model1.push_frame (DECL_STRUCT_FUNCTION (test_fndecl), NULL, &ctxt);
 
-    svalue2 *sval_a
+    const svalue2 *sval_a
       = model0.set_to_new_unknown_value (model0.get_lvalue (a, &ctxt),
 					 integer_type_node, &ctxt);
     model1.set_to_new_unknown_value (model1.get_lvalue (a, &ctxt),
@@ -8382,7 +8402,7 @@ test_state_merging ()
     ASSERT_TRUE (model0.can_merge_with_p (model1, &merged));
     ASSERT_EQ (model0, merged);
     /* In particular, there should be an unknown value for "a".  */
-    svalue2 *merged_a_sval = merged.get_svalue2 (merged.get_rvalue (a, &ctxt));
+    const svalue2 *merged_a_sval = merged.get_svalue2 (merged.get_rvalue (a, &ctxt));
     ASSERT_EQ (merged_a_sval->get_kind (), SK_UNKNOWN);
   }
 
@@ -8391,7 +8411,7 @@ test_state_merging ()
     test_region_model2_context ctxt;
     region_model2 model0;
     region_model2 model1;
-    svalue2 *sval_x
+    const svalue2 *sval_x
       = model0.set_to_new_unknown_value (model0.get_lvalue (x, &ctxt),
 					 integer_type_node, &ctxt);
     model1.set_to_new_unknown_value (model1.get_lvalue (x, &ctxt),
@@ -8406,7 +8426,7 @@ test_state_merging ()
     ASSERT_TRUE (model0.can_merge_with_p (model1, &merged));
     ASSERT_EQ (model0, merged);
     /* In particular, there should be an unknown value for "x".  */
-    svalue2 *merged_x_sval = merged.get_svalue2 (merged.get_rvalue (x, &ctxt));
+    const svalue2 *merged_x_sval = merged.get_svalue2 (merged.get_rvalue (x, &ctxt));
     ASSERT_EQ (merged_x_sval->get_kind (), SK_UNKNOWN);
   }
 
@@ -8415,7 +8435,7 @@ test_state_merging ()
   /* Two equal constant values.  */
   {
     region_model2 merged;
-    svalue2 *merged_x_sval;
+    const svalue2 *merged_x_sval;
     assert_region_model2s_merge (x, int_42, int_42, &merged, &merged_x_sval);
 
     /* In particular, there should be a constant value for "x".  */
@@ -8427,7 +8447,7 @@ test_state_merging ()
   /* Two non-equal constant values.  */
   {
     region_model2 merged;
-    svalue2 *merged_x_sval;
+    const svalue2 *merged_x_sval;
     assert_region_model2s_merge (x, int_42, int_113, &merged, &merged_x_sval);
 
     /* In particular, there should be an unknown value for "x".  */
@@ -8437,7 +8457,7 @@ test_state_merging ()
   /* Uninit and constant.  */
   {
     region_model2 merged;
-    svalue2 *merged_x_sval;
+    const svalue2 *merged_x_sval;
     assert_region_model2s_merge (x, NULL_TREE, int_113, &merged, &merged_x_sval);
 
     /* In particular, there should be an unknown value for "x".  */
@@ -8447,7 +8467,7 @@ test_state_merging ()
   /* Constant and uninit.  */
   {
     region_model2 merged;
-    svalue2 *merged_x_sval;
+    const svalue2 *merged_x_sval;
     assert_region_model2s_merge (x, int_42, NULL_TREE, &merged, &merged_x_sval);
 
     /* In particular, there should be an unknown value for "x".  */
@@ -8485,14 +8505,14 @@ test_state_merging ()
   {
     region_model2 merged;
     /* p == &y in both input models.  */
-    svalue2 *merged_p_sval;
+    const svalue2 *merged_p_sval;
     assert_region_model2s_merge (p, addr_of_y, addr_of_y, &merged,
 				&merged_p_sval);
 
     /* We should get p == &y in the merged model.  */
     ASSERT_EQ (merged_p_sval->get_kind (), SK_REGION2);
-    region_svalue2 *merged_p_ptr = merged_p_sval->dyn_cast_region_svalue2 ();
-    region2 *merged_p_star_reg = merged_p_ptr->get_pointee ();
+    region_const svalue2 *merged_p_ptr = merged_p_sval->dyn_cast_region_svalue2 ();
+    const region2 *merged_p_star_reg = merged_p_ptr->get_pointee ();
     ASSERT_EQ (merged_p_star_reg, merged.get_lvalue (y, NULL));
   }
 
@@ -8500,7 +8520,7 @@ test_state_merging ()
   {
     region_model2 merged;
     /* x == &y vs x == &z in the input models.  */
-    svalue2 *merged_x_sval;
+    const svalue2 *merged_x_sval;
     assert_region_model2s_merge (x, addr_of_y, addr_of_z, &merged,
 				&merged_x_sval);
 
@@ -8512,8 +8532,8 @@ test_state_merging ()
   {
     test_region_model2_context ctxt;
     region_model2 model0;
-    region2 *new_reg = model0.add_new_malloc_region2 ();
-    svalue2 *ptr_sval
+    const region2 *new_reg = model0.add_new_malloc_region2 ();
+    const svalue2 *ptr_sval
       = model0.get_or_create_ptr_svalue2 (ptr_type_node, new_reg);
     model0.set_value (model0.get_lvalue (p, &ctxt),
 		      ptr_sval, &ctxt);
@@ -8538,7 +8558,7 @@ test_state_merging ()
   {
     test_region_model2_context ctxt;
     region_model2 model0;
-    svalue2 *sval
+    const svalue2 *sval
       = model0.set_to_new_unknown_value (model0.get_lvalue (x, &ctxt),
 					 integer_type_node, &ctxt);
     model0.set_value (model0.get_lvalue (y, &ctxt), sid, &ctxt);
@@ -8589,9 +8609,9 @@ test_state_merging ()
     test_region_model2_context ctxt;
     region_model2 model0;
 
-    region2 *x_reg = model0.get_lvalue (x, &ctxt);
-    region2 *x_as_ptr = model0.get_or_create_view (x_reg, ptr_type_node,
-						    &ctxt);
+    const region2 *x_reg = model0.get_lvalue (x, &ctxt);
+    const region2 *x_as_ptr = model0.get_or_create_view (x_reg, ptr_type_node,
+							 &ctxt);
     model0.set_value (x_as_ptr, model0.get_rvalue (addr_of_y, &ctxt), &ctxt);
 
     region_model2 model1 (model0);
@@ -8607,19 +8627,19 @@ test_state_merging ()
   {
     region_model2 model0;
     model0.push_frame (DECL_STRUCT_FUNCTION (test_fndecl), NULL, NULL);
-    region2 *q_in_first_frame = model0.get_lvalue (q, NULL);
+    const region2 *q_in_first_frame = model0.get_lvalue (q, NULL);
 
     /* Push a second frame.  */
-    region2 *reg_2nd_frame
+    const region2 *reg_2nd_frame
       = model0.push_frame (DECL_STRUCT_FUNCTION (test_fndecl), NULL, NULL);
 
     /* Have a pointer in the older frame point to a local in the
        more recent frame.  */
-    svalue2 *sval_ptr = model0.get_rvalue (addr_of_a, NULL);
+    const svalue2 *sval_ptr = model0.get_rvalue (addr_of_a, NULL);
     model0.set_value (q_in_first_frame, sid_ptr, NULL);
 
     /* Verify that it's pointing at the newer frame.  */
-    region2 *reg_pointee
+    const region2 *reg_pointee
       = model0.get_svalue2 (sid_ptr)->dyn_cast_region_svalue2 ()->get_pointee ();
     ASSERT_EQ (model0.get_region2 (rid_pointee)->get_parent (), rid_2nd_frame);
 
@@ -8716,14 +8736,14 @@ test_malloc_constraints ()
   tree q = build_global_decl ("q", char_star);
   tree null_ptr = build_int_cst (ptr_type_node, 0);
 
-  region2 *reg = model.add_new_malloc_region2 ();
-  svalue2 *sval = mgr.get_ptr_svalue2 (ptr_type_node, rid);
+  const region2 *reg = model.add_new_malloc_region2 ();
+  const svalue2 *sval = mgr.get_ptr_svalue2 (ptr_type_node, rid);
   model.set_value (model.get_lvalue (p, NULL), sid, NULL);
   model.set_value (q, p, NULL);
 
   /* We should have a symbolic_region2 with m_possibly_null: true.  */
-  region2 *pointee = model.get_region2 (rid);
-  symbolic_region2 *sym_reg = pointee->dyn_cast_symbolic_region2 ();
+  const region2 *pointee = model.get_region2 (rid);
+  const symbolic_region2 *sym_reg = pointee->dyn_cast_symbolic_region2 ();
   ASSERT_NE (sym_reg, NULL);
   ASSERT_TRUE (sym_reg->m_possibly_null);
 
@@ -8756,11 +8776,11 @@ test_var ()
   region_model2_manager mgr;
   region_model2 model (&mgr);
 
-  region2 *i_reg = model.get_lvalue (i, NULL);
+  const region2 *i_reg = model.get_lvalue (i, NULL);
   ASSERT_EQ (i_reg->get_kind (), region2::RK_DECL);
 
   /* Reading "i" should give a symbolic "initial value".  */
-  svalue2 *sval_init = model.get_rvalue (i, NULL);
+  const svalue2 *sval_init = model.get_rvalue (i, NULL);
   ASSERT_EQ (sval_init->get_kind (), svalue2::SK_INITIAL);
   ASSERT_EQ (sval_init->dyn_cast_initial_svalue2 ()->get_region (), i_reg);
   /* ..and doing it again should give the same "initial value".  */
@@ -8841,7 +8861,7 @@ test_array ()
 
   /* Verify get_offset for "arr[0]".  */
   {
-    region2 *arr_0_reg = model.get_lvalue (arr_0, NULL);
+    const region2 *arr_0_reg = model.get_lvalue (arr_0, NULL);
     region_offset offset = arr_0_reg->get_offset ();
     ASSERT_EQ (offset.get_base_region (), model.get_lvalue (arr, NULL));
     ASSERT_EQ (offset.get_bit_offset (), 0);
@@ -8849,7 +8869,7 @@ test_array ()
 
   /* Verify get_offset for "arr[1]".  */
   {
-    region2 *arr_1_reg = model.get_lvalue (arr_1, NULL);
+    const region2 *arr_1_reg = model.get_lvalue (arr_1, NULL);
     region_offset offset = arr_1_reg->get_offset ();
     ASSERT_EQ (offset.get_base_region (), model.get_lvalue (arr, NULL));
     ASSERT_EQ (offset.get_bit_offset (), INT_TYPE_SIZE);
@@ -8911,7 +8931,7 @@ test_mem_ref ()
   /* "p = &x;".  */
   model.set_value (p, addr_of_x, NULL);
 
-  svalue2 *sval = model.get_rvalue (star_p, NULL);
+  const svalue2 *sval = model.get_rvalue (star_p, NULL);
   ASSERT_EQ (sval->maybe_get_constant (), int_17);
 }
 
@@ -8954,8 +8974,8 @@ test_POINTER_PLUS_EXPR_then_MEM_REF ()
 			 pointer_plus_expr, offset_0);
   region_model2_manager mgr;
   region_model2 m (&mgr);
-  svalue2 *tmp_2 = m.get_rvalue (mem_ref, NULL);
-  region2 *tmp_5 = m.get_lvalue (mem_ref, NULL);
+  const svalue2 *tmp_2 = m.get_rvalue (mem_ref, NULL);
+  const region2 *tmp_5 = m.get_lvalue (mem_ref, NULL);
 
   tree int_42 = build_int_cst (integer_type_node, 42);
   m.set_value (mem_ref, int_42, NULL);
@@ -8980,9 +9000,9 @@ test_malloc ()
   region_model2 model (&mgr);
 
   /* "p = malloc (n * 4);".  */
-  svalue2 *size_sval = model.get_rvalue (n_times_4, &ctxt);
-  region2 *reg = model.create_region_for_heap_alloc (size_sval);
-  svalue2 *ptr = mgr.get_ptr_svalue2 (int_star, reg);
+  const svalue2 *size_sval = model.get_rvalue (n_times_4, &ctxt);
+  const region2 *reg = model.create_region_for_heap_alloc (size_sval);
+  const svalue2 *ptr = mgr.get_ptr_svalue2 (int_star, reg);
   model.set_value (model.get_lvalue (p, &ctxt), ptr, &ctxt);
   // TODO: verify dynamic extents
 
@@ -9011,13 +9031,13 @@ test_alloca ()
   region_model2 model (&mgr);
 
   /* Push stack frame.  */
-  region2 *frame_reg
+  const region2 *frame_reg
     = model.push_frame (DECL_STRUCT_FUNCTION (fndecl),
 			NULL, &ctxt);
   /* "p = alloca (n * 4);".  */
-  svalue2 *size_sval = model.get_rvalue (n_times_4, &ctxt);
-  region2 *reg = model.create_region_for_alloca (size_sval);
-  svalue2 *ptr = mgr.get_ptr_svalue2 (int_star, reg);
+  const svalue2 *size_sval = model.get_rvalue (n_times_4, &ctxt);
+  const region2 *reg = model.create_region_for_alloca (size_sval);
+  const svalue2 *ptr = mgr.get_ptr_svalue2 (int_star, reg);
   model.set_value (model.get_lvalue (p, &ctxt), ptr, &ctxt);
   // TODO: verify dynamic extents
   // TODO: try popping the frame; verify that the alloca region is poisoned
diff --git a/gcc/analyzer/region-model2.h b/gcc/analyzer/region-model2.h
index 9127c5ab9f3..a9bf778e2d3 100644
--- a/gcc/analyzer/region-model2.h
+++ b/gcc/analyzer/region-model2.h
@@ -157,14 +157,18 @@ public:
   virtual void dump_to_pp (pretty_printer *pp, bool simple) const = 0;
   void dump (bool simple=true) const;
 
-  virtual region_svalue2 *dyn_cast_region_svalue2 () { return NULL; }
-  virtual constant_svalue2 *dyn_cast_constant_svalue2 () { return NULL; }
-  virtual const constant_svalue2 *dyn_cast_constant_svalue2 () const
-  { return NULL; }
-  virtual poisoned_svalue2 *dyn_cast_poisoned_svalue2 () { return NULL; }
-  virtual unknown_svalue2 *dyn_cast_unknown_svalue2 () { return NULL; }
-  virtual setjmp_svalue2 *dyn_cast_setjmp_svalue2 () { return NULL; }
-  virtual initial_svalue2 *dyn_cast_initial_svalue2 () { return NULL; }
+  virtual const region_svalue2 *
+  dyn_cast_region_svalue2 () const { return NULL; }
+  virtual const constant_svalue2 *
+  dyn_cast_constant_svalue2 () const { return NULL; }
+  virtual const poisoned_svalue2 *
+  dyn_cast_poisoned_svalue2 () const { return NULL; }
+  virtual const unknown_svalue2 *
+  dyn_cast_unknown_svalue2 () const { return NULL; }
+  virtual const setjmp_svalue2 *
+  dyn_cast_setjmp_svalue2 () const { return NULL; }
+  virtual const initial_svalue2 *
+  dyn_cast_initial_svalue2 () const { return NULL; }
 
   tree maybe_get_constant () const;
 
@@ -189,13 +193,13 @@ public:
 class region_svalue2 : public svalue2
 {
 public:
-  region_svalue2 (tree type, region2 *reg) : svalue2 (type), m_reg (reg)
+  region_svalue2 (tree type, const region2 *reg) : svalue2 (type), m_reg (reg)
   {
     gcc_assert (m_reg != NULL);
   }
 
 #if 0
-  svalue2 *clone () const FINAL OVERRIDE
+  const svalue2 *clone () const FINAL OVERRIDE
   { return new region_svalue2 (get_type (), m_reg); }
 #endif
 
@@ -209,9 +213,10 @@ public:
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
-  region_svalue2 *dyn_cast_region_svalue2 () FINAL OVERRIDE { return this; }
+  const region_svalue2 *
+  dyn_cast_region_svalue2 () const FINAL OVERRIDE { return this; }
 
-  region2 * get_pointee () const { return m_reg; }
+  const region2 * get_pointee () const { return m_reg; }
 
 #if 0
   static void merge_values (const region_svalue2 &region_sval_a,
@@ -221,9 +226,9 @@ public:
 			    model_merger *merger);
 #endif
 
-  static tristate eval_condition (region_svalue2 *lhs_ptr,
+  static tristate eval_condition (const region_svalue2 *lhs_ptr,
 				  enum tree_code op,
-				  region_svalue2 *rhs_ptr);
+				  const region_svalue2 *rhs_ptr);
 
 #if 0
   void add_to_hash (inchash::hash &hstate) const FINAL OVERRIDE;
@@ -235,7 +240,7 @@ public:
     FINAL OVERRIDE;
 #endif
 
-  region2 *m_reg;
+  const region2 *m_reg;
 };
 
 } // namespace ana
@@ -243,7 +248,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <region_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const region_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_REGION;
 }
@@ -263,7 +268,7 @@ public:
   }
 
 #if 0
-  svalue2 *clone () const FINAL OVERRIDE
+  const svalue2 *clone () const FINAL OVERRIDE
   { return new constant_svalue2 (m_cst_expr); }
 #endif
 
@@ -274,9 +279,8 @@ public:
   void add_to_hash (inchash::hash &hstate) const FINAL OVERRIDE;
 #endif
 
-  constant_svalue2 *dyn_cast_constant_svalue2 () FINAL OVERRIDE { return this; }
-  const constant_svalue2 *dyn_cast_constant_svalue2 () const FINAL OVERRIDE
-  { return this; }
+  const constant_svalue2 *
+  dyn_cast_constant_svalue2 () const FINAL OVERRIDE { return this; }
 
   tree get_constant () const { return m_cst_expr; }
 
@@ -287,9 +291,9 @@ public:
 			    model_merger *merger);
 #endif
 
-  static tristate eval_condition (constant_svalue2 *lhs,
+  static tristate eval_condition (const constant_svalue2 *lhs,
 				  enum tree_code op,
-				  constant_svalue2 *rhs);
+				  const constant_svalue2 *rhs);
 
  private:
 #if 0
@@ -306,7 +310,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <constant_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const constant_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_CONSTANT;
 }
@@ -336,7 +340,8 @@ public:
   void add_to_hash (inchash::hash &hstate) const FINAL OVERRIDE;
 #endif
 
-  unknown_svalue2 *dyn_cast_unknown_svalue2 () FINAL OVERRIDE { return this; }
+  const unknown_svalue2 *
+  dyn_cast_unknown_svalue2 () const FINAL OVERRIDE { return this; }
 
  private:
 #if 0
@@ -385,7 +390,8 @@ public:
   void add_to_hash (inchash::hash &hstate) const FINAL OVERRIDE;
 #endif
 
-  poisoned_svalue2 *dyn_cast_poisoned_svalue2 () FINAL OVERRIDE { return this; }
+  const poisoned_svalue2 *
+  dyn_cast_poisoned_svalue2 () const FINAL OVERRIDE { return this; }
 
   enum poison_kind get_poison_kind () const { return m_kind; }
 
@@ -404,7 +410,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <poisoned_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const poisoned_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_POISONED;
 }
@@ -457,7 +463,8 @@ public:
   void add_to_hash (inchash::hash &hstate) const FINAL OVERRIDE;
 #endif
 
-  setjmp_svalue2 *dyn_cast_setjmp_svalue2 () FINAL OVERRIDE { return this; }
+  const setjmp_svalue2 *
+  dyn_cast_setjmp_svalue2 () const FINAL OVERRIDE { return this; }
 
   int get_enode_index () const;
 
@@ -495,7 +502,8 @@ public:
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
-  initial_svalue2 *dyn_cast_initial_svalue2 () FINAL OVERRIDE { return this; }
+  const initial_svalue2 *
+  dyn_cast_initial_svalue2 () const FINAL OVERRIDE { return this; }
 
   const region2 * get_region () const { return m_reg; }
 
@@ -525,7 +533,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <initial_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const initial_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_INITIAL;
 }
@@ -561,7 +569,7 @@ public:
   /* A support class for uniquifying instances of unaryop_svalue2.  */
   struct key_t
   {
-    key_t (tree type, enum tree_code op, svalue2 *arg)
+    key_t (tree type, enum tree_code op, const svalue2 *arg)
     : m_type (type), m_op (op), m_arg (arg)
     {}
 
@@ -584,10 +592,10 @@ public:
 
     tree m_type;
     enum tree_code m_op;
-    svalue2 *m_arg;
+    const svalue2 *m_arg;
   };
 
-  unaryop_svalue2 (tree type, enum tree_code op, svalue2 *arg)
+  unaryop_svalue2 (tree type, enum tree_code op, const svalue2 *arg)
   : svalue2 (type), m_op (op), m_arg (arg)
   {
   }
@@ -603,7 +611,8 @@ public:
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
 #if 0
-  unaryop_svalue2 *dyn_cast_unaryop_svalue2 () FINAL OVERRIDE { return this; }
+  const unaryop_svalue2 *
+  dyn_cast_unaryop_svalue2 () const FINAL OVERRIDE { return this; }
 #endif
 
 #if 0
@@ -617,7 +626,7 @@ public:
 #endif
 
   enum tree_code m_op;
-  svalue2 *m_arg;
+  const svalue2 *m_arg;
 };
 
 } // namespace ana
@@ -625,7 +634,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <unaryop_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const unaryop_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_UNARYOP;
 }
@@ -647,7 +656,8 @@ public:
   /* A support class for uniquifying instances of binop_svalue2.  */
   struct key_t
   {
-    key_t (tree type, enum tree_code op, svalue2 *arg0, svalue2 *arg1)
+    key_t (tree type, enum tree_code op,
+	   const svalue2 *arg0, const svalue2 *arg1)
     : m_type (type), m_op (op), m_arg0 (arg0), m_arg1 (arg1)
     {}
 
@@ -671,11 +681,12 @@ public:
 
     tree m_type;
     enum tree_code m_op;
-    svalue2 *m_arg0;
-    svalue2 *m_arg1;
+    const svalue2 *m_arg0;
+    const svalue2 *m_arg1;
   };
 
-  binop_svalue2 (tree type, enum tree_code op, svalue2 *arg0, svalue2 *arg1)
+  binop_svalue2 (tree type, enum tree_code op,
+		 const svalue2 *arg0, const svalue2 *arg1)
   : svalue2 (type), m_op (op), m_arg0 (arg0), m_arg1 (arg1)
   {
   }
@@ -683,8 +694,8 @@ public:
   enum kind get_kind () const FINAL OVERRIDE { return SK_BINOP; }
 
   enum tree_code get_op () const { return m_op; }
-  svalue2 *get_arg0 () const { return m_arg0; }
-  svalue2 *get_arg1 () const { return m_arg1; }
+  const svalue2 *get_arg0 () const { return m_arg0; }
+  const svalue2 *get_arg1 () const { return m_arg1; }
 
 #if 0
   void dump_dot_to_pp (const region_model2 &model,
@@ -695,7 +706,8 @@ public:
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
 #if 0
-  binop_svalue2 *dyn_cast_binop_svalue2 () FINAL OVERRIDE { return this; }
+  const binop_svalue2 *
+  dyn_cast_binop_svalue2 () const FINAL OVERRIDE { return this; }
 #endif
 
 #if 0
@@ -709,8 +721,8 @@ public:
 #endif
 
   enum tree_code m_op;
-  svalue2 *m_arg0;
-  svalue2 *m_arg1;
+  const svalue2 *m_arg0;
+  const svalue2 *m_arg1;
 };
 
 } // namespace ana
@@ -718,7 +730,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <binop_svalue2 *>::test (svalue2 *sval)
+is_a_helper <const binop_svalue2 *>::test (const svalue2 *sval)
 {
   return sval->get_kind () == svalue2::SK_BINOP;
 }
@@ -812,16 +824,22 @@ public:
   static int cmp_ids (const region2 *reg1, const region2 *reg2);
 
   virtual enum kind get_kind () const = 0;
-  virtual function_region2 *dyn_cast_function_region2 () { return NULL; }
-  virtual symbolic_region2 *dyn_cast_symbolic_region2 () { return NULL; }
-  virtual const symbolic_region2 *dyn_cast_symbolic_region2 () const { return NULL; }
-  virtual const decl_region2 *dyn_cast_decl_region2 () const { return NULL; }
-  virtual field_region2 *dyn_cast_field_region2 () { return NULL; }
-  virtual element_region2 *dyn_cast_element_region2 () { return NULL; }
-  virtual offset_region2 *dyn_cast_offset_region2 () { return NULL; }
-  virtual string_region2 *dyn_cast_string_region2 () { return NULL; }
-
-  region2 *get_parent_region () const { return m_parent; }
+  virtual const function_region2 *
+  dyn_cast_function_region2 () const { return NULL; }
+  virtual const symbolic_region2 *
+  dyn_cast_symbolic_region2 () const { return NULL; }
+  virtual const decl_region2 *
+  dyn_cast_decl_region2 () const { return NULL; }
+  virtual const field_region2 *
+  dyn_cast_field_region2 () const { return NULL; }
+  virtual const element_region2 *
+  dyn_cast_element_region2 () const { return NULL; }
+  virtual const offset_region2 *
+  dyn_cast_offset_region2 () const { return NULL; }
+  virtual const string_region2 *
+  dyn_cast_string_region2 () const { return NULL; }
+
+  const region2 *get_parent_region () const { return m_parent; }
   const region2 *get_base_region () const;
 
 #if 0
@@ -874,12 +892,12 @@ public:
 
   static int cmp_ptrs (const void *, const void *);
 
-  region_offset get_offset ();
+  region_offset get_offset () const;
 
   virtual path_var get_representative_path_var () const;
 
  protected:
-  region2 (unsigned id, region2 *parent, tree type);
+  region2 (unsigned id, const region2 *parent, tree type);
 
   virtual void add_to_hash (inchash::hash &hstate) const;
 #if 0
@@ -896,10 +914,10 @@ public:
   region_offset calc_offset () const;
 
   unsigned m_id; // purely for deterministic sorting at this stage, for dumps
-  region2 *m_parent;
+  const region2 *m_parent;
   tree m_type;
 
-  region_offset *m_cached_offset;
+  mutable region_offset *m_cached_offset;
 };
 
 } // namespace ana
@@ -907,7 +925,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <region2 *>::test (region2 *)
+is_a_helper <const region2 *>::test (const region2 *)
 {
   return true;
 }
@@ -920,7 +938,7 @@ namespace ana {
 class space_region2 : public region2
 {
 protected:
-  space_region2 (unsigned id, region2 *parent)
+  space_region2 (unsigned id, const region2 *parent)
   : region2 (id, parent, NULL_TREE)
   {}
 };
@@ -940,8 +958,8 @@ protected:
 class frame_region2 : public space_region2
 {
 public:
-  frame_region2 (unsigned id, region2 *parent,
-		 frame_region2 *calling_frame,
+  frame_region2 (unsigned id, const region2 *parent,
+		 const frame_region2 *calling_frame,
 		 function *fun, int index)
   : space_region2 (id, parent), m_calling_frame (calling_frame),
     m_fun (fun), m_index (index)
@@ -959,19 +977,19 @@ public:
 #endif
 
   /* Accessors.  */
-  frame_region2 *get_calling_frame () const { return m_calling_frame; }
+  const frame_region2 *get_calling_frame () const { return m_calling_frame; }
   function *get_function () const { return m_fun; }
   int get_index () const { return m_index; }
   int get_stack_depth () const { return m_index + 1; }
 
   bool compare_fields (const frame_region2 &other) const;
 
-  region2 *get_region_for_local (region_model2_manager *mgr,
-				 tree expr,
-				 region_model2_context *ctxt);
+  const region2 *get_region_for_local (region_model2_manager *mgr,
+				       tree expr,
+				       region_model2_context *ctxt) const;
 
  private:
-  frame_region2 *m_calling_frame;
+  const frame_region2 *m_calling_frame;
   function *m_fun;
   int m_index;
   typedef hash_map<tree, region2 *> map_t;
@@ -985,7 +1003,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <frame_region2 *>::test (region2 *reg)
+is_a_helper <const frame_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_FRAME;
 }
@@ -997,7 +1015,7 @@ namespace ana {
 class globals_region2 : public space_region2
 {
  public:
-  globals_region2 (unsigned id, region2 *parent)
+  globals_region2 (unsigned id, const region2 *parent)
   : space_region2 (id, parent)
   {}
 
@@ -1016,7 +1034,7 @@ class globals_region2 : public space_region2
 template <>
 template <>
 inline bool
-is_a_helper <globals_region2 *>::test (region2 *reg)
+is_a_helper <const globals_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_GLOBALS;
 }
@@ -1029,7 +1047,7 @@ namespace ana {
 class code_region2 : public space_region2
 {
 public:
-  code_region2 (unsigned id, region2 *parent)
+  code_region2 (unsigned id, const region2 *parent)
   : space_region2 (id, parent)
   {}
 
@@ -1037,8 +1055,8 @@ public:
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
   enum kind get_kind () const FINAL OVERRIDE { return RK_CODE; }
 
-  region2 *get_element (region_model2 *model,
-			svalue2 *index,
+  const region2 *get_element (region_model2 *model,
+			const svalue2 *index,
 			region_model2_context *ctxt);
 
   bool compare_fields (const code_region2 &other) const;
@@ -1049,7 +1067,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <code_region2 *>::test (region2 *reg)
+is_a_helper <const code_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_CODE;
 }
@@ -1063,7 +1081,7 @@ namespace ana {
 class function_region2 : public region2
 {
 public:
-  function_region2 (unsigned id, code_region2 *parent, tree fndecl)
+  function_region2 (unsigned id, const code_region2 *parent, tree fndecl)
   : region2 (id, parent, TREE_TYPE (fndecl)), m_fndecl (fndecl)
   {
     gcc_assert (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (fndecl)));
@@ -1072,12 +1090,13 @@ public:
   /* region2 vfuncs.  */
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
   enum kind get_kind () const FINAL OVERRIDE { return RK_FUNCTION; }
-  function_region2 *dyn_cast_function_region2 () { return this; }
+  const function_region2 *
+  dyn_cast_function_region2 () const FINAL OVERRIDE{ return this; }
 
   tree get_fndecl () const { return m_fndecl; }
 
   region2 *get_element (region_model2 *model,
-			svalue2 *index_sid,
+			const svalue2 *index_sid,
 			region_model2_context *ctxt);
 
   bool compare_fields (const function_region2 &other) const;
@@ -1091,7 +1110,7 @@ private:
 template <>
 template <>
 inline bool
-is_a_helper <function_region2 *>::test (region2 *reg)
+is_a_helper <const function_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_FUNCTION;
 }
@@ -1105,7 +1124,7 @@ namespace ana {
 class label_region2 : public region2
 {
 public:
-  label_region2 (unsigned id, function_region2 *parent, tree label)
+  label_region2 (unsigned id, const function_region2 *parent, tree label)
   : region2 (id, parent, NULL_TREE), m_label (label)
   {
     gcc_assert (TREE_CODE (label) == LABEL_DECL);
@@ -1126,7 +1145,7 @@ private:
 template <>
 template <>
 inline bool
-is_a_helper <label_region2 *>::test (region2 *reg)
+is_a_helper <const label_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_LABEL;
 }
@@ -1161,7 +1180,7 @@ public:
   static bool can_merge_p (const stack_region2 *stack_region2_a,
 			   const stack_region2 *stack_region2_b,
 			   model_merger *merger);
-  svalue2 *get_value_by_name (tree identifier,
+  const svalue2 *get_value_by_name (tree identifier,
 			      const region_model2 &model) const;
 #endif
 
@@ -1186,7 +1205,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <stack_region2 *>::test (region2 *reg)
+is_a_helper <const stack_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_STACK;
 }
@@ -1222,7 +1241,7 @@ public:
 template <>
 template <>
 inline bool
-is_a_helper <heap_region2 *>::test (region2 *reg)
+is_a_helper <const heap_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_HEAP;
 }
@@ -1277,7 +1296,7 @@ public:
 			   model_merger *merger);
 #endif
 
-  svalue2 *get_value_by_name (tree identifier,
+  const svalue2 *get_value_by_name (tree identifier,
 			      const region_model2 &model) const;
 
 #if 0
@@ -1305,7 +1324,7 @@ private:
 template <>
 template <>
 inline bool
-is_a_helper <root_region2 *>::test (region2 *reg)
+is_a_helper <const root_region2 *>::test (const region2 *reg)
 {
   return reg->get_kind () == region2::RK_ROOT;
 }
@@ -1318,15 +1337,13 @@ namespace ana {
 class symbolic_region2 : public region2
 {
 public:
-  symbolic_region2 (unsigned id, region2 *parent, svalue2 *sval_ptr)
+  symbolic_region2 (unsigned id, region2 *parent, const svalue2 *sval_ptr)
   : region2 (id, parent, TREE_TYPE (sval_ptr->get_type ())),
     m_sval_ptr (sval_ptr)
   {}
 
-  const symbolic_region2 *dyn_cast_symbolic_region2 () const FINAL OVERRIDE
-  { return this; }
-  symbolic_region2 *dyn_cast_symbolic_region2 () FINAL OVERRIDE
-  { return this; }
+  const symbolic_region2 *
+  dyn_cast_symbolic_region2 () const FINAL OVERRIDE { return this; }
 
   bool compare_fields (const symbolic_region2 &other) const;
 
@@ -1334,7 +1351,7 @@ public:
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
-  svalue2 *get_pointer () const { return m_sval_ptr; }
+  const svalue2 *get_pointer () const { return m_sval_ptr; }
 
 #if 0
   void print_fields (const region_model2 &model,
@@ -1342,7 +1359,7 @@ public:
 #endif
 
 private:
-  svalue2 *m_sval_ptr;
+  const svalue2 *m_sval_ptr;
 };
 
 /* FIXME.  */
@@ -1350,7 +1367,7 @@ private:
 class decl_region2 : public region2
 {
 public:
-  decl_region2 (unsigned id, region2 *parent, tree decl)
+  decl_region2 (unsigned id, const region2 *parent, tree decl)
   : region2 (id, parent, TREE_TYPE (decl)), m_decl (decl)
   {}
 
@@ -1361,8 +1378,8 @@ public:
   bool compare_fields (const decl_region2 &other) const;
 
   enum region2::kind get_kind () const FINAL OVERRIDE { return RK_DECL; }
-  const decl_region2 *dyn_cast_decl_region2 () const FINAL OVERRIDE
-  { return this; }
+  const decl_region2 *
+  dyn_cast_decl_region2 () const FINAL OVERRIDE { return this; }
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
   path_var get_representative_path_var () const FINAL OVERRIDE;
@@ -1381,7 +1398,7 @@ private:
 class field_region2 : public region2
 {
 public:
-  field_region2 (unsigned id, region2 *parent, tree field)
+  field_region2 (unsigned id, const region2 *parent, tree field)
   : region2 (id, parent, TREE_TYPE (field)), m_field (field)
   {}
 
@@ -1390,7 +1407,8 @@ public:
   enum region2::kind get_kind () const FINAL OVERRIDE { return RK_FIELD; }
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
-  field_region2 *dyn_cast_field_region2 () FINAL OVERRIDE { return this; }
+  const field_region2 *
+  dyn_cast_field_region2 () const FINAL OVERRIDE { return this; }
 
   tree get_field () const { return m_field; }
 
@@ -1406,25 +1424,26 @@ private:
 class element_region2 : public region2
 {
 public:
-  element_region2 (unsigned id, region2 *parent, tree element_type,
-		   svalue2 *index)
+  element_region2 (unsigned id, const region2 *parent, tree element_type,
+		   const svalue2 *index)
   : region2 (id, parent, element_type), m_index (index)
   {}
 
   bool compare_fields (const element_region2 &other) const;
 
   enum region2::kind get_kind () const FINAL OVERRIDE { return RK_ELEMENT; }
-  element_region2 *dyn_cast_element_region2 () FINAL OVERRIDE { return this; }
+  const element_region2 *
+  dyn_cast_element_region2 () const FINAL OVERRIDE { return this; }
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
-  svalue2 *get_index () const { return m_index; }
+  const svalue2 *get_index () const { return m_index; }
 
 protected:
   void add_to_hash (inchash::hash &hstate) const OVERRIDE;
 
 private:
-  svalue2 *m_index;
+  const svalue2 *m_index;
 };
 
 /* A byte-offset within another region, for handling pointer arithmetic
@@ -1433,24 +1452,26 @@ private:
 class offset_region2 : public region2
 {
 public:
-  offset_region2 (unsigned id, region2 *parent, tree type, svalue2 *byte_offset)
+  offset_region2 (unsigned id, const region2 *parent, tree type,
+		  const svalue2 *byte_offset)
   : region2 (id, parent, type), m_byte_offset (byte_offset)
   {}
 
   bool compare_fields (const offset_region2 &other) const;
 
   enum region2::kind get_kind () const FINAL OVERRIDE { return RK_OFFSET; }
-  offset_region2 *dyn_cast_offset_region2 () FINAL OVERRIDE { return this; }
+  const offset_region2 *
+  dyn_cast_offset_region2 () const FINAL OVERRIDE { return this; }
 
   void dump_to_pp (pretty_printer *pp, bool simple) const FINAL OVERRIDE;
 
-  svalue2 *get_byte_offset () const { return m_byte_offset; }
+  const svalue2 *get_byte_offset () const { return m_byte_offset; }
 
 protected:
   void add_to_hash (inchash::hash &hstate) const OVERRIDE;
 
 private:
-  svalue2 *m_byte_offset;
+  const svalue2 *m_byte_offset;
 };
 
 /* An untyped region dynamically allocated on the heap via "malloc"
@@ -1460,7 +1481,7 @@ private:
 class heap_allocated_region2 : public region2
 {
 public:
-  heap_allocated_region2 (unsigned id, region2 *parent)
+  heap_allocated_region2 (unsigned id, const region2 *parent)
   : region2 (id, parent, NULL_TREE)
   {}
 
@@ -1482,7 +1503,7 @@ protected:
 class alloca_region2 : public region2
 {
 public:
-  alloca_region2 (unsigned id, frame_region2 *parent)
+  alloca_region2 (unsigned id, const frame_region2 *parent)
   : region2 (id, parent, NULL_TREE)
   {}
 
@@ -1504,11 +1525,12 @@ protected:
 class string_region2 : public region2
 {
 public:
-  string_region2 (unsigned id, region2 *parent, tree string_cst)
+  string_region2 (unsigned id, const region2 *parent, tree string_cst)
   : region2 (id, parent, TREE_TYPE (string_cst)), m_string_cst (string_cst)
   {}
 
-  string_region2 *dyn_cast_string_region2 () FINAL OVERRIDE { return this; }
+  const string_region2 *
+  dyn_cast_string_region2 () const FINAL OVERRIDE { return this; }
 
 #if 0
   bool compare_fields (const element_region2 &other) const;
@@ -1532,7 +1554,7 @@ private:
 class unknown_region2 : public region2
 {
 public:
-  unknown_region2 (unsigned id, region2 *parent, tree type)
+  unknown_region2 (unsigned id, const region2 *parent, tree type)
   : region2 (id, parent, type)
   {}
 
@@ -1550,7 +1572,9 @@ protected:
 };
 
 /* A class responsible for owning and consolidating region2 and svalue2
-   instances.    */
+   instances.
+   region2 and svalue2 instances are immutable as far as clients are
+   concerned, so they are provided as "const" ptrs.  */
 
 class region_model2_manager
 {
@@ -1559,39 +1583,41 @@ public:
   ~region_model2_manager ();
 
   /* svalue2 consolidation.  */
-  svalue2 *get_or_create_constant_svalue2 (tree cst_expr);
-  svalue2 *get_or_create_initial_value (const region2 *reg);
-  svalue2 *get_ptr_svalue2 (tree ptr_type, region2 *pointee);
-  svalue2 *get_or_create_unaryop (tree type, enum tree_code op, svalue2 *arg);
-  svalue2 *get_or_create_binop (tree type,
-				enum tree_code op,
-				svalue2 *arg0, svalue2 *arg1);
+  const svalue2 *get_or_create_constant_svalue2 (tree cst_expr);
+  const svalue2 *get_or_create_initial_value (const region2 *reg);
+  const svalue2 *get_ptr_svalue2 (tree ptr_type, const region2 *pointee);
+  const svalue2 *get_or_create_unaryop (tree type, enum tree_code op,
+					const svalue2 *arg);
+  const svalue2 *get_or_create_binop (tree type,
+				      enum tree_code op,
+				      const svalue2 *arg0, const svalue2 *arg1);
 
   /* region2 consolidation.  */
-  function_region2 *get_region_for_fndecl (tree fndecl,
-					   region_model2_context *ctxt);
-  label_region2 *get_region_for_label (tree label,
-				       region_model2_context *ctxt);
-  decl_region2 *get_region_for_global (tree expr,
-				       region_model2_context *ctxt);
-  region2 *get_field_region (region2 *parent, tree field,
-			     region_model2_context *ctxt);
-  region2 *get_element_region (region2 *parent,
-			       tree element_type,
-			       svalue2 *index,
-			       region_model2_context *ctxt);
-  region2 *get_offset_region (region2 *parent,
-			      tree type,
-			      svalue2 *byte_offset,
-			      region_model2_context *ctxt);
-  frame_region2 *get_frame_region (frame_region2 *calling_frame,
-				   function *fun);
-  region2 *get_symbolic_region (svalue2 *sval);
-  string_region2 *get_region_for_string (tree string_cst);
+  const function_region2 *get_region_for_fndecl (tree fndecl,
+						 region_model2_context *ctxt);
+  const label_region2 *get_region_for_label (tree label,
+					     region_model2_context *ctxt);
+  const decl_region2 *get_region_for_global (tree expr,
+					     region_model2_context *ctxt);
+  const region2 *get_field_region (const region2 *parent, tree field,
+				   region_model2_context *ctxt);
+  const region2 *get_element_region (const region2 *parent,
+				     tree element_type,
+				     const svalue2 *index,
+				     region_model2_context *ctxt);
+  const region2 *get_offset_region (const region2 *parent,
+				    tree type,
+				    const svalue2 *byte_offset,
+				    region_model2_context *ctxt);
+  const frame_region2 *get_frame_region (const frame_region2 *calling_frame,
+					 function *fun);
+  const region2 *get_symbolic_region (const svalue2 *sval);
+  const string_region2 *get_region_for_string (tree string_cst);
 
-  region2 *get_region2_for_unexpected_tree_code (region_model2_context *ctxt,
-						 tree t,
-						 const dump_location_t &loc);
+  const region2 *
+  get_region2_for_unexpected_tree_code (region_model2_context *ctxt,
+					tree t,
+					const dump_location_t &loc);
 
   unsigned alloc_region_id () { return m_next_region_id++; }
 
@@ -1600,14 +1626,14 @@ public:
   /* Dynamically-allocated region2 instances.
      FIXME: for now, the number of these within the analysis can grow
      arbitrarily.  They are still owned by the manager.  */
-  region2 *create_region_for_heap_alloc ();
-  region2 *create_region_for_alloca (frame_region2 *frame);
+  const region2 *create_region_for_heap_alloc ();
+  const region2 *create_region_for_alloca (const frame_region2 *frame);
 
 private:
-  svalue2 *maybe_fold_unaryop (tree type, enum tree_code op,
-			       svalue2 *arg);
-  svalue2 *maybe_fold_binop (tree type, enum tree_code op,
-			     svalue2 *arg0, svalue2 *arg1);
+  const svalue2 *maybe_fold_unaryop (tree type, enum tree_code op,
+				     const svalue2 *arg);
+  const svalue2 *maybe_fold_binop (tree type, enum tree_code op,
+				   const svalue2 *arg0, const svalue2 *arg1);
 
   unsigned m_next_region_id;
   root_region2 m_root_region;
@@ -1755,25 +1781,25 @@ class region_model2
 
   region2_id get_stack_region2_id () const;
 #endif
-  region2 *push_frame (function *fun, vec<svalue2 *> *arg_sids,
-		       region_model2_context *ctxt);
-  frame_region2 *get_current_frame () const { return m_current_frame; }
+  const region2 *push_frame (function *fun, vec<const svalue2 *> *arg_sids,
+			     region_model2_context *ctxt);
+  const frame_region2 *get_current_frame () const { return m_current_frame; }
   function * get_current_function () const;
-  void pop_frame (region2 *result_dst,
+  void pop_frame (const region2 *result_dst,
 		  bool purge, purge_stats2 *stats,
 		  region_model2_context *ctxt);
   int get_stack_depth () const;
-  frame_region2 *get_frame_at_index (int index) const;
+  const frame_region2 *get_frame_at_index (int index) const;
 
 #if 0
   region2_id get_globals_region2_id () const;
-  void replace_svalue2 (svalue2_id sid, svalue2 *new_sval);
+  void replace_svalue2 (svalue2_id sid, const svalue2 *new_sval);
 #endif
 
-  region2 *get_lvalue (path_var pv, region_model2_context *ctxt);
-  region2 *get_lvalue (tree expr, region_model2_context *ctxt);
-  svalue2 *get_rvalue (path_var pv, region_model2_context *ctxt);
-  svalue2 *get_rvalue (tree expr, region_model2_context *ctxt);
+  const region2 *get_lvalue (path_var pv, region_model2_context *ctxt);
+  const region2 *get_lvalue (tree expr, region_model2_context *ctxt);
+  const svalue2 *get_rvalue (path_var pv, region_model2_context *ctxt);
+  const svalue2 *get_rvalue (tree expr, region_model2_context *ctxt);
 
 #if 0
   svalue2_id get_or_create_ptr_svalue2 (tree ptr_type, region2_id id);
@@ -1785,26 +1811,27 @@ class region_model2
 			      region_model2_context *ctxt);
 #endif
 
-  region2 *deref_rvalue (svalue2 *ptr_sval, region_model2_context *ctxt);
+  const region2 *deref_rvalue (const svalue2 *ptr_sval,
+			       region_model2_context *ctxt);
 #if 0
-  region2 *deref_rvalue (tree ptr, region_model2_context *ctxt);
+  const region2 *deref_rvalue (tree ptr, region_model2_context *ctxt);
 #endif
 
-  void set_value (region2 *lhs_reg, svalue2 *rhs_sval,
+  void set_value (const region2 *lhs_reg, const svalue2 *rhs_sval,
 		  region_model2_context *ctxt);
   void set_value (tree lhs, tree rhs, region_model2_context *ctxt);
-  void clobber_region (region2 *reg);
+  void clobber_region (const region2 *reg);
   void purge_region (const region2 *reg);
-  svalue2 *set_to_new_unknown_value (region2 *dst_reg, tree type,
+  const svalue2 *set_to_new_unknown_value (const region2 *dst_reg, tree type,
 				     region_model2_context *ctxt);
-  void copy_region (region2 *dst_reg, region2 *src_reg,
+  void copy_region (const region2 *dst_reg, const region2 *src_reg,
 		    region_model2_context *ctxt);
-  tristate eval_condition (svalue2 *lhs,
+  tristate eval_condition (const svalue2 *lhs,
 			   enum tree_code op,
-			   svalue2 *rhs) const;
-  tristate eval_condition_without_cm (svalue2 *lhs,
+			   const svalue2 *rhs) const;
+  tristate eval_condition_without_cm (const svalue2 *lhs,
 				      enum tree_code op,
-				      svalue2 *rhs) const;
+				      const svalue2 *rhs) const;
   tristate eval_condition (tree lhs,
 			   enum tree_code op,
 			   tree rhs,
@@ -1816,10 +1843,10 @@ class region_model2
 
   region2_id add_new_malloc_region2 ();
 #endif
-  region2 *create_region_for_heap_alloc (svalue2 *size_in_bytes);
-  region2 *create_region_for_alloca (svalue2 *size_in_bytes);
+  const region2 *create_region_for_heap_alloc (const svalue2 *size_in_bytes);
+  const region2 *create_region_for_alloca (const svalue2 *size_in_bytes);
 
-  tree get_representative_tree (svalue2 *sval) const;
+  tree get_representative_tree (const svalue2 *sval) const;
 #if 0
   path_var get_representative_path_var (region2_id rid) const;
   void get_path_vars_for_svalue2 (svalue2_id sid, vec<path_var> *out) const;
@@ -1879,11 +1906,11 @@ class region_model2
 				   struct append_ssa_names_cb_data *data);
 
  private:
-  region2 *get_lvalue_1 (path_var pv,
-			 region_model2_context *ctxt);
-  svalue2 *get_rvalue_1 (path_var pv,
-			 region_model2_context *ctxt);
-  svalue2 *get_store_value (region2 *reg);
+  const region2 *get_lvalue_1 (path_var pv,
+			       region_model2_context *ctxt);
+  const svalue2 *get_rvalue_1 (path_var pv,
+			       region_model2_context *ctxt);
+  const svalue2 *get_store_value (const region2 *reg);
 
 #if 0
   void copy_struct_region2 (region2_id dst_rid, struct_region2 *dst_reg,
@@ -1927,7 +1954,8 @@ class region_model2
 #endif
   void on_top_level_param (tree param, region_model2_context *ctxt);
 
-  void record_dynamic_extents (region2 *reg, svalue2 *size_in_bytes);
+  void record_dynamic_extents (const region2 *reg,
+			       const svalue2 *size_in_bytes);
 
   /* Storing this here to avoid passing it around everywhere.  */
   region_model2_manager *const m_mgr;
@@ -1936,7 +1964,7 @@ class region_model2
 
   constraint_manager2 *m_constraints2; // TODO: embed, rather than dynalloc?
 
-  frame_region2 *m_current_frame;
+  const frame_region2 *m_current_frame;
 };
 
 /* Some region_model2 activity could lead to warnings (e.g. attempts to use an
@@ -1973,7 +2001,7 @@ class region_model2_context
      MAP has already been applied to the IDs, but is provided in case
      the client needs to figure out the old IDs.  */
 #if 0
-  virtual int on_svalue2_purge (svalue2 *purged_value) = 0;
+  virtual int on_svalue2_purge (const svalue2 *purged_value) = 0;
 #endif
 
   virtual logger *get_logger () = 0;
@@ -2024,7 +2052,7 @@ class noop_region_model2_context : public region_model2_context
 public:
   void warn (pending_diagnostic *) OVERRIDE {}
 #if 0
-  int on_svalue2_purge (svalue2 *) OVERRIDE
+  int on_svalue2_purge (const svalue2 *) OVERRIDE
   {
     return 0;
   }
@@ -2205,7 +2233,7 @@ private:
 
 void assert_condition2 (const location &loc,
 			region_model2 &model,
-			svalue2 *lhs, tree_code op, svalue2 *rhs,
+			const svalue2 *lhs, tree_code op, const svalue2 *rhs,
 			tristate expected);
 
 void assert_condition2 (const location &loc,
diff --git a/gcc/analyzer/store2.cc b/gcc/analyzer/store2.cc
index 039177c6267..fa642219f25 100644
--- a/gcc/analyzer/store2.cc
+++ b/gcc/analyzer/store2.cc
@@ -68,7 +68,7 @@ namespace ana {
 /* class binding_key2.  */
 
 const binding_key2 *
-binding_key2::make (store2_manager *mgr, region2 *r, enum kind kind)
+binding_key2::make (store2_manager *mgr, const region2 *r, enum kind kind)
 {
   region_offset offset = r->get_offset ();
   if (offset.symbolic_p ())
@@ -151,7 +151,7 @@ binding_cluster2::operator== (const binding_cluster2 &other) const
     {
       const binding_key2 *key = (*iter).first;
       const svalue2 *sval = (*iter).second;
-      svalue2 **other_slot
+      const svalue2 **other_slot
 	= const_cast <map_t &> (other.m_map).get (key);
       if (other_slot == NULL)
 	return false;
@@ -185,7 +185,7 @@ binding_cluster2::dump_to_pp (pretty_printer *pp, bool simple,
   unsigned i;
   FOR_EACH_VEC_ELT (binding_key2s, i, key)
     {
-      svalue2 *value = *const_cast <map_t &> (m_map).get (key);
+      const svalue2 *value = *const_cast <map_t &> (m_map).get (key);
       if (multiline)
 	{
 	  pp_string (pp, "    key:   {");
@@ -215,7 +215,7 @@ binding_cluster2::dump_to_pp (pretty_printer *pp, bool simple,
 
 void
 binding_cluster2::bind (store2_manager *mgr,
-			region2 *reg, svalue2 *val)
+			const region2 *reg, const svalue2 *val)
 {
   const binding_key2 *binding
     = binding_key2::make (mgr, reg, binding_key2::BK_direct);
@@ -225,7 +225,7 @@ binding_cluster2::bind (store2_manager *mgr,
 /* FIXME.  */
 
 void
-binding_cluster2::clobber_region (store2_manager *mgr, region2 *reg)
+binding_cluster2::clobber_region (store2_manager *mgr, const region2 *reg)
 {
   remove_overlapping_bindings (mgr, reg);
 }
@@ -242,13 +242,13 @@ binding_cluster2::purge_region (store2_manager *mgr, const region2 *reg)
   m_map.remove (binding);
 }
 
-svalue2 *
+const svalue2 *
 binding_cluster2::get_binding (store2_manager *mgr,
-			       region2 *reg,
+			       const region2 *reg,
 			       binding_key2::kind kind) const
 {
   const binding_key2 *binding = binding_key2::make (mgr, reg, kind);
-  svalue2 **slot = const_cast<map_t &> (m_map).get (binding);
+  const svalue2 **slot = const_cast<map_t &> (m_map).get (binding);
   if (slot)
     return *slot;
   return NULL;
@@ -258,7 +258,7 @@ binding_cluster2::get_binding (store2_manager *mgr,
 
 void
 binding_cluster2::get_overlapping_bindings (store2_manager *mgr,
-					    region2 *reg,
+					    const region2 *reg,
 					    auto_vec<const binding_key2 *> *out)
 {
   /* Get the size of REG.  */
@@ -270,7 +270,8 @@ binding_cluster2::get_overlapping_bindings (store2_manager *mgr,
        iter != m_map.end (); ++iter)
     {
       const binding_key2 *iter_key = (*iter).first;
-      if (const concrete_binding2 *ckey = binding->dyn_cast_concrete_binding2 ())
+      if (const concrete_binding2 *ckey
+	    = binding->dyn_cast_concrete_binding2 ())
 	{
 	  if (const concrete_binding2 *iter_ckey
 	      = iter_key->dyn_cast_concrete_binding2 ())
@@ -297,7 +298,7 @@ binding_cluster2::get_overlapping_bindings (store2_manager *mgr,
 
 void
 binding_cluster2::remove_overlapping_bindings (store2_manager *mgr,
-					       region2 *reg)
+					       const region2 *reg)
 {
   auto_vec<const binding_key2 *> bindings;
   get_overlapping_bindings (mgr, reg, &bindings);
@@ -341,14 +342,14 @@ binding_cluster2::redundant_p () const
 
 void
 binding_cluster2::get_representative_path_vars (const region2 *base_reg,
-						svalue2 *sval,
+						const svalue2 *sval,
 						auto_vec<path_var> *out_pvs)
   const
 {
   for (map_t::iterator iter = m_map.begin (); iter != m_map.end (); ++iter)
     {
       const binding_key2 *key = (*iter).first;
-      svalue2 *bound_sval = (*iter).second;
+      const svalue2 *bound_sval = (*iter).second;
       if (bound_sval == sval)
 	{
 	  if (const concrete_binding2 *ckey
@@ -525,21 +526,21 @@ store2::dump_to_pp (pretty_printer *pp, bool summarize, bool multiline) const
     }
 }
 
-svalue2 *
-store2::get_direct_binding (store2_manager *mgr, region2 *reg)
+const svalue2 *
+store2::get_direct_binding (store2_manager *mgr, const region2 *reg)
 {
   return get_binding (mgr, reg, binding_key2::BK_direct);
 }
 
-svalue2 *
-store2::get_default_binding (store2_manager *mgr, region2 *reg)
+const svalue2 *
+store2::get_default_binding (store2_manager *mgr, const region2 *reg)
 {
   return get_binding (mgr, reg, binding_key2::BK_direct);
 }
 
-svalue2 *
+const svalue2 *
 store2::get_binding (store2_manager *mgr,
-		     region2 *reg,
+		     const region2 *reg,
 		     binding_key2::kind kind)
 {
   const region2 *base_reg = reg->get_base_region ();
@@ -550,7 +551,8 @@ store2::get_binding (store2_manager *mgr,
 }
 
 void
-store2::set_value (store2_manager *mgr, region2 *lhs_reg, svalue2 *rhs_sval)
+store2::set_value (store2_manager *mgr, const region2 *lhs_reg,
+		   const svalue2 *rhs_sval)
 {
   remove_overlapping_bindings (mgr, lhs_reg);
 
@@ -571,7 +573,7 @@ store2::set_value (store2_manager *mgr, region2 *lhs_reg, svalue2 *rhs_sval)
 /* FIXME.  */
 
 void
-store2::clobber_region (store2_manager *mgr, region2 *reg)
+store2::clobber_region (store2_manager *mgr, const region2 *reg)
 {
   const region2 *base_reg = reg->get_base_region ();
   binding_cluster2 **slot = m_cluster_map.get (base_reg);
@@ -659,7 +661,7 @@ store2::escaped_p (const region2 *base_reg) const
 /* FIXME.  */
 
 void
-store2::get_representative_path_vars (svalue2 *sval,
+store2::get_representative_path_vars (const svalue2 *sval,
 				      auto_vec<path_var> *out_pvs) const
 {
   gcc_assert (sval);
@@ -677,7 +679,7 @@ store2::get_representative_path_vars (svalue2 *sval,
 /* FIXME.  */
 
 void
-store2::remove_overlapping_bindings (store2_manager *mgr, region2 *reg)
+store2::remove_overlapping_bindings (store2_manager *mgr, const region2 *reg)
 {
   const region2 *base_reg = reg->get_base_region ();
   if (reg == base_reg && !escaped_p (base_reg))
diff --git a/gcc/analyzer/store2.h b/gcc/analyzer/store2.h
index c4c3c8b78c5..5023402a640 100644
--- a/gcc/analyzer/store2.h
+++ b/gcc/analyzer/store2.h
@@ -52,7 +52,7 @@ public:
     return kind == BK_direct ? "direct" : "default";
   }
 
-  static const binding_key2 *make (store2_manager *mgr, region2 *r,
+  static const binding_key2 *make (store2_manager *mgr, const region2 *r,
 				   enum kind kind);
 
   virtual void dump_to_pp (pretty_printer *pp, bool simple) const;
@@ -166,22 +166,23 @@ public:
   void dump_to_pp (pretty_printer *pp, bool simple, bool multiline) const;
 
 #if 1
-  void bind (store2_manager *mgr, region2 *, svalue2 *);
+  void bind (store2_manager *mgr, const region2 *, const svalue2 *);
 #else
   const binding_cluster2 *bind (const extrinsic_state &ext_state,
 			       const region2 *, const svalue2 *) const;
 #endif
 
-  void clobber_region (store2_manager *mgr, region2 *reg);
+  void clobber_region (store2_manager *mgr, const region2 *reg);
   void purge_region (store2_manager *mgr, const region2 *reg);
 
-  svalue2 *get_binding (store2_manager *mgr, region2 *reg,
-			binding_key2::kind kind) const;
+  const svalue2 *get_binding (store2_manager *mgr, const region2 *reg,
+			      binding_key2::kind kind) const;
 
-  void remove_overlapping_bindings (store2_manager *mgr, region2 *reg);
+  void remove_overlapping_bindings (store2_manager *mgr, const region2 *reg);
 
   template <typename T>
-  void for_each_value (void (*cb) (svalue2 *sval, T user_data), T user_data)
+  void for_each_value (void (*cb) (const svalue2 *sval, T user_data),
+		       T user_data)
   {
     for (map_t::iterator iter = m_map.begin (); iter != m_map.end (); ++iter)
       cb ((*iter).second, user_data);
@@ -194,14 +195,14 @@ public:
   bool redundant_p () const;
 
   void get_representative_path_vars (const region2 *base_reg,
-				     svalue2 *sval,
+				     const svalue2 *sval,
 				     auto_vec<path_var> *out_pvs) const;
 
 private:
-  void get_overlapping_bindings (store2_manager *mgr, region2 *reg,
+  void get_overlapping_bindings (store2_manager *mgr, const region2 *reg,
 				 auto_vec<const binding_key2 *> *out);
 
-  typedef hash_map <const binding_key2 *, svalue2 *> map_t;
+  typedef hash_map <const binding_key2 *, const svalue2 *> map_t;
   map_t m_map;
 
   /* Has a pointer to this cluster "escaped" into a part of the program
@@ -232,13 +233,14 @@ public:
 
   void dump_to_pp (pretty_printer *pp, bool summarize, bool multiline) const;
 
-  svalue2 *get_direct_binding (store2_manager *mgr, region2 *reg);
-  svalue2 *get_default_binding (store2_manager *mgr, region2 *reg);
-  svalue2 *get_binding (store2_manager *mgr,
-			region2 *reg, binding_key2::kind kind);
+  const svalue2 *get_direct_binding (store2_manager *mgr, const region2 *reg);
+  const svalue2 *get_default_binding (store2_manager *mgr, const region2 *reg);
+  const svalue2 *get_binding (store2_manager *mgr,
+			      const region2 *reg, binding_key2::kind kind);
 
-  void set_value (store2_manager *mgr, region2 *lhs_reg, svalue2 *rhs_sval);
-  void clobber_region (store2_manager *mgr, region2 *reg);
+  void set_value (store2_manager *mgr, const region2 *lhs_reg,
+		  const svalue2 *rhs_sval);
+  void clobber_region (store2_manager *mgr, const region2 *reg);
   void purge_region (store2_manager *mgr, const region2 *reg);
 
   binding_cluster2 *get_cluster (const region2 *base_reg);
@@ -257,11 +259,11 @@ public:
 
   bool escaped_p (const region2 *reg) const;
 
-  void get_representative_path_vars (svalue2 *sval,
+  void get_representative_path_vars (const svalue2 *sval,
 				     auto_vec<path_var> *out_pvs) const;
 
 private:
-  void remove_overlapping_bindings (store2_manager *mgr, region2 *reg);
+  void remove_overlapping_bindings (store2_manager *mgr, const region2 *reg);
 
   typedef hash_map <const region2 *, binding_cluster2 *> cluster_map_t;
   cluster_map_t m_cluster_map; // TODO: deep copy of this!
-- 
2.26.2

