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>.
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)
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/>. */
23 #include "coretypes.h"
25 #include "tree-pass.h"
26 #include "diagnostic.h"
28 #include "analyzer/engine.h"
32 /* Data for the analyzer pass. */
34 const pass_data pass_data_analyzer
=
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 */
47 /* The analyzer pass. */
49 class pass_analyzer
: public ipa_opt_pass_d
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 */
65 /* opt_pass methods: */
66 bool gate (function
*) FINAL OVERRIDE
;
67 unsigned int execute (function
*) FINAL OVERRIDE
;
68 }; // class pass_analyzer
70 /* Only run the analyzer if -fanalyzer. */
73 pass_analyzer::gate (function
*)
75 return flag_analyzer
!= 0;
78 /* Entrypoint for the analyzer pass. */
81 pass_analyzer::execute (function
*)
86 sorry ("%qs was not enabled in this build of GCC"
87 " (missing configure-time option %qs)",
88 "-fanalyzer", "--enable-analyzer");
96 /* Make an instance of the analyzer pass. */
99 make_pass_analyzer (gcc::context
*ctxt
)
101 return new pass_analyzer (ctxt
);