From 5a14d57f99b237edef23168d71b95004b366ab2a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 2 Jul 2019 13:52:48 -0400
Subject: [PATCH 058/108] FIXME: analyzer cleanups

---
 gcc/analyzer/Make-lang.in          |  1 +
 gcc/analyzer/analyzer-pass.cc      | 84 +++++++++++++++++-----------------
 gcc/analyzer/analyzer-plugin.cc    | 39 +++++++++++-----
 gcc/analyzer/analyzer-selftests.cc | 93 ++++++++++++++++++++++++++++++++++++++
 gcc/analyzer/analyzer-selftests.h  | 47 +++++++++++++++++++
 gcc/analyzer/analyzer.cc           | 39 ++++++++--------
 gcc/analyzer/constraint-manager.cc | 19 ++++++++
 gcc/analyzer/impl-4.cc             | 19 ++++++++
 gcc/analyzer/pending-diagnostic.cc | 21 ++++++++-
 gcc/analyzer/pending-diagnostic.h  |  2 +-
 gcc/analyzer/region-model.cc       | 19 ++++++++
 gcc/analyzer/region-model.h        |  2 +-
 gcc/analyzer/sm-file.cc            | 21 ++++++++-
 gcc/analyzer/sm-malloc.cc          | 20 +++++++-
 gcc/analyzer/sm-pattern-test.cc    | 21 +++++++++
 gcc/analyzer/sm-sensitive.cc       | 20 ++++++++
 gcc/analyzer/sm-taint.cc           | 21 +++++++++
 gcc/analyzer/sm.cc                 | 19 ++++++++
 gcc/analyzer/sm.h                  |  5 +-
 gcc/analyzer/tristate.cc           | 20 ++++++++
 20 files changed, 450 insertions(+), 82 deletions(-)
 create mode 100644 gcc/analyzer/analyzer-selftests.cc
 create mode 100644 gcc/analyzer/analyzer-selftests.h

diff --git a/gcc/analyzer/Make-lang.in b/gcc/analyzer/Make-lang.in
index 9f27ff76..58bf520 100644
--- a/gcc/analyzer/Make-lang.in
+++ b/gcc/analyzer/Make-lang.in
@@ -56,6 +56,7 @@ ANALYZER_PLUGIN_SO_OBJS = \
 	analyzer/analyzer-logging.o \
 	analyzer/analyzer-pass.o \
 	analyzer/analyzer-plugin.o \
+	analyzer/analyzer-selftests.o \
 	analyzer/checker-script.o \
 	analyzer/constraint-manager.o \
 	analyzer/digraph.o \
diff --git a/gcc/analyzer/analyzer-pass.cc b/gcc/analyzer/analyzer-pass.cc
index 40989f5..8f7bcd6 100644
--- a/gcc/analyzer/analyzer-pass.cc
+++ b/gcc/analyzer/analyzer-pass.cc
@@ -1,3 +1,22 @@
+/* Integration of the analyzer with GCC's pass manager.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
@@ -31,13 +50,11 @@
 
 namespace {
 
+/* Data for the analyzer pass.  */
+
 const pass_data pass_data_analyzer =
 {
-#if 1
   IPA_PASS, /* type */
-#else
-  GIMPLE_PASS, /* type */
-#endif
   "analyzer", /* name */
   OPTGROUP_NONE, /* optinfo_flags */
   TV_NONE, /* tv_id */
@@ -48,37 +65,30 @@ const pass_data pass_data_analyzer =
   0, /* todo_flags_finish */
 };
 
-class pass_analyzer 
-#if 1
-: public ipa_opt_pass_d
-#else
-: public gimple_opt_pass
-#endif
+/* The analyzer pass.  */
+
+class pass_analyzer : public ipa_opt_pass_d
 {
 public:
    pass_analyzer(gcc::context *ctxt)
-#if 1     
-    : ipa_opt_pass_d (pass_data_analyzer, ctxt,
-		      NULL, /* generate_summary */
-		      NULL, /* write_summary */
-		      NULL, /* read_summary */
-		      NULL, /* write_optimization_summary */
-		      NULL, /* read_optimization_summary */
-		      NULL, /* stmt_fixup */
-		      0, /* function_transform_todo_flags_start */
-		      NULL, /* function_transform */
-		      NULL) /* variable_transform */
-#else
-     : gimple_opt_pass(pass_data_analyzer, ctxt)
-#endif
+   : ipa_opt_pass_d (pass_data_analyzer, ctxt,
+		     NULL, /* generate_summary */
+		     NULL, /* write_summary */
+		     NULL, /* read_summary */
+		     NULL, /* write_optimization_summary */
+		     NULL, /* read_optimization_summary */
+		     NULL, /* stmt_fixup */
+		     0, /* function_transform_todo_flags_start */
+		     NULL, /* function_transform */
+		     NULL) /* variable_transform */
   {}
 
   /* opt_pass methods: */
-  virtual unsigned int execute (function *);
-
- private:
+  unsigned int execute (function *) FINAL OVERRIDE;
 }; // class pass_analyzer
 
