From 1830c4dd0661168ef3d822534368c6dbf86d7090 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 21 Jun 2019 17:46:32 -0400
Subject: [PATCH 46/47] FIXME: various cleanups

---
 gcc/analyzer/impl-4.cc       | 21 ++++++++++++++-------
 gcc/analyzer/region-model.cc | 28 +++++++++++++++++++---------
 gcc/analyzer/supergraph.h    | 12 +++++++++---
 gcc/analyzer/tristate.cc     |  6 +++---
 4 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/gcc/analyzer/impl-4.cc b/gcc/analyzer/impl-4.cc
index 498bec6..784bea5 100644
--- a/gcc/analyzer/impl-4.cc
+++ b/gcc/analyzer/impl-4.cc
@@ -2655,17 +2655,21 @@ readability (const_tree expr)
     {
     case COMPONENT_REF:
     case MEM_REF:
+      /* Impose a slight readability penalty relative to that of
+	 operand 0.  */
       return readability (TREE_OPERAND (expr, 0)) - 1;
 
     case SSA_NAME:
       {
 	if (tree var = SSA_NAME_VAR (expr))
 	  return readability (var);
+	/* Avoid printing '<unknown>' for SSA names for temporaries.  */
 	return -1;
       }
       break;
 
     case VAR_DECL:
+      /* Arbitrarily-chosen "high readability" value.  */
       return 256;
 
     default:
@@ -2675,9 +2679,8 @@ readability (const_tree expr)
   return 0;
 }
 
-// FIXME:
-/* A qsort comparator for trees for use by exploded_node::detect_leaks,
-   to sort them into most user-readable to least user-readable.  */
+/* A qsort comparator for trees to sort them into most user-readable to
+   least user-readable.  */
 
 static int
 readability_comparator (const void *p1, const void *p2)
@@ -2766,7 +2769,9 @@ impl_region_model_context::on_inherited_svalue (svalue_id parent_sid,
 
 ////////////////////////////////////////////////////////////////////////////
 
-/* FIXME.  */
+/* class program_state.  */
+
+/* program_state's ctor.  */
 
 program_state::program_state (const extrinsic_state &ext_state)
 : m_region_model (new region_model ())
@@ -2776,7 +2781,7 @@ program_state::program_state (const extrinsic_state &ext_state)
     m_checker_states.safe_push (new sm_state_map ());
 }
 
-/* FIXME.  */
+/* program_state's copy ctor.  */
 
 program_state::program_state (const program_state &other)
 : m_region_model (new region_model (*other.m_region_model))
@@ -2787,7 +2792,7 @@ program_state::program_state (const program_state &other)
     m_checker_states.safe_push (smap->clone ());
 }
 
-/* FIXME.  */
+/* program_state's assignment operator.  */
 
 program_state&
 program_state::operator= (const program_state &other)
@@ -3580,7 +3585,9 @@ program_state::on_edge (exploded_graph &eg,
 
 ////////////////////////////////////////////////////////////////////////////
 
-/* FIXME.  */
+/* class exploded_edge : public dedge.  */
+
+/* exploded_edge's ctor.  */
 
 exploded_edge::exploded_edge (exploded_node *src, exploded_node *dest,
 			      const superedge *sedge)
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 8c0fdd9..5e3daec 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -756,8 +756,8 @@ region::hash () const
 
 void
 region::print (const region_model &model,
-		   region_id this_rid,
-		   pretty_printer *pp) const
+	       region_id this_rid,
+	       pretty_printer *pp) const
 {
   this_rid.print (pp);
   pp_string (pp, ": {");
@@ -2967,8 +2967,11 @@ region_model::update_for_return_superedge (const return_superedge &return_edge,
 }
 
 /* Given a true or false edge guarded by conditional statement COND_STMT,
-   add appropriate constraints from the conditional and return true,
-   or return false if the constraints contradict existing knowledge
+   determine appropriate constraints for the edge to be taken.
+
+   If they are feasible, add the constraints and return true.
+
+   Return false if the constraints contradict existing knowledge
    (and so the edge should not be taken).  */
 
 bool
@@ -2988,7 +2991,13 @@ region_model::apply_constraints_for_gcond (const superedge &edge,
   return add_constraint (lhs, op, rhs, ctxt);
 }
 
-/* FIXME.  */
+/* Given an EDGE guarded by SWITCH_STMT, determine appropriate constraints
+   for the edge to be taken.
+
+   If they are feasible, add the constraints and return true.
+
+   Return false if the constraints contradict existing knowledge
+   (and so the edge should not be taken).  */
 
 bool
 region_model::apply_constraints_for_gswitch (const superedge &edge,
@@ -3126,7 +3135,7 @@ region_model::replace_svalue (svalue_id sid, svalue *new_sval)
   m_svalues[idx] = new_sval;
 }
 
-/* FIXME.  */
+/* Add region R to this model, returning its region_id.  */
 
 region_id
 region_model::add_region (region *r)
@@ -3136,7 +3145,7 @@ region_model::add_region (region *r)
   return region_id::from_int (m_regions.length () - 1);
 }
 
