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)
commit75038aa6aa5b562e6358108619d66ef2ccab9a53
treeb1fe8edd2080d5fea96ef7347ce1fd7f93983cfa
parent68cbbe7cdc7754d5b8aa2c9072e37745ff3b7604
analyzer: introduce namespace to avoid ODR clashes (PR 93307)

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