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