-/* FIXME.  */
+/* Return the svalue with id SVAL_ID, or NULL for a null id.  */
 
 svalue *
 region_model::get_svalue (svalue_id sval_id) const
@@ -3146,7 +3155,7 @@ region_model::get_svalue (svalue_id sval_id) const
   return m_svalues[sval_id.as_int ()];
 }
 
-/* FIXME.  */
+/* Return the region with id RID, or NULL for a null id.  */
 
 region *
 region_model::get_region (region_id rid) const
@@ -3509,7 +3518,8 @@ inchash::add (region_id rid, inchash::hash &hstate)
 }
 
 // FIXME:
-void
+
+DEBUG_FUNCTION void
 debug (const region_model &rmodel)
 {
   fprintf (stderr, "%s\n", rmodel.to_str ().c_str ());
diff --git a/gcc/analyzer/supergraph.h b/gcc/analyzer/supergraph.h
index 01a0cb4..6caf015 100644
--- a/gcc/analyzer/supergraph.h
+++ b/gcc/analyzer/supergraph.h
@@ -35,7 +35,7 @@ class dot_annotator;
 
 class logger;
 
-/* FIXME.  */
+/* An enum for discriminating between superedge subclasses.  */
 
 enum edge_kind
 {
@@ -180,7 +180,7 @@ private:
   stmt_to_node_t m_stmt_to_node_t;
 };
 
-/* FIXME.  */
+/* A node within a supergraph.  */
 
 class supernode
 {
@@ -253,7 +253,7 @@ class supernode
   const int m_index; /* unique within the supergraph as a whole.  */
 };
 
-/* FIXME.  */
+/* An abstract base class encapsulating an edge within a supergraph.  */
 
 class superedge
 {
@@ -354,6 +354,9 @@ class callgraph_superedge : public superedge
   cgraph_edge *const m_cedge;
 };
 
+/* A subclass of superedge corresponding to the edge for an
+   interprocedural call.  */
+
 class call_superedge : public callgraph_superedge
 {
  public:
@@ -386,6 +389,9 @@ class call_superedge : public callgraph_superedge
   }
 };
 
+/* A subclass of superedge corresponding to the edge for an
+   interprocedural return.  */
+
 class return_superedge : public callgraph_superedge
 {
  public:
diff --git a/gcc/analyzer/tristate.cc b/gcc/analyzer/tristate.cc
index aa7ef11..7e16418 100644
--- a/gcc/analyzer/tristate.cc
+++ b/gcc/analyzer/tristate.cc
@@ -125,7 +125,7 @@ test_ctors ()
   ASSERT_NE (t, f);
 }
 
-/* FIXME.  */
+/* Test && on tristate instances.  */
 
 static void
 test_and ()
@@ -144,7 +144,7 @@ test_and ()
   ASSERT_TRISTATE_FALSE (tristate (false) && tristate::unknown ());
 }
 
-/* FIXME.  */
+/* Test || on tristate instances.  */
 
 static void
 test_or ()
@@ -163,7 +163,7 @@ test_or ()
   ASSERT_TRISTATE_UNKNOWN (tristate (false) || tristate::unknown ());
 }
 
-/* FIXME.  */
+/* Test ! on tristate instances.  */
 
 static void
 test_not ()
-- 
1.8.5.3

