analyzer: widening_svalues take a function_point rather than a program_point
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 5 Oct 2022 00:19:06 +0000 (20:19 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 5 Oct 2022 00:19:06 +0000 (20:19 -0400)
Enabling work towrads better call summarization.

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::get_or_create_widening_svalue): Use a
function_point rather than a program_point.
* region-model.cc (selftest::test_widening_constraints): Likewise.
* region-model.h
(region_model_manager::get_or_create_widening_svalue): Likewise.
(model_merger::get_function_point): New.
* svalue.cc (svalue::can_merge_p): Use a function_point rather
than a program_point.
(svalue::can_merge_p): Likewise.
* svalue.h (widening_svalue::key_t): Likewise.
(widening_svalue::widening_svalue): Likewise.

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

index cbda77f..ed5b9c7 100644 (file)
@@ -1143,10 +1143,11 @@ region_model_manager::get_or_create_unmergeable (const svalue *arg)
    and ITER_SVAL at POINT, creating it if necessary.  */
 
 const svalue *
-region_model_manager::get_or_create_widening_svalue (tree type,
-                                                    const program_point &point,
-                                                    const svalue *base_sval,
-                                                    const svalue *iter_sval)
+region_model_manager::
+get_or_create_widening_svalue (tree type,
+                              const function_point &point,
+                              const svalue *base_sval,
+                              const svalue *iter_sval)
 {
   gcc_assert (base_sval->get_kind () != SK_WIDENING);
   gcc_assert (iter_sval->get_kind () != SK_WIDENING);
index 22c5287..e92bba2 100644 (file)
@@ -7956,7 +7956,7 @@ static void
 test_widening_constraints ()
 {
   region_model_manager mgr;
-  program_point point (program_point::origin (mgr));
+  function_point point (program_point::origin (mgr).get_function_point ());
   tree int_0 = build_int_cst (integer_type_node, 0);
   tree int_m1 = build_int_cst (integer_type_node, -1);
   tree int_1 = build_int_cst (integer_type_node, 1);
index e86720a..baac7ba 100644 (file)
@@ -278,7 +278,7 @@ public:
                                           const svalue *inner_svalue);
   const svalue *get_or_create_unmergeable (const svalue *arg);
   const svalue *get_or_create_widening_svalue (tree type,
-                                              const program_point &point,
+                                              const function_point &point,
                                               const svalue *base_svalue,
                                               const svalue *iter_svalue);
   const svalue *get_or_create_compound_svalue (tree type,
@@ -1282,6 +1282,10 @@ struct model_merger
   }
 
   bool mergeable_svalue_p (const svalue *) const;
+  const function_point &get_function_point () const
+  {
+    return m_point.get_function_point ();
+  }
 
   const region_model *m_model_a;
   const region_model *m_model_b;
index f5a5f1c..a37c152 100644 (file)
@@ -207,7 +207,7 @@ svalue::can_merge_p (const svalue *other,
   if (maybe_get_constant () && other->maybe_get_constant ())
     {
       return mgr->get_or_create_widening_svalue (other->get_type (),
-                                                merger->m_point,
+                                                merger->get_function_point (),
                                                 other, this);
     }
 
@@ -220,7 +220,7 @@ svalue::can_merge_p (const svalue *other,
        && binop_sval->get_arg1 ()->get_kind () == SK_CONSTANT
        && other->get_kind () != SK_WIDENING)
       return mgr->get_or_create_widening_svalue (other->get_type (),
-                                                merger->m_point,
+                                                merger->get_function_point (),
                                                 other, this);
 
   /* Merge: (Widen(existing_val, V), existing_val) -> Widen (existing_val, V)
index f4cab0d..9393d6e 100644 (file)
@@ -1113,9 +1113,9 @@ public:
   /* A support class for uniquifying instances of widening_svalue.  */
   struct key_t
   {
-    key_t (tree type, const program_point &point,
+    key_t (tree type, const function_point &point,
           const svalue *base_sval, const svalue *iter_sval)
-    : m_type (type), m_point (point.get_function_point ()),
+    : m_type (type), m_point (point),
       m_base_sval (base_sval), m_iter_sval (iter_sval)
     {}
 
@@ -1153,12 +1153,12 @@ public:
      DIR_UNKNOWN
     };
 
-  widening_svalue (tree type, const program_point &point,
+  widening_svalue (tree type, const function_point &point,
                   const svalue *base_sval, const svalue *iter_sval)
   : svalue (complexity::from_pair (base_sval->get_complexity (),
                                   iter_sval->get_complexity ()),
            type),
-    m_point (point.get_function_point ()),
+    m_point (point),
     m_base_sval (base_sval), m_iter_sval (iter_sval)
   {
     gcc_assert (base_sval->can_have_associated_state_p ());