+/* Entrypoint for the analyzer pass.  */
+
 unsigned int
 pass_analyzer::execute (function *)
 {
@@ -100,24 +110,22 @@ pass_analyzer::execute (function *)
 
 } // anon namespace
 
-#if 1
+/* Make an instance of the analyzer pass.  */
+
 static ipa_opt_pass_d *
-#else
-static gimple_opt_pass *
-#endif
 make_pass_analyzer (gcc::context *ctxt)
 {
   return new pass_analyzer (ctxt);
 }
 
-/* Called by plugin_init.  */
+/* Register the analyzer pass with GCC's pass manager.
+   Called by plugin_init.  */
 
 void
 register_analyzer_pass ()
 {
   static struct register_pass_info pass_info;
 
-#if 1
   /* IPA-LTO pass.  */
   pass_info.pass = make_pass_analyzer (g);
   pass_info.reference_pass_name = "whole-program";
@@ -126,14 +134,4 @@ register_analyzer_pass ()
 
   register_callback ("analyzer", PLUGIN_PASS_MANAGER_SETUP, NULL,
 		     &pass_info);
-#else
-  /* Self-assign detection should happen after SSA is constructed.  */
-  pass_info.pass = make_pass_analyzer (g);
-  pass_info.reference_pass_name = "ssa";
-  pass_info.ref_pass_instance_number = 1;
-  pass_info.pos_op = PASS_POS_INSERT_AFTER;
-
-  register_callback ("analyzer", PLUGIN_PASS_MANAGER_SETUP, NULL,
-		     &pass_info);
-#endif
 }
diff --git a/gcc/analyzer/analyzer-plugin.cc b/gcc/analyzer/analyzer-plugin.cc
index 86585b8..28edb7e 100644
--- a/gcc/analyzer/analyzer-plugin.cc
+++ b/gcc/analyzer/analyzer-plugin.cc
@@ -1,3 +1,23 @@
+/* Top-level interface to the analyzer, as a GCC plugin.
+   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/>.  */
+
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
@@ -27,6 +47,7 @@
 #include "gimple-pretty-print.h"
 
 #include "analyzer/analyzer.h"
+#include "analyzer/analyzer-selftests.h"
 
 int plugin_is_GPL_compatible;
 
@@ -35,24 +56,17 @@ int plugin_is_GPL_compatible;
 namespace selftest {
 
 static void
-analyzer_selftests (void */*gcc_data*/, void */*user_data*/)
+analyzer_selftests_cb (void */*gcc_data*/, void */*user_data*/)
 {
-#if 0
-  analyzer_checker_script_cc_tests ();
-#endif
-  analyzer_constraint_manager_cc_tests ();
-  analyzer_digraph_cc_tests ();
-  analyzer_impl_2_cc_tests ();
-  analyzer_impl_4_cc_tests ();
-  analyzer_path_state_cc_tests ();
-  analyzer_region_model_cc_tests ();
-  analyzer_tristate_cc_tests ();
+  run_analyzer_selftests ();
 }
 
 } /* end of namespace selftest.  */
 
 #endif /* #if CHECKING_P */
 
+/* Entrypoint to the pass.  */
+
 int
 plugin_init (struct plugin_name_args *plugin_info,
 	     struct plugin_gcc_version */*version*/)
@@ -64,9 +78,10 @@ plugin_init (struct plugin_name_args *plugin_info,
 #if CHECKING_P
   register_callback (plugin_info->base_name,
 		     PLUGIN_RUN_SELFTESTS,
-		     selftest::analyzer_selftests, NULL);
+		     selftest::analyzer_selftests_cb, NULL);
 #endif /* #if CHECKING_P */
 
