From 675695224ec4b27b0bd1e3ddb4e7980fef4abd98 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 19 Feb 2021 17:18:23 -0500
Subject: [PATCH 21/23] FIXME: delete dead code

---
 gcc/analyzer/diagnostic-manager.cc | 207 -----------------------------
 1 file changed, 207 deletions(-)

diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 7bd1df64901..c0691b0bc25 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -98,22 +98,6 @@ saved_diagnostic::~saved_diagnostic ()
   delete m_problem;
 }
 
-#if 0
-bool
-saved_diagnostic::operator== (const saved_diagnostic &other) const
-{
-  return (m_sm == other.m_sm
-	  /* We don't compare m_enode.  */
-	  && m_snode == other.m_snode
-	  && m_stmt == other.m_stmt
-	  /* We don't compare m_stmt_finder.  */
-	  && pending_diagnostic::same_tree_p (m_var, other.m_var)
-	  && m_state == other.m_state
-	  && m_d->equal_p (*other.m_d)
-	  && m_trailing_eedge == other.m_trailing_eedge);
-}
-#endif
-
 /* Return a new json::object of the form
    {"sm": optional str,
     "enode": int,
@@ -587,76 +571,6 @@ diagnostic_manager::to_json () const
   return dm_obj;
 }
 
-#if 0
-/* A class for identifying sets of duplicated pending_diagnostic.
-
-   We want to find the simplest dedupe_candidate amongst those that share a
-   dedupe_key.  */
-
-class dedupe_key
-{
-public:
-  dedupe_key (const saved_diagnostic &sd,
-	      const exploded_path &epath)
-  : m_sd (sd), m_stmt (sd.m_stmt)
-  {
-    /* Support deferring the choice of stmt until after an emission path has
-     been built, using an optional stmt_finder.  */
-    if (m_stmt == NULL)
-      {
-	gcc_assert (sd.m_stmt_finder);
-	m_stmt = sd.m_stmt_finder->find_stmt (epath);
-      }
-    gcc_assert (m_stmt);
-  }
-
-  hashval_t hash () const
-  {
-    inchash::hash hstate;
-    hstate.add_ptr (m_stmt);
-    // TODO: m_sd
-    return hstate.end ();
-  }
-  bool operator== (const dedupe_key &other) const
-  {
-    return (m_sd == other.m_sd
-	    && m_stmt == other.m_stmt);
-  }
-
-  const saved_diagnostic &m_sd;
-  const gimple *m_stmt;
-};
-#endif
-
-#if 0
-/* The value of a slot for a dedupe_key within dedupe_winners:
-   the exploded_path for the best candidate for that key, and the
-   number of duplicates seen so far.  */
-
-class dedupe_candidate
-{
-public:
-  // has the exploded_path
-  dedupe_candidate (const shortest_exploded_paths &sp,
-		    saved_diagnostic *sd)
-  : m_epath (sp.get_shortest_path (sd->m_enode)),
-    m_num_dupes (0)
-  {
-  }
-
-  unsigned length () const { return m_epath.length (); }
-  const exploded_path &get_path () const { return m_epath; }
-
-  void add_duplicate () { m_num_dupes++; }
-  int get_num_dupes () const { return m_num_dupes; }
-
-private:
-  exploded_path m_epath;
-public:
-  int m_num_dupes;
-};
-#endif
-
 #if 0
 
 /* FIXME: a way to debug the states within exploded_path::feasible_p.  */
@@ -711,127 +625,6 @@ public:
   pretty_printer *m_event_pp;
   simple_diagnostic_path m_diag_path;
 };
