analyzer: introduce namespace to avoid ODR clashes (PR 93307)
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 17 Jan 2020 14:50:33 +0000 (09:50 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 22 Jan 2020 19:18:31 +0000 (14:18 -0500)
PR analyzer/93307 reports that in an LTO bootstrap, there are ODR
violations between:
- the "region" type:
    gcc/analyzer/region-model.h:792
  vs:
    gcc/sched-int.h:1443
- the "constraint" type:
    gcc/analyzer/constraint-manager.h:121
  vs:
    gcc/tree-ssa-structalias.c:533

This patches solves this clash by putting all of the analyzer names
within a namespace.  I chose "ana" as it is short (to save typing).
The analyzer selftests are moved from namespace "selftest" to
"ana::selftest".

There are various places where the namespace has to be closed
and reopened, to allow e.g. for specializations of templates
in the global namespace.

gcc/analyzer/ChangeLog:
PR analyzer/93307
* analysis-plan.h: Wrap everything namespace "ana".
* analyzer-logging.cc: Likewise.
* analyzer-logging.h: Likewise.
* analyzer-pass.cc (pass_analyzer::execute): Update for "ana"
namespace.
* analyzer-selftests.cc: Wrap everything namespace "ana".
* analyzer-selftests.h: Likewise.
* analyzer.h: Likewise for forward decls of types.
* call-string.h: Likewise.
* checker-path.cc: Likewise.
* checker-path.h: Likewise.
* constraint-manager.cc: Likewise.
* constraint-manager.h: Likewise.
* diagnostic-manager.cc: Likewise.
* diagnostic-manager.h: Likewise.
* engine.cc: Likewise.
* engine.h: Likewise.
* exploded-graph.h: Likewise.
* function-set.cc: Likewise.
* function-set.h: Likewise.
* pending-diagnostic.cc: Likewise.
* pending-diagnostic.h: Likewise.
* program-point.cc: Likewise.
* program-point.h: Likewise.
* program-state.cc: Likewise.
* program-state.h: Likewise.
* region-model.cc: Likewise.
* region-model.h: Likewise.
* sm-file.cc: Likewise.
* sm-malloc.cc: Likewise.
* sm-pattern-test.cc: Likewise.
* sm-sensitive.cc: Likewise.
* sm-signal.cc: Likewise.
* sm-taint.cc: Likewise.
* sm.cc: Likewise.
* sm.h: Likewise.
* state-purge.h: Likewise.
* supergraph.cc: Likewise.
* supergraph.h: Likewise.

gcc/ChangeLog:
PR analyzer/93307
* gdbinit.in (break-on-saved-diagnostic): Update for move of
diagnostic_manager into "ana" namespace.
* selftest-run-tests.c (selftest::run_tests): Update for move of
selftest::run_analyzer_selftests to
ana::selftest::run_analyzer_selftests.

42 files changed:
gcc/ChangeLog
gcc/analyzer/ChangeLog
gcc/analyzer/analysis-plan.h
gcc/analyzer/analyzer-logging.cc
gcc/analyzer/analyzer-logging.h
gcc/analyzer/analyzer-pass.cc
gcc/analyzer/analyzer-selftests.cc
gcc/analyzer/analyzer-selftests.h
gcc/analyzer/analyzer.h
gcc/analyzer/call-string.h
gcc/analyzer/checker-path.cc
gcc/analyzer/checker-path.h
gcc/analyzer/constraint-manager.cc
gcc/analyzer/constraint-manager.h
gcc/analyzer/diagnostic-manager.cc
gcc/analyzer/diagnostic-manager.h
gcc/analyzer/engine.cc
gcc/analyzer/engine.h
gcc/analyzer/exploded-graph.h
gcc/analyzer/function-set.cc
gcc/analyzer/function-set.h
gcc/analyzer/pending-diagnostic.cc
gcc/analyzer/pending-diagnostic.h
gcc/analyzer/program-point.cc
gcc/analyzer/program-point.h
gcc/analyzer/program-state.cc
gcc/analyzer/program-state.h
gcc/analyzer/region-model.cc
gcc/analyzer/region-model.h
gcc/analyzer/sm-file.cc
gcc/analyzer/sm-malloc.cc
gcc/analyzer/sm-pattern-test.cc
gcc/analyzer/sm-sensitive.cc
gcc/analyzer/sm-signal.cc
gcc/analyzer/sm-taint.cc
gcc/analyzer/sm.cc
gcc/analyzer/sm.h
gcc/analyzer/state-purge.h
gcc/analyzer/supergraph.cc
gcc/analyzer/supergraph.h
gcc/gdbinit.in
gcc/selftest-run-tests.c

index 272968a..07e7356 100644 (file)
@@ -1,3 +1,12 @@
+2020-01-22  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93307
+       * gdbinit.in (break-on-saved-diagnostic): Update for move of
+       diagnostic_manager into "ana" namespace.
+       * selftest-run-tests.c (selftest::run_tests): Update for move of
+       selftest::run_analyzer_selftests to
+       ana::selftest::run_analyzer_selftests.
+
 2020-01-22  Richard Sandiford  <richard.sandiford@arm.com>
 
        * cfgexpand.c (union_stack_vars): Update the size.
index b49f43b..07876a0 100644 (file)
@@ -1,3 +1,46 @@
+2020-01-22  David Malcolm  <dmalcolm@redhat.com>
+
+       PR analyzer/93307
+       * analysis-plan.h: Wrap everything namespace "ana".
+       * analyzer-logging.cc: Likewise.
+       * analyzer-logging.h: Likewise.
+       * analyzer-pass.cc (pass_analyzer::execute): Update for "ana"
+       namespace.
+       * analyzer-selftests.cc: Wrap everything namespace "ana".
+       * analyzer-selftests.h: Likewise.
+       * analyzer.h: Likewise for forward decls of types.
+       * call-string.h: Likewise.
+       * checker-path.cc: Likewise.
+       * checker-path.h: Likewise.
+       * constraint-manager.cc: Likewise.
+       * constraint-manager.h: Likewise.
+       * diagnostic-manager.cc: Likewise.
+       * diagnostic-manager.h: Likewise.
+       * engine.cc: Likewise.
+       * engine.h: Likewise.
+       * exploded-graph.h: Likewise.
+       * function-set.cc: Likewise.
+       * function-set.h: Likewise.
+       * pending-diagnostic.cc: Likewise.
+       * pending-diagnostic.h: Likewise.
+       * program-point.cc: Likewise.
+       * program-point.h: Likewise.
+       * program-state.cc: Likewise.
+       * program-state.h: Likewise.
+       * region-model.cc: Likewise.
+       * region-model.h: Likewise.
+       * sm-file.cc: Likewise.
+       * sm-malloc.cc: Likewise.
+       * sm-pattern-test.cc: Likewise.
+       * sm-sensitive.cc: Likewise.
+       * sm-signal.cc: Likewise.
+       * sm-taint.cc: Likewise.
+       * sm.cc: Likewise.
+       * sm.h: Likewise.
+       * state-purge.h: Likewise.
+       * supergraph.cc: Likewise.
+       * supergraph.h: Likewise.
+
 2020-01-21  David Malcolm  <dmalcolm@redhat.com>
 
        PR analyzer/93352
index a44c795..79030ba 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_ANALYSIS_PLAN_H
 #define GCC_ANALYZER_ANALYSIS_PLAN_H
 
+namespace ana {
+
 /* A class to encapsulate decisions about how the analysis should happen.
    Examples:
    - the order in which functions should be analyzed, so that function
@@ -53,4 +55,6 @@ private:
   auto_vec<int> m_index_by_uid;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_ANALYSIS_PLAN_H */
index 9a6b36e..bd82875 100644 (file)
@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Implementation of class logger.  */
 
 /* ctor for logger.  */
@@ -221,4 +223,6 @@ log_user::set_logger (logger *logger)
   m_logger = logger;
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 9d5364b..132f97e 100644 (file)
@@ -23,6 +23,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef ANALYZER_LOGGING_H
 #define ANALYZER_LOGGING_H
 
+namespace ana {
+
 /* A logger encapsulates a logging stream: a way to send
    lines of pertinent information to a FILE *.  */
 
@@ -257,4 +259,6 @@ log_user::exit_scope (const char *scope_name)
 #define LOG_FUNC_4(LOGGER, FMT, A0, A1, A2, A3) \
   log_scope s (LOGGER, __func__, FMT, A0, A1, A2, A3)
 
+} // namespace ana
+
 #endif /* ANALYZER_LOGGING_H */
index 4070e6d..a27421e 100644 (file)
@@ -81,7 +81,7 @@ unsigned int
 pass_analyzer::execute (function *)
 {
 #if ENABLE_ANALYZER
-  run_checkers ();
+  ana::run_checkers ();
 #else
   sorry ("%qs was not enabled in this build of GCC"
         " (missing configure-time option %qs)",
index 1272936..8e200a3 100644 (file)
@@ -29,6 +29,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if CHECKING_P
 
+namespace ana {
+
 namespace selftest {
 
 /* Build a VAR_DECL named NAME of type TYPE, simulating a file-level
@@ -61,4 +63,6 @@ run_analyzer_selftests ()
 
 } /* end of namespace selftest.  */
 
+} // namespace ana
+
 #endif /* #if CHECKING_P */
index 62da6cd..7924b8c 100644 (file)
@@ -23,6 +23,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if CHECKING_P
 
+namespace ana {
+
 namespace selftest {
 
 extern tree build_global_decl (const char *name, tree type);
@@ -40,7 +42,9 @@ extern void analyzer_region_model_cc_tests ();
 extern void analyzer_sm_file_cc_tests ();
 extern void analyzer_sm_signal_cc_tests ();
 
-} /* end of namespace selftest.  */
+} /* end of namespace ana::selftest.  */
+
+} // namespace ana
 
 #endif /* #if CHECKING_P */
 
index 7fc6959..e84e695 100644 (file)
@@ -24,6 +24,9 @@ along with GCC; see the file COPYING3.  If not see
 /* Forward decls of common types, with indentation to show inheritance.  */
 
 class graphviz_out;
+
+namespace ana {
+
 class supergraph;
 class supernode;
 class superedge;
@@ -68,6 +71,8 @@ class state_purge_per_ssa_name;
 class state_change;
 class rewind_info_t;
 
+} // namespace ana
+
 extern bool is_special_named_call_p (const gcall *call, const char *funcname,
                                     unsigned int num_args);
 extern bool is_named_call_p (tree fndecl, const char *funcname);
index d0b2509..5e362d8 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_CALL_STRING_H
 #define GCC_ANALYZER_CALL_STRING_H
 
+namespace ana {
+
 class supergraph;
 class call_superedge;
 class return_superedge;
@@ -73,4 +75,6 @@ private:
   auto_vec<const return_superedge *> m_return_edges;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_CALL_STRING_H */
index 6c0f66c..f7455ba 100644 (file)
@@ -61,6 +61,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Get a string for EK.  */
 
 const char *
@@ -954,4 +956,6 @@ checker_path::add_final_event (const state_machine *sm,
   add_event (end_of_path);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 20bab77..cceffe0 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_CHECKER_PATH_H
 #define GCC_ANALYZER_CHECKER_PATH_H
 
+namespace ana {
+
 /* An enum for discriminating between the concrete subclasses of
    checker_event.  */
 
@@ -519,4 +521,6 @@ private:
   hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_CHECKER_PATH_H */
index 669d604..9d13ec3 100644 (file)
@@ -45,6 +45,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* One of the end-points of a range.  */
 
 struct bound
@@ -2257,4 +2259,6 @@ analyzer_constraint_manager_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index c6a40f9..0f4506c 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_CONSTRAINT_MANAGER_H
 #define GCC_ANALYZER_CONSTRAINT_MANAGER_H
 
+namespace ana {
+
 class constraint_manager;
 
 /* Abstract base class for specifying how state should be purged.  */
@@ -243,4 +245,6 @@ public:
                                equiv_class_id rhs_id);
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_CONSTRAINT_MANAGER_H */
index a00d9f7..02bc4a6 100644 (file)
@@ -58,6 +58,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* class saved_diagnostic.  */
 
 /* saved_diagnostic's ctor.
@@ -1274,4 +1276,6 @@ diagnostic_manager::finish_pruning (checker_path *path) const
     }
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index c0f13bf..0c1d976 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_DIAGNOSTIC_MANAGER_H
 #define GCC_ANALYZER_DIAGNOSTIC_MANAGER_H
 
+namespace ana {
+
 /* A to-be-emitted diagnostic stored within diagnostic_manager.  */
 
 class saved_diagnostic
@@ -121,4 +123,6 @@ private:
   const int m_verbosity;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_DIAGNOSTIC_MANAGER_H */
index 92615e6..53c9379 100644 (file)
@@ -62,6 +62,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 static int readability_comparator (const void *p1, const void *p2);
 
 /* class impl_region_model_context : public region_model_context.  */
@@ -882,6 +884,8 @@ exploded_node::dump (const extrinsic_state &ext_state) const
   dump (stderr, ext_state);
 }
 
+} // namespace ana
+
 /* Return true if FNDECL has a gimple body.  */
 // TODO: is there a pre-canned way to do this?
 
@@ -898,6 +902,8 @@ fndecl_has_gimple_body_p (tree fndecl)
   return n->has_gimple_body_p ();
 }
 
+namespace ana {
+
 /* A pending_diagnostic subclass for implementing "__analyzer_dump_path".  */
 
 class dump_path_diagnostic
@@ -2930,6 +2936,8 @@ struct function_call_string
   call_string m_cs;
 };
 
+} // namespace ana
+
 template <> struct default_hash_traits<function_call_string>
 : public pod_hash_traits<function_call_string>
 {
@@ -2975,6 +2983,8 @@ pod_hash_traits<function_call_string>::is_empty (value_type v)
   return v.m_fun == reinterpret_cast<function *> (NULL);
 }
 
+namespace ana {
+
 /* Top-level cluster for generating .dot output for exploded graphs,
    handling the functionless nodes, and grouping the remaining nodes by
    callstring.  */
@@ -3631,4 +3641,6 @@ run_checkers ()
     fclose (dump_fout);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index bbad2e2..24b51ec 100644 (file)
@@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_ENGINE_H
 #define GCC_ANALYZER_ENGINE_H
 
+namespace ana {
+
 extern void run_checkers ();
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_ENGINE_H */
index 357a1b4..57636fb 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_EXPLODED_GRAPH_H
 #define GCC_ANALYZER_EXPLODED_GRAPH_H
 
+namespace ana {
+
 /* Concrete implementation of region_model_context, wiring it up to the
    rest of the analysis engine.  */
 
@@ -828,4 +830,6 @@ public:
 
 // TODO: split the above up?
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_EXPLODED_GRAPH_H */
index 93ce473..6ed15ae 100644 (file)
@@ -27,6 +27,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Return true if NAME is within this set.  */
 
 bool
@@ -188,4 +190,6 @@ analyzer_function_set_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 9c73bf5..f12ca72 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_FUNCTION_SET_H
 #define GCC_ANALYZER_FUNCTION_SET_H
 
+namespace ana {
+
 /* A set of names.  */
 
 class function_set
@@ -43,4 +45,6 @@ private:
   size_t m_count;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_FUNCTION_SET_H */
index b692c98..c196903 100644 (file)
@@ -35,6 +35,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Generate a label_text by printing FMT.
 
    Use a clone of the global_dc for formatting callbacks.
@@ -76,4 +78,6 @@ pending_diagnostic::same_tree_p (tree t1, tree t2)
   return simple_cst_equal (t1, t2) == 1;
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 6132fcf..b1ff268 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_PENDING_DIAGNOSTIC_H
 #define GCC_ANALYZER_PENDING_DIAGNOSTIC_H
 
+namespace ana {
+
 /* Various bundles of information used for generating more precise
    messages for events within a diagnostic_path, for passing to the
    various "describe_*" vfuncs of pending_diagnostic.  See those
@@ -267,4 +269,6 @@ class pending_diagnostic_subclass : public pending_diagnostic
   }
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_PENDING_DIAGNOSTIC_H */
index e85f1ba..2e7f769 100644 (file)
@@ -55,6 +55,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Get a string for PK.  */
 
 const char *
@@ -551,4 +553,6 @@ analyzer_program_point_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index b9fe548..3772a41 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_PROGRAM_POINT_H
 #define GCC_ANALYZER_PROGRAM_POINT_H
 
+namespace ana {
+
 class exploded_graph;
 
 /* An enum for distinguishing the various kinds of program_point.  */
@@ -307,4 +309,6 @@ public:
   call_string m_call_string;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_PROGRAM_POINT_H */
index 7dbdf9d..72daee6 100644 (file)
@@ -57,6 +57,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* class sm_state_map.  */
 
 /* sm_state_map's ctor.  */
@@ -1396,4 +1398,6 @@ analyzer_program_state_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 155eaf8..a2c5c9a 100644 (file)
@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_PROGRAM_STATE_H
 #define GCC_ANALYZER_PROGRAM_STATE_H
 
+namespace ana {
+
 /* Data shared by all program_state instances.  */
 
 class extrinsic_state
@@ -47,6 +49,8 @@ public:
   auto_delete_vec <state_machine> &m_checkers;
 };
 
+} // namespace ana
+
 template <> struct default_hash_traits<svalue_id>
 : public pod_hash_traits<svalue_id>
 {
@@ -92,6 +96,8 @@ pod_hash_traits<svalue_id>::is_empty (value_type v)
   return v.null_p ();
 }
 
+namespace ana {
+
 /* Map from svalue_id to state machine state, also capturing the origin of
    each state.  */
 
@@ -362,4 +368,6 @@ class state_change
   auto_vec<sm_change> m_sm_changes;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_PROGRAM_STATE_H */
index 9474c67..0bca5c0 100644 (file)
@@ -62,6 +62,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Dump T to PP in language-independent form, for debugging/logging/dumping
    purposes.  */
 
@@ -6906,6 +6908,8 @@ canonicalization::dump () const
   dump (stderr);
 }
 
+} // namespace ana
+
 /* Update HSTATE with a hash of SID.  */
 
 void
@@ -6930,6 +6934,8 @@ debug (const region_model &rmodel)
   rmodel.dump (false);
 }
 
+namespace ana {
+
 #if CHECKING_P
 
 namespace selftest {
@@ -7984,4 +7990,6 @@ analyzer_region_model_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index c9c8265..1090b96 100644 (file)
@@ -31,6 +31,10 @@ along with GCC; see the file COPYING3.  If not see
    recursive callstack.  */
 // TODO: would this be better as a new tree code?
 
+using namespace ana;
+
+namespace ana {
+
 class path_var
 {
 public:
@@ -52,12 +56,16 @@ public:
   int m_stack_depth; // or -1 for globals?
 };
 
+} // namespace ana
+
 namespace inchash
 {
   extern void add_path_var (path_var pv, hash &hstate);
 } // namespace inchash
 
 
+namespace ana {
+
 /* 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.  */
@@ -549,6 +557,8 @@ public:
   region_id m_rid;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -557,6 +567,8 @@ is_a_helper <region_svalue *>::test (svalue *sval)
   return sval->get_kind () == SK_REGION;
 }
 
+namespace ana {
+
 /* Concrete subclass of svalue representing a specific constant value.  */
 
 class constant_svalue : public svalue
@@ -606,6 +618,8 @@ public:
   tree m_cst_expr;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -614,6 +628,8 @@ is_a_helper <constant_svalue *>::test (svalue *sval)
   return sval->get_kind () == SK_CONSTANT;
 }
 
+namespace ana {
+
 /* Concrete subclass of svalue representing a unique but unknown value.
    Comparisons of variables that share the same unknown value are known
    to be equal, even if we don't know what the value is.  */
@@ -690,6 +706,8 @@ public:
   enum poison_kind m_kind;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -698,6 +716,8 @@ is_a_helper <poisoned_svalue *>::test (svalue *sval)
   return sval->get_kind () == SK_POISONED;
 }
 
+namespace ana {
+
 /* Concrete subclass of svalue representing setjmp buffers, so that
    longjmp can potentially "return" to an entirely different function.  */
 
@@ -876,6 +896,8 @@ public:
   region_id m_active_view_rid;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -884,6 +906,8 @@ is_a_helper <region *>::test (region *)
   return true;
 }
 
+namespace ana {
+
 /* Concrete region subclass for storing "primitive" types (integral types,
    pointers, etc).  */
 
@@ -972,6 +996,8 @@ public:
   map_t m_map;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -980,6 +1006,8 @@ is_a_helper <map_region *>::test (region *reg)
   return (reg->dyn_cast_map_region () != NULL);
 }
 
+namespace ana {
+
 /* Abstract subclass representing a region with fields
    (either a struct or a union).  */
 
@@ -996,6 +1024,8 @@ public:
   bool compare_fields (const struct_or_union_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1005,6 +1035,8 @@ is_a_helper <struct_or_union_region *>::test (region *reg)
          || reg->get_kind () == RK_UNION);
 }
 
+namespace ana {
+
 /* Concrete region subclass.  A map_region representing a struct, using
    FIELD_DECLs for its keys.  */
 
@@ -1024,6 +1056,8 @@ public:
   bool compare_fields (const struct_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1032,6 +1066,8 @@ is_a_helper <struct_region *>::test (region *reg)
   return reg->get_kind () == RK_STRUCT;
 }
 
+namespace ana {
+
 /* Concrete region subclass.  A map_region representing a union, using
    FIELD_DECLs for its keys.  */
 
@@ -1051,6 +1087,8 @@ public:
   bool compare_fields (const union_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1059,6 +1097,8 @@ is_a_helper <union_region *>::test (region *reg)
   return reg->get_kind () == RK_UNION;
 }
 
+namespace ana {
+
 /* Abstract map_region subclass for accessing decls, used as a base class
    for function frames and for the globals region.  */
 
@@ -1117,6 +1157,8 @@ public:
   int m_depth;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1125,6 +1167,8 @@ is_a_helper <frame_region *>::test (region *reg)
   return reg->get_kind () == RK_FRAME;
 }
 
+namespace ana {
+
 /* Concrete region subclass, to hold global variables (data and bss).  */
 
 class globals_region : public scope_region
@@ -1149,6 +1193,8 @@ class globals_region : public scope_region
   bool compare_fields (const globals_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1157,6 +1203,8 @@ is_a_helper <globals_region *>::test (region *reg)
   return reg->get_kind () == RK_GLOBALS;
 }
 
+namespace ana {
+
 /* Concrete region subclass.  A map_region representing the code, using
    FUNCTION_DECLs for its keys.  */
 
@@ -1185,6 +1233,8 @@ public:
   bool compare_fields (const code_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1193,6 +1243,8 @@ is_a_helper <code_region *>::test (region *reg)
   return reg->get_kind () == RK_CODE;
 }
 
+namespace ana {
+
 /* Concrete region subclass.  A map_region representing the code for
    a particular function, using LABEL_DECLs for its keys.  */
 
@@ -1223,6 +1275,8 @@ public:
   bool compare_fields (const function_region &other) const;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1231,6 +1285,8 @@ is_a_helper <function_region *>::test (region *reg)
   return reg->get_kind () == RK_FUNCTION;
 }
 
+namespace ana {
+
 /* Concrete region subclass representing an array (or an array-like view
    of a parent region of memory.
    This can't be a map_region as we can't use trees as the keys: there's
@@ -1325,6 +1381,8 @@ public:
   map_t m_map;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1333,6 +1391,8 @@ is_a_helper <array_region *>::test (region *reg)
   return reg->get_kind () == RK_ARRAY;
 }
 
+namespace ana {
+
 /* Concrete region subclass representing a stack, containing all stack
    frames, and implicitly providing a POISON_KIND_UNINIT value to all
    child regions by default.  */
@@ -1387,6 +1447,8 @@ public:
   auto_vec<region_id> m_frame_rids;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1395,6 +1457,8 @@ is_a_helper <stack_region *>::test (region *reg)
   return reg->get_kind () == RK_STACK;
 }
 
+namespace ana {
+
 /* Concrete region subclass: a region within which regions can be
    dynamically allocated.  */
 
@@ -1421,6 +1485,8 @@ public:
 
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1429,6 +1495,8 @@ is_a_helper <heap_region *>::test (region *reg)
   return reg->get_kind () == RK_HEAP;
 }
 
+namespace ana {
+
 /* Concrete region subclass.  The root region, containing all regions
    (either directly, or as descendents).
    Unique within a region_model.  */
@@ -1497,6 +1565,8 @@ private:
   region_id m_heap_rid;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -1505,6 +1575,8 @@ is_a_helper <root_region *>::test (region *reg)
   return reg->get_kind () == RK_ROOT;
 }
 
+namespace ana {
+
 /* Concrete region subclass: a region to use when dereferencing an unknown
    pointer.  */
 
@@ -1941,6 +2013,8 @@ struct canonicalization
   int m_next_sid_int;
 };
 
+} // namespace ana
+
 namespace inchash
 {
   extern void add (svalue_id sid, hash &hstate);
@@ -1949,10 +2023,14 @@ namespace inchash
 
 extern void debug (const region_model &rmodel);
 
+namespace ana {
+
 #if CHECKING_P
 
 namespace selftest {
 
+using namespace ::selftest;
+
 /* An implementation of region_model_context for use in selftests, which
    stores any pending_diagnostic instances passed to it.  */
 
@@ -2068,4 +2146,6 @@ void assert_condition (const location &loc,
 
 #endif /* #if CHECKING_P */
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_REGION_MODEL_H */
index f731981..1144492 100644 (file)
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* A state machine for detecting misuses of <stdio.h>'s FILE * API.  */
@@ -434,4 +436,6 @@ analyzer_sm_file_cc_tests ()
 
 #endif /* CHECKING_P */
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 15fa1c7..526680a 100644 (file)
@@ -38,6 +38,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* A state machine for detecting misuses of the malloc/free API.
@@ -794,4 +796,6 @@ make_malloc_state_machine (logger *logger)
   return new malloc_state_machine (logger);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 571e13e..cac78e7 100644 (file)
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* A state machine for use in DejaGnu tests, to check that
@@ -149,4 +151,6 @@ make_pattern_test_state_machine (logger *logger)
   return new pattern_test_state_machine (logger);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 16b53e2..a067c18 100644 (file)
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* An experimental state machine, for tracking exposure of sensitive
@@ -245,4 +247,6 @@ make_sensitive_state_machine (logger *logger)
   return new sensitive_state_machine (logger);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 0057ab9..146ad71 100644 (file)
@@ -61,6 +61,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* An experimental state machine, for tracking calls to async-signal-unsafe
@@ -367,5 +369,7 @@ analyzer_sm_signal_cc_tests ()
 
 } // namespace selftest
 
+} // namespace ana
+
 #endif /* CHECKING_P */
 #endif /* #if ENABLE_ANALYZER */
index e454407..00b794a 100644 (file)
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 namespace {
 
 /* An experimental state machine, for tracking "taint": unsanitized uses
@@ -325,4 +327,6 @@ make_taint_state_machine (logger *logger)
   return new taint_state_machine (logger);
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 03d65ff..74fd170 100644 (file)
@@ -61,6 +61,8 @@ any_pointer_p (tree var)
   return POINTER_TYPE_P (TREE_TYPE (var));
 }
 
+namespace ana {
+
 /* Add a state with name NAME to this state_machine.
    The string is required to outlive the state_machine.
 
@@ -119,4 +121,6 @@ make_checkers (auto_delete_vec <state_machine> &out, logger *logger)
     }
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index fb49630..25163d7 100644 (file)
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3.  If not see
 extern tree is_zero_assignment (const gimple *stmt);
 extern bool any_pointer_p (tree var);
 
+namespace ana {
+
 class state_machine;
 class sm_context;
 class pending_diagnostic;
@@ -175,4 +177,6 @@ extern state_machine *make_sensitive_state_machine (logger *logger);
 extern state_machine *make_signal_state_machine (logger *logger);
 extern state_machine *make_pattern_test_state_machine (logger *logger);
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_SM_H */
index e33733a..ee7d10c 100644 (file)
@@ -68,6 +68,8 @@ pod_hash_traits<function_point>::is_empty (value_type v)
   return v.get_kind () == PK_EMPTY;
 }
 
+namespace ana {
+
 /* The result of analyzing which SSA names can be purged from state at
    different points in the program, so that we can simplify program_state
    objects, in the hope of reducing state-blowup.  */
@@ -159,4 +161,6 @@ private:
   const state_purge_map *m_map;
 };
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_STATE_PURGE_H */
index 1dcc274..4660239 100644 (file)
@@ -54,6 +54,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #if ENABLE_ANALYZER
 
+namespace ana {
+
 /* Get the cgraph_edge, but only if there's an underlying function body.  */
 
 cgraph_edge *
@@ -976,4 +978,6 @@ callgraph_superedge::map_expr_from_callee_to_caller (tree callee_expr,
   return NULL_TREE;
 }
 
+} // namespace ana
+
 #endif /* #if ENABLE_ANALYZER */
index 4c0775c..3580ae6 100644 (file)
@@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_ANALYZER_SUPERGRAPH_H
 #define GCC_ANALYZER_SUPERGRAPH_H
 
+using namespace ana;
+
+namespace ana {
+
 /* Forward decls, using indentation to show inheritance.  */
 
 class supergraph;
@@ -372,6 +376,8 @@ class callgraph_superedge : public superedge
   cgraph_edge *const m_cedge;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -382,6 +388,8 @@ is_a_helper <const callgraph_superedge *>::test (const superedge *sedge)
          || sedge->get_kind () == SUPEREDGE_RETURN);
 }
 
+namespace ana {
+
 /* A subclass of superedge representing an interprocedural call.  */
 
 class call_superedge : public callgraph_superedge
@@ -416,6 +424,8 @@ class call_superedge : public callgraph_superedge
   }
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -424,6 +434,8 @@ is_a_helper <const call_superedge *>::test (const superedge *sedge)
   return sedge->get_kind () == SUPEREDGE_CALL;
 }
 
+namespace ana {
+
 /* A subclass of superedge represesnting an interprocedural return.  */
 
 class return_superedge : public callgraph_superedge
@@ -453,6 +465,8 @@ class return_superedge : public callgraph_superedge
   }
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -461,6 +475,8 @@ is_a_helper <const return_superedge *>::test (const superedge *sedge)
   return sedge->get_kind () == SUPEREDGE_RETURN;
 }
 
+namespace ana {
+
 /* A subclass of superedge that corresponds to a CFG edge.  */
 
 class cfg_superedge : public superedge
@@ -487,6 +503,8 @@ class cfg_superedge : public superedge
   const ::edge m_cfg_edge;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -495,6 +513,8 @@ is_a_helper <const cfg_superedge *>::test (const superedge *sedge)
   return sedge->get_kind () == SUPEREDGE_CFG_EDGE;
 }
 
+namespace ana {
+
 /* A subclass for edges from switch statements, retaining enough
    information to identify the pertinent case, and for adding labels
    when rendering via graphviz.  */
@@ -526,6 +546,8 @@ class switch_cfg_superedge : public cfg_superedge {
   const int m_idx;
 };
 
+} // namespace ana
+
 template <>
 template <>
 inline bool
@@ -534,6 +556,8 @@ is_a_helper <const switch_cfg_superedge *>::test (const superedge *sedge)
   return sedge->dyn_cast_switch_cfg_superedge () != NULL;
 }
 
+namespace ana {
+
 /* Base class for adding additional content to the .dot output
    for a supergraph.  */
 
@@ -551,4 +575,6 @@ class dot_annotator
 
 extern cgraph_edge *supergraph_call_edge (function *fun, gimple *stmt);
 
+} // namespace ana
+
 #endif /* GCC_ANALYZER_SUPERGRAPH_H */
index 0b4631d..c4f400c 100644 (file)
@@ -291,11 +291,11 @@ command-line options).
 end
 
 define break-on-saved-diagnostic
-break diagnostic_manager::add_diagnostic
+break ana::diagnostic_manager::add_diagnostic
 end
 
 document break-on-saved-diagnostic
-Put a breakpoint on diagnostic_manager::add_diagnostic, called within
+Put a breakpoint on ana::diagnostic_manager::add_diagnostic, called within
 the analyzer whenever a diagnostic is saved for later de-duplication and
 possible emission.
 end
index e451387..d47e928 100644 (file)
@@ -119,7 +119,7 @@ selftest::run_tests ()
   lang_hooks.run_lang_selftests ();
 
   /* Run the analyzer selftests (if enabled).  */
-  run_analyzer_selftests ();
+  ana::selftest::run_analyzer_selftests ();
 
   /* Force a GC at the end of the selftests, to shake out GC-related
      issues.  For example, if any GC-managed items have buggy (or missing)