+  /* Register our pass.  */
   register_analyzer_pass ();
 
   return 0;
diff --git a/gcc/analyzer/analyzer-selftests.cc b/gcc/analyzer/analyzer-selftests.cc
new file mode 100644
index 0000000..cbb9e3f
--- /dev/null
+++ b/gcc/analyzer/analyzer-selftests.cc
@@ -0,0 +1,93 @@
+/* Selftest support for the analyzer.
+   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/>.  */
+
+/* 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 <string>
+#include "stringpool.h"
+#include "analyzer/analyzer-selftests.h"
+
+#if CHECKING_P
+
+namespace selftest {
+
+/* Build a VAR_DECL named NAME of type TYPE, simulating a file-level
+   static variable.  */
+
+tree
+build_global_decl (const char *name, tree type)
+{
+  tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
+			  get_identifier (name), type);
+  TREE_STATIC (decl) = 1;
+  return decl;
+}
+
+/* Run all analyzer-specific selftests.  */
+
+void
+run_analyzer_selftests ()
+{
+#if 0
+  analyzer_checker_script_cc_tests ();
+#endif
+  analyzer_constraint_manager_cc_tests ();
+  analyzer_digraph_cc_tests ();
+  analyzer_impl_2_cc_tests ();
+  analyzer_impl_4_cc_tests ();
+  analyzer_path_state_cc_tests ();
+  analyzer_region_model_cc_tests ();
+  analyzer_tristate_cc_tests ();
+}
+
+} /* end of namespace selftest.  */
+
+#endif /* #if CHECKING_P */
diff --git a/gcc/analyzer/analyzer-selftests.h b/gcc/analyzer/analyzer-selftests.h
new file mode 100644
index 0000000..e29da5a
--- /dev/null
+++ b/gcc/analyzer/analyzer-selftests.h
@@ -0,0 +1,47 @@
+/* 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_SELFTESTS_H
+#define GCC_ANALYZER_SELFTESTS_H
+
+#if CHECKING_P
+
+namespace selftest {
+
+extern tree build_global_decl (const char *name, tree type);
+
+extern void run_analyzer_selftests ();
+
+/* Declarations for specific families of tests (by source file), in
+   alphabetical order, for the checker plugin.  */
+extern void analyzer_checker_script_cc_tests ();
+extern void analyzer_constraint_manager_cc_tests ();
+extern void analyzer_digraph_cc_tests ();
+extern void analyzer_impl_2_cc_tests ();
+extern void analyzer_impl_4_cc_tests ();
+extern void analyzer_path_state_cc_tests ();
+extern void analyzer_region_model_cc_tests ();
+extern void analyzer_tristate_cc_tests ();
+
+} /* end of namespace selftest.  */
+
+#endif /* #if CHECKING_P */
+
+#endif /* GCC_ANALYZER_SELFTESTS_H */
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc
index 1834b3f..3cac7f5 100644
--- a/gcc/analyzer/analyzer.cc
+++ b/gcc/analyzer/analyzer.cc
@@ -1,3 +1,22 @@
+/* Utility functions for the analyzer.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
@@ -128,23 +147,3 @@ expr_to_string (tree t)
   free (tmp);
   return result;
 }
-
-#if CHECKING_P
-
-namespace selftest {
-
-/* Build a VAR_DECL named NAME of type TYPE, simulating a file-level
-   static variable.  */
-
-tree
-build_global_decl (const char *name, tree type)
-{
-  tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
-			  get_identifier (name), type);
-  TREE_STATIC (decl) = 1;
-  return decl;
-}
-
-} /* end of namespace selftest.  */
-
-#endif /* #if CHECKING_P */
diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index 8a159bb..97a4c60 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -1,3 +1,22 @@
+/* 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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/impl-4.cc b/gcc/analyzer/impl-4.cc
index 0aeb76c..b2695e6 100644
--- a/gcc/analyzer/impl-4.cc
+++ b/gcc/analyzer/impl-4.cc
@@ -1,3 +1,22 @@
+/* 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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/pending-diagnostic.cc b/gcc/analyzer/pending-diagnostic.cc
index bf2efc5..a07339b 100644
--- a/gcc/analyzer/pending-diagnostic.cc
+++ b/gcc/analyzer/pending-diagnostic.cc
@@ -1,3 +1,22 @@
+/* Classes for analyzer diagnostics.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
@@ -31,8 +50,6 @@
 #include "cgraph.h"
 #include "diagnostic-path.h"
 #include "gcc-rich-location.h"
-#include <string>
-#include "analyzer/supergraph.h"
 #include "analyzer/pending-diagnostic.h"
 
 label_text
diff --git a/gcc/analyzer/pending-diagnostic.h b/gcc/analyzer/pending-diagnostic.h
index a63b824..8cdabd2 100644
--- a/gcc/analyzer/pending-diagnostic.h
+++ b/gcc/analyzer/pending-diagnostic.h
@@ -1,4 +1,4 @@
-/* FIXME.
+/* Classes for analyzer diagnostics.
    Copyright (C) 2019 Free Software Foundation, Inc.
    Contributed by David Malcolm <dmalcolm@redhat.com>.
 
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 5634e0b..932b4af 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -1,3 +1,22 @@
+/* Classes for modeling the state of memory.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 4ed7f01..061c826 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -1,4 +1,4 @@
-/* FIXME.
+/* Classes for modeling the state of memory.
    Copyright (C) 2019 Free Software Foundation, Inc.
    Contributed by David Malcolm <dmalcolm@redhat.com>.
 
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc
index 7d3b747..26e6466 100644
--- a/gcc/analyzer/sm-file.cc
+++ b/gcc/analyzer/sm-file.cc
@@ -1,4 +1,23 @@
-/* A state machine for detecting misuses of <stdio.h>'s FILE * API.  */
+/* A state machine for detecting misuses of <stdio.h>'s FILE * API.
+   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/>.  */
+
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index 5d3c333..a3f0736 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -1,4 +1,22 @@
-/* A state machine for detecting misuses of the malloc/free API.  */
+/* A state machine for detecting misuses of the malloc/free API.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm-pattern-test.cc b/gcc/analyzer/sm-pattern-test.cc
index 5e4c8a6..5025e3a 100644
--- a/gcc/analyzer/sm-pattern-test.cc
+++ b/gcc/analyzer/sm-pattern-test.cc
@@ -1,3 +1,24 @@
+/* A state machine for use in DejaGnu tests, to check that
+   pattern-matching works as expected.
+
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc
index c998da5..a8d899e 100644
--- a/gcc/analyzer/sm-sensitive.cc
+++ b/gcc/analyzer/sm-sensitive.cc
@@ -1,3 +1,23 @@
+/* An experimental state machine, for tracking exposure of sensitive
+   data (e.g. through logging).
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc
index c2deb7f..4275a1b 100644
--- a/gcc/analyzer/sm-taint.cc
+++ b/gcc/analyzer/sm-taint.cc
@@ -1,3 +1,24 @@
+/* An experimental state machine, for tracking "taint": unsanitized uses
+   of data potentially under an attacker's control.
+
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm.cc b/gcc/analyzer/sm.cc
index 539986a..8efc598 100644
--- a/gcc/analyzer/sm.cc
+++ b/gcc/analyzer/sm.cc
@@ -1,3 +1,22 @@
+/* Modeling API uses and misuses via state machines.
+   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/>.  */
 /* FIXME.  */
 #include "config.h"
 #include "gcc-plugin.h"
diff --git a/gcc/analyzer/sm.h b/gcc/analyzer/sm.h
index cd2e4a3..a973545 100644
--- a/gcc/analyzer/sm.h
+++ b/gcc/analyzer/sm.h
@@ -1,4 +1,4 @@
-/* FIXME.
+/* Modeling API uses and misuses via state machines.
    Copyright (C) 2019 Free Software Foundation, Inc.
    Contributed by David Malcolm <dmalcolm@redhat.com>.
 
@@ -23,6 +23,9 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "analyzer/analyzer-logging.h"
 
+class supernode;
+class superedge;
+
 ////////////////////////////////////////////////////////////////////////////
 
 /* Utility functions for use by state machines.  */
diff --git a/gcc/analyzer/tristate.cc b/gcc/analyzer/tristate.cc
index ebc2555..e829cd5 100644
--- a/gcc/analyzer/tristate.cc
+++ b/gcc/analyzer/tristate.cc
@@ -1,3 +1,23 @@
+/* "True" vs "False" vs "Unknown".
+   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/>.  */
+
 #include "config.h"
 #include "gcc-plugin.h"
 #include "system.h"
-- 
1.8.5.3

