c++: Tweaks for -Wredundant-move [PR107363]
[official-gcc.git] / gcc / analyzer / analyzer-pass.cc
blob423595f45f05feeb9a6952cc79cf347e41058175
1 /* Integration of the analyzer with GCC's pass manager.
2 Copyright (C) 2019-2022 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #define INCLUDE_MEMORY
23 #include "system.h"
24 #include "coretypes.h"
25 #include "context.h"
26 #include "tree-pass.h"
27 #include "diagnostic.h"
28 #include "options.h"
29 #include "tree.h"
30 #include "analyzer/analyzer.h"
31 #include "analyzer/engine.h"
33 namespace {
35 /* Data for the analyzer pass. */
37 const pass_data pass_data_analyzer =
39 IPA_PASS, /* type */
40 "analyzer", /* name */
41 OPTGROUP_NONE, /* optinfo_flags */
42 TV_ANALYZER, /* tv_id */
43 PROP_ssa, /* properties_required */
44 0, /* properties_provided */
45 0, /* properties_destroyed */
46 0, /* todo_flags_start */
47 0, /* todo_flags_finish */
50 /* The analyzer pass. */
52 class pass_analyzer : public ipa_opt_pass_d
54 public:
55 pass_analyzer(gcc::context *ctxt)
56 : ipa_opt_pass_d (pass_data_analyzer, ctxt,
57 NULL, /* generate_summary */
58 NULL, /* write_summary */
59 NULL, /* read_summary */
60 NULL, /* write_optimization_summary */
61 NULL, /* read_optimization_summary */
62 NULL, /* stmt_fixup */
63 0, /* function_transform_todo_flags_start */
64 NULL, /* function_transform */
65 NULL) /* variable_transform */
68 /* opt_pass methods: */
69 bool gate (function *) final override;
70 unsigned int execute (function *) final override;
71 }; // class pass_analyzer
73 /* Only run the analyzer if -fanalyzer. */
75 bool
76 pass_analyzer::gate (function *)
78 return flag_analyzer != 0;
81 /* Entrypoint for the analyzer pass. */
83 unsigned int
84 pass_analyzer::execute (function *)
86 #if ENABLE_ANALYZER
87 ana::run_checkers ();
88 #else
89 sorry_no_analyzer ();
90 #endif
92 return 0;
95 } // anon namespace
97 /* Make an instance of the analyzer pass. */
99 ipa_opt_pass_d *
100 make_pass_analyzer (gcc::context *ctxt)
102 return new pass_analyzer (ctxt);
105 #if !ENABLE_ANALYZER
107 /* Issue a "sorry" diagnostic that the analyzer was not enabled. */
109 void
110 sorry_no_analyzer ()
112 sorry ("%qs was not enabled in this build of GCC"
113 " (missing configure-time option %qs)",
114 "-fanalyzer", "--enable-analyzer");
117 #endif /* #if !ENABLE_ANALYZER */