]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/analyzer/analyzer-pass.cc
analyzer: introduce namespace to avoid ODR clashes (PR 93307)
[thirdparty/gcc.git] / gcc / analyzer / analyzer-pass.cc
CommitLineData
757bf1df
DM
1/* Integration of the analyzer with GCC's pass manager.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#include "config.h"
22#include "system.h"
23#include "coretypes.h"
24#include "context.h"
25#include "tree-pass.h"
26#include "diagnostic.h"
27#include "options.h"
28#include "analyzer/engine.h"
29
30namespace {
31
32/* Data for the analyzer pass. */
33
34const pass_data pass_data_analyzer =
35{
36 IPA_PASS, /* type */
37 "analyzer", /* name */
38 OPTGROUP_NONE, /* optinfo_flags */
39 TV_ANALYZER, /* tv_id */
40 PROP_ssa, /* properties_required */
41 0, /* properties_provided */
42 0, /* properties_destroyed */
43 0, /* todo_flags_start */
44 0, /* todo_flags_finish */
45};
46
47/* The analyzer pass. */
48
49class pass_analyzer : public ipa_opt_pass_d
50{
51public:
52 pass_analyzer(gcc::context *ctxt)
53 : ipa_opt_pass_d (pass_data_analyzer, ctxt,
54 NULL, /* generate_summary */
55 NULL, /* write_summary */
56 NULL, /* read_summary */
57 NULL, /* write_optimization_summary */
58 NULL, /* read_optimization_summary */
59 NULL, /* stmt_fixup */
60 0, /* function_transform_todo_flags_start */
61 NULL, /* function_transform */
62 NULL) /* variable_transform */
63 {}
64
65 /* opt_pass methods: */
66 bool gate (function *) FINAL OVERRIDE;
67 unsigned int execute (function *) FINAL OVERRIDE;
68}; // class pass_analyzer
69
70/* Only run the analyzer if -fanalyzer. */
71
72bool
73pass_analyzer::gate (function *)
74{
75 return flag_analyzer != 0;
76}
77
78/* Entrypoint for the analyzer pass. */
79
80unsigned int
81pass_analyzer::execute (function *)
82{
83#if ENABLE_ANALYZER
75038aa6 84 ana::run_checkers ();
757bf1df
DM
85#else
86 sorry ("%qs was not enabled in this build of GCC"
87 " (missing configure-time option %qs)",
88 "-fanalyzer", "--enable-analyzer");
89#endif
90
91 return 0;
92}
93
94} // anon namespace
95
96/* Make an instance of the analyzer pass. */
97
98ipa_opt_pass_d *
99make_pass_analyzer (gcc::context *ctxt)
100{
101 return new pass_analyzer (ctxt);
102}