-
-/* A class for deduplicating diagnostics and finding (and emitting) the
-   best diagnostic within each partition.  */
-
-class dedupe_winners
-{
-public:
-  /* Determine an exploded_path for SD using SP and, if it's feasible,
-     determine if it's the best seen so far for its dedupe_key.
-     Retain the winner for each dedupe_key, and discard the rest.  */
-
-  void add (logger *logger,
-	    const shortest_exploded_paths &sp,
-	    const exploded_graph *eg,
-	    saved_diagnostic *sd)
-  {
-    /* Build a dedupe_candidate for SD.
-       This uses SP to build an exploded_path.  */
-    dedupe_candidate *dc = new dedupe_candidate (sp, sd);
-
-    sd->set_epath_length (dc->length ());
-
-    /* Verify that the epath is feasible.
-       State-merging means that not every path in the epath corresponds
-       to a feasible one w.r.t. states.
-       Here we simply check each duplicate saved_diagnostic's
-       shortest_path, and reject any that aren't feasible.
-       This could introduce false negatives, as there could be longer
-       feasible paths within the egraph.  */
-    if (logger)
-      logger->log ("considering %qs at EN: %i, SN: %i",
-		   sd->m_d->get_kind (), sd->m_enode->m_index,
-		   sd->m_snode->m_index);
-
-    feasibility_problem *p = NULL;
-    FIXME_feasibility_debugger dbg;
-    if (dc->get_path ().feasible_p (logger, &p, m_engine, eg, &dbg))
-      {
-	if (logger)
-	  logger->log ("accepting %qs at EN: %i, SN: %i with feasible path",
-		       sd->m_d->get_kind (), sd->m_enode->m_index,
-		       sd->m_snode->m_index);
-	sd->set_feasible ();
-      }
-    else
-      {
-	if (flag_analyzer_feasibility)
-	  {
-	    if (logger)
-	      logger->log ("rejecting %qs at EN: %i, SN: %i"
-			   " due to infeasible path",
-			   sd->m_d->get_kind (), sd->m_enode->m_index,
-			   sd->m_snode->m_index);
-	    dbg.dump (p);
-	    sd->set_infeasible (p);
-	    delete dc;
-	    return;
-	  }
-	else
-	  {
-	    if (logger)
-	      logger->log ("accepting %qs at EN: %i, SN: %i"
-			   " despite infeasible path (due to %qs)",
-			   sd->m_d->get_kind (), sd->m_enode->m_index,
-			   sd->m_snode->m_index,
-			   "-fno-analyzer-feasibility");
-	    sd->set_infeasible (p);
-	  }
-      }
-
-    dedupe_key *key = new dedupe_key (*sd, dc->get_path ());
-    if (dedupe_candidate **slot = m_map.get (key))
-      {
-	if (logger)
-	  logger->log ("already have this dedupe_key");
-
-	(*slot)->add_duplicate ();
-
-	if (dc->length () < (*slot)->length ())
-	  {
-	    /* We've got a shorter path for the key; replace
-	       the current candidate.  */
-	    if (logger)
-	      logger->log ("length %i is better than existing length %i;"
-			   " taking over this dedupe_key",
-			   dc->length (), (*slot)->length ());
-	    dc->m_num_dupes = (*slot)->get_num_dupes ();
-	    delete *slot;
-	    *slot = dc;
-	  }
-	else
-	  /* We haven't beaten the current best candidate;
-	     drop the new candidate.  */
-	  {
-	    if (logger)
-	      logger->log ("length %i isn't better than existing length %i;"
-			   " dropping this candidate",
-			   dc->length (), (*slot)->length ());
-	    delete dc;
-	  }
-	delete key;
-      }
-    else
-      {
-	/* This is the first candidate for this key.  */
-	m_map.put (key, dc);
-	if (logger)
-	  logger->log ("first candidate for this dedupe_key");
-      }
-  }
-
-
-private:
-  engine *m_engine;
-
-  /* This maps from each dedupe_key to a current best dedupe_candidate.  */
-
-  typedef hash_map<const dedupe_key *, dedupe_candidate *,
-		   dedupe_hash_map_traits> map_t;
-  map_t m_map;
-};
 #endif
 
 /* Emit all saved diagnostics.  */
-- 
2.26.2

