From 6b79932125473fd174b9a2e651832687c7362528 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 16 Feb 2021 11:33:46 -0500
Subject: [PATCH 15/23] FIXME: hacking up deduplication

---
 gcc/analyzer/diagnostic-manager.cc |  7 +++++++
 gcc/analyzer/diagnostic-manager.h  | 13 ++++++++++++-
 gcc/analyzer/engine.cc             |  9 +++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc
index 3ed198898ce..ddda1c1a666 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -235,6 +235,8 @@ diagnostic_manager::add_diagnostic (const state_machine *sm,
      through the exploded_graph to the diagnostic.  */
   gcc_assert (enode);
 
+  gcc_unreachable ();
+#if 0
   saved_diagnostic *sd
     = new saved_diagnostic (sm, enode, snode, stmt, finder, var, sval,
 			    state, d);
@@ -243,6 +245,7 @@ diagnostic_manager::add_diagnostic (const state_machine *sm,
     log ("adding saved diagnostic %i at SN %i: %qs",
 	 m_saved_diagnostics.length () - 1,
 	 snode->m_index, d->get_kind ());
+#endif
 }
 
 /* Queue pending_diagnostic D at ENODE for later emission.  */
@@ -265,6 +268,7 @@ diagnostic_manager::to_json () const
 {
   json::object *dm_obj = new json::object ();
 
+#if 0
   {
     json::array *sd_arr = new json::array ();
     int i;
@@ -273,6 +277,7 @@ diagnostic_manager::to_json () const
       sd_arr->append (sd->to_json ());
     dm_obj->set ("diagnostics", sd_arr);
   }
+#endif
 
   return dm_obj;
 }
@@ -644,6 +649,7 @@ diagnostic_manager::emit_saved_diagnostics (const exploded_graph &eg)
 {
   LOG_SCOPE (get_logger ());
   auto_timevar tv (TV_ANALYZER_DIAGNOSTICS);
+#if 0
   log ("# saved diagnostics: %i", m_saved_diagnostics.length ());
   if (get_logger ())
     {
@@ -675,6 +681,7 @@ diagnostic_manager::emit_saved_diagnostics (const exploded_graph &eg)
   /* For each dedupe-key, call emit_saved_diagnostic on the "best"
      saved_diagnostic.  */
   best_candidates.emit_best (this, eg);
+#endif
 }
 
 /* Given a saved_diagnostic SD at STMT with feasible path EPATH through EG,
diff --git a/gcc/analyzer/diagnostic-manager.h b/gcc/analyzer/diagnostic-manager.h
index 9fb952b4228..8852fc95568 100644
--- a/gcc/analyzer/diagnostic-manager.h
+++ b/gcc/analyzer/diagnostic-manager.h
@@ -89,6 +89,15 @@ private:
   feasibility_problem *m_problem;
 };
 
+/* FIXME.
+   An equivalence of saved_diagnostics.  */
+
+class dedupe_set
+{
+public:
+  auto_delete_vec<saved_diagnostic> m_saved_diagnostics;
+};
+
 class path_builder;
 
 /* A class with responsibility for saving pending diagnostics, so that
@@ -131,6 +140,7 @@ public:
 			      const gimple *stmt,
 			      int num_dupes);
 
+#if 0
   unsigned get_num_diagnostics () const
   {
     return m_saved_diagnostics.length ();
@@ -143,6 +153,7 @@ public:
   {
     return m_saved_diagnostics[idx];
   }
+#endif
 
 private:
   void build_emission_path (const path_builder &pb,
@@ -179,7 +190,7 @@ private:
   void finish_pruning (checker_path *path) const;
 
   engine *m_eng;
-  auto_delete_vec<saved_diagnostic> m_saved_diagnostics;
+  auto_delete_vec<dedupe_set> m_dedupe_sets;
   const int m_verbosity;
 };
 
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 2ca9268f4fc..ce32b17711f 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -968,6 +968,7 @@ exploded_node::dump_dot (graphviz_out *gv, const dump_args_t &args) const
 	}
     }
 
+#if 0
   /* Dump any saved_diagnostics at this enode.  */
   {
     const diagnostic_manager &dm = args.m_eg.get_diagnostic_manager ();
@@ -981,6 +982,8 @@ exploded_node::dump_dot (graphviz_out *gv, const dump_args_t &args) const
 	  }
       }
   }
+  // FIXME: maybe have the ECs as dot nodes, and have the diagnostics link to them???
+#endif
 
   pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
 
@@ -1434,7 +1437,9 @@ exploded_node::on_longjmp (exploded_graph &eg,
      any that this adds to show where the longjmp is rewinding to.  */
 
   diagnostic_manager *dm = &eg.get_diagnostic_manager ();
+#if 0
   unsigned prev_num_diagnostics = dm->get_num_diagnostics ();
+#endif
 
   new_region_model->on_longjmp (longjmp_call, setjmp_call,
 				setjmp_point.get_stack_depth (), ctxt);
@@ -1484,12 +1489,14 @@ exploded_node::on_longjmp (exploded_graph &eg,
 
 	 Do this by setting m_trailing_eedge on any diagnostics that were
 	 just saved.  */
+#if 0
       unsigned num_diagnostics = dm->get_num_diagnostics ();
       for (unsigned i = prev_num_diagnostics; i < num_diagnostics; i++)
 	{
 	  saved_diagnostic *sd = dm->get_saved_diagnostic (i);
 	  sd->m_trailing_eedge = eedge;
 	}
+#endif
     }
 }
 
@@ -4613,6 +4620,7 @@ private:
 	break;
       }
     gv->end_tdtr ();
+#if 0
     /* Dump any saved_diagnostics at this enode.  */
     {
       const diagnostic_manager &dm = m_eg.get_diagnostic_manager ();
@@ -4623,6 +4631,7 @@ private:
 	    print_saved_diagnostic (gv, sd);
 	}
     }
+#endif
     pp_printf (pp, "</TABLE>");
     pp_printf (pp, "</TD>");
   }
-- 
2.26.2

