GCC Middle and Back End API Reference
checker-path.h
Go to the documentation of this file.
1/* Subclass of diagnostics::paths::path for analyzer diagnostics.
2 Copyright (C) 2019-2025 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#ifndef GCC_ANALYZER_CHECKER_PATH_H
22#define GCC_ANALYZER_CHECKER_PATH_H
23
26
27namespace ana {
28
29/* Subclass of diagnostic path for analyzer diagnostics. */
30
32{
33public:
37 : diagnostics::paths::path (logical_loc_mgr),
39 m_thread ("main"),
41 {}
42
43 /* Implementation of diagnostics::paths::path vfuncs. */
44
45 unsigned num_events () const final override
46 {
47 return m_events.length ();
48 }
49
51 get_event (int idx) const final override
52 {
53 return *m_events[idx];
54 }
55 unsigned num_threads () const final override
56 {
57 return 1;
58 }
61 {
62 return m_thread;
63 }
64
65 const extrinsic_state &get_ext_state () const { return m_ext_state; }
66
68 {
69 return m_events[idx];
70 }
71
72 bool
73 same_function_p (int event_idx_a,
74 int event_idx_b) const final override;
75
76 void dump (pretty_printer *pp) const;
77 void debug () const;
78
79 logger *get_logger () const { return m_logger; }
80 void maybe_log (logger *logger, const char *desc) const;
81
82 void add_event (std::unique_ptr<checker_event> event);
83
84 void delete_event (int idx)
85 {
86 checker_event *event = m_events[idx];
87 m_events.ordered_remove (idx);
88 delete event;
89 }
90
91 void delete_events (unsigned start_idx, unsigned len)
92 {
93 for (unsigned i = start_idx; i < start_idx + len; i++)
94 delete m_events[i];
95 m_events.block_remove (start_idx, len);
96 }
97
98 void replace_event (unsigned idx, checker_event *new_event)
99 {
100 delete m_events[idx];
101 m_events[idx] = new_event;
102 }
103
105 const region *reg,
106 const region_model *model,
107 const event_loc_info &loc_info,
108 bool debug);
109
110 /* After all event-pruning, a hook for notifying each event what
111 its ID will be. The events are notified in order, allowing
112 for later events to refer to the IDs of earlier events in
113 their descriptions. */
115 {
116 checker_event *e;
117 int i;
119 e->prepare_for_emission (this, pd, diagnostics::paths::event_id_t (i));
120 }
121
123
125 diagnostics::paths::event_id_t setjmp_emission_id)
126 {
127 m_setjmp_event_ids.put (enode, setjmp_emission_id);
128 }
129
130 bool get_setjmp_event (const exploded_node *enode,
131 diagnostics::paths::event_id_t *out_emission_id)
132 {
133 if (diagnostics::paths::event_id_t *emission_id
134 = m_setjmp_event_ids.get (enode))
135 {
136 *out_emission_id = *emission_id;
137 return true;
138 }
139 return false;
140 }
141
142 bool cfg_edge_pair_at_p (unsigned idx) const;
143
145
146private:
148
150
152
153 /* The events that have occurred along this path. */
155
156 /* During prepare_for_emission (and after), the setjmp_event for each
157 exploded_node *, so that rewind events can refer to them in their
158 descriptions. */
159 hash_map <const exploded_node *, diagnostics::paths::event_id_t> m_setjmp_event_ids;
160
162};
163
164} // namespace ana
165
166#endif /* GCC_ANALYZER_CHECKER_PATH_H */
Definition checker-event.h:98
void delete_events(unsigned start_idx, unsigned len)
Definition checker-path.h:91
void add_region_creation_events(pending_diagnostic *pd, const region *reg, const region_model *model, const event_loc_info &loc_info, bool debug)
void prepare_for_emission(pending_diagnostic *pd)
Definition checker-path.h:114
void inject_any_inlined_call_events(logger *logger)
bool get_setjmp_event(const exploded_node *enode, diagnostics::paths::event_id_t *out_emission_id)
Definition checker-path.h:130
void maybe_log(logger *logger, const char *desc) const
const extrinsic_state & get_ext_state() const
Definition checker-path.h:65
hash_map< const exploded_node *, diagnostics::paths::event_id_t > m_setjmp_event_ids
Definition checker-path.h:159
const diagnostics::paths::thread & get_thread(diagnostics::paths::thread_id_t) const final override
Definition checker-path.h:60
auto_delete_vec< checker_event > m_events
Definition checker-path.h:154
void debug() const
bool same_function_p(int event_idx_a, int event_idx_b) const final override
unsigned num_threads() const final override
Definition checker-path.h:55
DISABLE_COPY_AND_ASSIGN(checker_path)
logger * m_logger
Definition checker-path.h:161
void add_event(std::unique_ptr< checker_event > event)
void replace_event(unsigned idx, checker_event *new_event)
Definition checker-path.h:98
const diagnostics::paths::event & get_event(int idx) const final override
Definition checker-path.h:51
unsigned num_events() const final override
Definition checker-path.h:45
void dump(pretty_printer *pp) const
logger * get_logger() const
Definition checker-path.h:79
checker_event * get_checker_event(int idx)
Definition checker-path.h:67
bool cfg_edge_pair_at_p(unsigned idx) const
simple_diagnostic_thread m_thread
Definition checker-path.h:151
checker_path(const diagnostics::logical_locations::manager &logical_loc_mgr, const extrinsic_state &ext_state, logger *logger)
Definition checker-path.h:34
void record_setjmp_event(const exploded_node *enode, diagnostics::paths::event_id_t setjmp_emission_id)
Definition checker-path.h:124
const extrinsic_state & m_ext_state
Definition checker-path.h:149
void fixup_locations(pending_diagnostic *pd)
void delete_event(int idx)
Definition checker-path.h:84
Definition exploded-graph.h:205
Definition program-state.h:34
Definition analyzer-logging.h:34
Definition pending-diagnostic.h:189
Definition region-model.h:298
Definition region.h:126
Definition vec.h:1813
Definition logical-locations.h:147
Definition paths.h:83
Definition paths.h:207
path(const logical_locations::manager &logical_loc_mgr)
Definition paths.h:231
Definition paths.h:198
Definition ree.cc:583
Definition pretty-print.h:241
Definition simple-diagnostic-path.h:84
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2009
Definition access-diagram.h:30
int thread_id_t
Definition event-id.h:71
diagnostic_event_id_t event_id_t
Definition event-id.h:66
Definition coretypes.h:167
i
Definition poly-int.h:776
Definition event-loc-info.h:29
#define FOR_EACH_VEC_ELT(V, I, P)
Definition vec.h:1895