From e46730d830373daba5076a0ed103c09e245311eb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 26 Sep 2019 15:37:39 -0400
Subject: [PATCH 124/124] FIXME: eliminate the rest of path-state.cc/h

---
 gcc/analyzer/Make-lang.in          |  1 -
 gcc/analyzer/analyzer-selftests.cc |  3 --
 gcc/analyzer/constraint-manager.cc |  1 -
 gcc/analyzer/engine.cc             |  1 -
 gcc/analyzer/engine.h              | 25 ++++++++++++++++
 gcc/analyzer/path-state.cc         | 59 --------------------------------------
 gcc/analyzer/path-state.h          | 55 -----------------------------------
 gcc/analyzer/region-model.cc       | 20 ++++++++++++-
 gcc/analyzer/region-model.h        | 32 +++++++++++++++++++++
 9 files changed, 76 insertions(+), 121 deletions(-)
 delete mode 100644 gcc/analyzer/path-state.cc
 delete mode 100644 gcc/analyzer/path-state.h

diff --git a/gcc/analyzer/Make-lang.in b/gcc/analyzer/Make-lang.in
index 8ef62a3..e298043 100644
--- a/gcc/analyzer/Make-lang.in
+++ b/gcc/analyzer/Make-lang.in
@@ -62,7 +62,6 @@ ANALYZER_PLUGIN_SO_OBJS = \
 	analyzer/digraph.o \
 	analyzer/graphviz.o \
 	analyzer/engine.o \
-	analyzer/path-state.o \
 	analyzer/pending-diagnostic.o \
 	analyzer/region-model.o \
 	analyzer/sm.o \
