]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/analyzer/diagnostic-manager.h
1c7bc7462afcc458fa51bd9c7bc399612ab10b0f
1 /* Classes for saving, deduplicating, and emitting analyzer diagnostics.
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/>. */
21 #ifndef GCC_ANALYZER_DIAGNOSTIC_MANAGER_H
22 #define GCC_ANALYZER_DIAGNOSTIC_MANAGER_H
26 /* A to-be-emitted diagnostic stored within diagnostic_manager. */
28 class saved_diagnostic
31 saved_diagnostic (const state_machine
*sm
,
32 const exploded_node
*enode
,
33 const supernode
*snode
, const gimple
*stmt
,
34 stmt_finder
*stmt_finder
,
35 tree var
, state_machine::state_t state
,
36 pending_diagnostic
*d
);
39 bool operator== (const saved_diagnostic
&other
) const;
42 const state_machine
*m_sm
;
43 const exploded_node
*m_enode
;
44 const supernode
*m_snode
;
46 stmt_finder
*m_stmt_finder
;
48 state_machine::state_t m_state
;
49 pending_diagnostic
*m_d
;
50 exploded_edge
*m_trailing_eedge
;
53 DISABLE_COPY_AND_ASSIGN (saved_diagnostic
);
58 /* A class with responsibility for saving pending diagnostics, so that
59 they can be emitted after the exploded_graph is complete.
60 This lets us de-duplicate diagnostics, and find the shortest path
61 for each similar diagnostic, potentially using edges that might
62 not have been found when each diagnostic was first saved.
64 This also lets us compute shortest_paths once, rather than
67 class diagnostic_manager
: public log_user
70 diagnostic_manager (logger
*logger
, int verbosity
);
72 void add_diagnostic (const state_machine
*sm
,
73 const exploded_node
*enode
,
74 const supernode
*snode
, const gimple
*stmt
,
76 tree var
, state_machine::state_t state
,
77 pending_diagnostic
*d
);
79 void add_diagnostic (const exploded_node
*enode
,
80 const supernode
*snode
, const gimple
*stmt
,
82 pending_diagnostic
*d
);
84 void emit_saved_diagnostics (const exploded_graph
&eg
);
86 void emit_saved_diagnostic (const exploded_graph
&eg
,
87 const saved_diagnostic
&sd
,
88 const exploded_path
&epath
,
92 unsigned get_num_diagnostics () const
94 return m_saved_diagnostics
.length ();
96 saved_diagnostic
*get_saved_diagnostic (unsigned idx
)
98 return m_saved_diagnostics
[idx
];
100 const saved_diagnostic
*get_saved_diagnostic (unsigned idx
) const
102 return m_saved_diagnostics
[idx
];
106 void build_emission_path (const path_builder
&pb
,
107 const exploded_path
&epath
,
108 checker_path
*emission_path
) const;
110 void add_events_for_eedge (const path_builder
&pb
,
111 const exploded_edge
&eedge
,
112 checker_path
*emission_path
) const;
114 bool significant_edge_p (const path_builder
&pb
,
115 const exploded_edge
&eedge
) const;
117 void add_events_for_superedge (const path_builder
&pb
,
118 const exploded_edge
&eedge
,
119 checker_path
*emission_path
) const;
121 void prune_path (checker_path
*path
,
122 const state_machine
*sm
,
123 tree var
, state_machine::state_t state
) const;
125 void prune_for_sm_diagnostic (checker_path
*path
,
126 const state_machine
*sm
,
128 state_machine::state_t state
) const;
129 void update_for_unsuitable_sm_exprs (tree
*expr
) const;
130 void prune_interproc_events (checker_path
*path
) const;
131 void finish_pruning (checker_path
*path
) const;
133 auto_delete_vec
<saved_diagnostic
> m_saved_diagnostics
;
134 const int m_verbosity
;
139 #endif /* GCC_ANALYZER_DIAGNOSTIC_MANAGER_H */