1 /* Integration of the analyzer with GCC's pass manager.
2 Copyright (C) 2019-2024 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/>. */
22 #define INCLUDE_MEMORY
24 #include "coretypes.h"
26 #include "tree-pass.h"
27 #include "diagnostic.h"
30 #include "analyzer/analyzer.h"
31 #include "analyzer/engine.h"
35 /* Data for the analyzer pass. */
37 const pass_data pass_data_analyzer
=
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
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. */
76 pass_analyzer::gate (function
*)
78 return flag_analyzer
!= 0;
81 /* Entrypoint for the analyzer pass. */
84 pass_analyzer::execute (function
*)
97 /* Make an instance of the analyzer pass. */
100 make_pass_analyzer (gcc::context
*ctxt
)
102 return new pass_analyzer (ctxt
);
107 /* Issue a "sorry" diagnostic that the analyzer was not enabled. */
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 */