diff --git a/gcc/analyzer/analyzer-selftests.cc b/gcc/analyzer/analyzer-selftests.cc
index 4a8fbff..abaef7e 100644
--- a/gcc/analyzer/analyzer-selftests.cc
+++ b/gcc/analyzer/analyzer-selftests.cc
@@ -76,9 +76,6 @@ build_global_decl (const char *name, tree type)
 void
 run_analyzer_selftests ()
 {
-#if 0
-  analyzer_checker_script_cc_tests ();
-#endif
   analyzer_constraint_manager_cc_tests ();
   analyzer_digraph_cc_tests ();
   analyzer_engine_cc_tests ();
diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index 71cb612..64a34a0 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -57,7 +57,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "selftest.h"
 #include "fold-const.h"
 #include "analyzer/tristate.h"
-#include "analyzer/path-state.h"
 #include "analyzer/supergraph.h"
 #include "analyzer/constraint-manager.h"
 #include "analyzer/analyzer-selftests.h"
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 990ec31..1a17106 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -60,7 +60,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "fold-const.h"
 #include "analyzer/tristate.h"
 #include "analyzer/digraph.h"
-#include "analyzer/path-state.h"
 #include "tree-ssa-operands.h"
 #include "tree-vrp.h"
 #include "gimple-ssa.h"
diff --git a/gcc/analyzer/engine.h b/gcc/analyzer/engine.h
index 6e7d60b..898d9a5 100644
--- a/gcc/analyzer/engine.h
+++ b/gcc/analyzer/engine.h
@@ -1 +1,26 @@
+/* FIXME.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   Contributed by David Malcolm <dmalcolm@redhat.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_ANALYZER_ENGINE_H
+#define GCC_ANALYZER_ENGINE_H
+
 extern void run_checkers ();
+
+#endif /* GCC_ANALYZER_ENGINE_H */
diff --git a/gcc/analyzer/path-state.cc b/gcc/analyzer/path-state.cc
deleted file mode 100644
index 25f72e4..0000000
--- a/gcc/analyzer/path-state.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-/* FIXME.  */
-#include "config.h"
-#include "gcc-plugin.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tree.h"
-#include "tm.h"
-#include "toplev.h"
-#include "hash-table.h"
-#include "vec.h"
-#include "ggc.h"
-#include "basic-block.h"
-#include "tree-ssa-alias.h"
-#include "internal-fn.h"
-#include "gimple-fold.h"
-#include "tree-eh.h"
-#include "gimple-expr.h"
-#include "is-a.h"
-#include "gimple.h"
-#include "tree-pass.h"
-#include "intl.h"
-#include "context.h"
-#include "diagnostic.h"
-#include "bitmap.h"
-#include "gimple.h"
-#include "gimple-iterator.h"
-#include "gimple-pretty-print.h"
-#include "tree-pretty-print.h"
-#include "analyzer.h"
-#include "graphviz.h"
-#include "cgraph.h"
-#include "diagnostic-path.h"
-#include "gcc-rich-location.h"
-#include "tree-dfa.h"
-#include <string>
-#include "analyzer/analyzer-logging.h"
-#include "stringpool.h"
-#include "selftest.h"
-#include "fold-const.h"
-#include "analyzer/tristate.h"
-#include "analyzer/path-state.h"
-#include "analyzer/supergraph.h"
-
-/* FIXME.  */
-
-std::string
-path_var::to_str () const
-{
-  if (m_tree == NULL_TREE)
-    return "NULL";
-  if (CONSTANT_CLASS_P (m_tree))
-    return expr_to_string (m_tree);
-  else
-    return (std::string ("(")
-	    + expr_to_string (m_tree)
-	    + " @ "
-	    + std::to_string (m_stack_depth)
-	    + ")");
-}
diff --git a/gcc/analyzer/path-state.h b/gcc/analyzer/path-state.h
deleted file mode 100644
index fd836c1..0000000
--- a/gcc/analyzer/path-state.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Tracking equivalence classes and constraints at a point on an execution path.
-   Copyright (C) 2019 Free Software Foundation, Inc.
-   Contributed by David Malcolm <dmalcolm@redhat.com>.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#ifndef GCC_ANALYZER_PATH_STATE_H
-#define GCC_ANALYZER_PATH_STATE_H
-
-/* A tree, extended with stack frame information for locals, so that
-   we can distinguish between different values of locals within a potentially
-   recursive callstack.  */
-// FIXME: would this be better as a new tree code?
-
-class path_var
-{
-public:
-  path_var (tree t, int stack_depth)
-  : m_tree (t), m_stack_depth (stack_depth)
-  {
-    // TODO: ignore stack depth for globals and constants
-  }
-
-  bool operator== (const path_var &other) const
-  {
-    return (m_tree == other.m_tree
-	    && m_stack_depth == other.m_stack_depth);
-  }
-
-  std::string to_str () const;
-
-  tree m_tree;
-  int m_stack_depth; // or -1 for globals?
-};
-
-namespace inchash
-{
-  extern void add_path_var (path_var pv, hash &hstate);
-} // namespace inchash
-
-#endif /* GCC_ANALYZER_PATH_STATE_H */
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 8939f41..33900bb 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -57,7 +57,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "selftest.h"
 #include "fold-const.h"
 #include "analyzer/tristate.h"
-#include "analyzer/path-state.h"
 #include "analyzer/supergraph.h"
 #include "analyzer/region-model.h"
 #include "tree-diagnostic.h"
@@ -71,6 +70,25 @@ along with GCC; see the file COPYING3.  If not see
 
 /* FIXME.  */
 
+std::string
+path_var::to_str () const
+{
+  if (m_tree == NULL_TREE)
+    return "NULL";
+  if (CONSTANT_CLASS_P (m_tree))
+    return expr_to_string (m_tree);
+  else
+    return (std::string ("(")
+	    + expr_to_string (m_tree)
+	    + " @ "
+	    + std::to_string (m_stack_depth)
+	    + ")");
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+/* FIXME.  */
+
 static void
 dump_separator (pretty_printer *pp, bool *is_first)
 {
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 36ad1b0..f90cb2b 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -45,6 +45,38 @@ class pending_diagnostic;
 
 class constraint_manager;
 
+/* A tree, extended with stack frame information for locals, so that
+   we can distinguish between different values of locals within a potentially
+   recursive callstack.  */
+// FIXME: would this be better as a new tree code?
+
+class path_var
+{
+public:
+  path_var (tree t, int stack_depth)
+  : m_tree (t), m_stack_depth (stack_depth)
+  {
+    // TODO: ignore stack depth for globals and constants
+  }
+
+  bool operator== (const path_var &other) const
+  {
+    return (m_tree == other.m_tree
+	    && m_stack_depth == other.m_stack_depth);
+  }
+
+  std::string to_str () const;
+
+  tree m_tree;
+  int m_stack_depth; // or -1 for globals?
+};
+
+namespace inchash
+{
+  extern void add_path_var (path_var pv, hash &hstate);
+} // namespace inchash
+
+
 /* A region_model is effectively a graph of regions and symbolic values.
    We store per-model IDs rather than pointers to make it easier to clone
    and to compare graphs.  */
-- 
1.8.5.3

