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-2024 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
25
26namespace ana {
27
28/* Subclass of diagnostic_path for analyzer diagnostics. */
29
31{
32public:
34 : diagnostic_path (),
35 m_thread ("main"),
37 {}
38
39 /* Implementation of diagnostic_path vfuncs. */
40
41 unsigned num_events () const final override
42 {
43 return m_events.length ();
44 }
45
46 const diagnostic_event & get_event (int idx) const final override
47 {
48 return *m_events[idx];
49 }
50 unsigned num_threads () const final override
51 {
52 return 1;
53 }
54 const diagnostic_thread &
55 get_thread (diagnostic_thread_id_t) const final override
56 {
57 return m_thread;
58 }
59
61 {
62 return m_events[idx];
63 }
64
65 void dump (pretty_printer *pp) const;
66 void debug () const;
67
68 logger *get_logger () const { return m_logger; }
69 void maybe_log (logger *logger, const char *desc) const;
70
71 void add_event (std::unique_ptr<checker_event> event);
72
73 void delete_event (int idx)
74 {
75 checker_event *event = m_events[idx];
76 m_events.ordered_remove (idx);
77 delete event;
78 }
79
80 void delete_events (unsigned start_idx, unsigned len)
81 {
82 for (unsigned i = start_idx; i < start_idx + len; i++)
83 delete m_events[i];
84 m_events.block_remove (start_idx, len);
85 }
86
88 {
89 delete m_events[idx];
90 m_events[idx] = new_event;
91 }
92
94 const region *reg,
95 const region_model *model,
97 bool debug);
98
99 /* After all event-pruning, a hook for notifying each event what
100 its ID will be. The events are notified in order, allowing
101 for later events to refer to the IDs of earlier events in
102 their descriptions. */
110
112
118
121 {
123 {
125 return true;
126 }
127 return false;
128 }
129
130 bool cfg_edge_pair_at_p (unsigned idx) const;
131
133
134private:
136
138
139 /* The events that have occurred along this path. */
141
142 /* During prepare_for_emission (and after), the setjmp_event for each
143 exploded_node *, so that rewind events can refer to them in their
144 descriptions. */
146
148};
149
150} // namespace ana
151
152#endif /* GCC_ANALYZER_CHECKER_PATH_H */
Definition checker-event.h:101
virtual void prepare_for_emission(checker_path *, pending_diagnostic *pd, diagnostic_event_id_t emission_id)
Definition checker-path.h:31
void delete_events(unsigned start_idx, unsigned len)
Definition checker-path.h:80
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:103
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:46
bool get_setjmp_event(const exploded_node *enode, diagnostic_event_id_t *out_emission_id)
Definition checker-path.h:119
hash_map< const exploded_node *, diagnostic_event_id_t > m_setjmp_event_ids
Definition checker-path.h:145
auto_delete_vec< checker_event > m_events
Definition checker-path.h:140
const diagnostic_thread & get_thread(diagnostic_thread_id_t) const final override
Definition checker-path.h:55
void debug() const
unsigned num_threads() const final override
Definition checker-path.h:50
DISABLE_COPY_AND_ASSIGN(checker_path)
checker_path(logger *logger)
Definition checker-path.h:33
logger * m_logger
Definition checker-path.h:147
void record_setjmp_event(const exploded_node *enode, diagnostic_event_id_t setjmp_emission_id)
Definition checker-path.h:113
void add_event(std::unique_ptr< checker_event > event)
void replace_event(unsigned idx, checker_event *new_event)
Definition checker-path.h:87
unsigned num_events() const final override
Definition checker-path.h:41
void dump(pretty_printer *pp) const
logger * get_logger() const
Definition checker-path.h:68
checker_event * get_checker_event(int idx)
Definition checker-path.h:60
bool cfg_edge_pair_at_p(unsigned idx) const
simple_diagnostic_thread m_thread
Definition checker-path.h:137
void fixup_locations(pending_diagnostic *pd)
void delete_event(int idx)
Definition checker-path.h:73
Definition exploded-graph.h:203
Definition analyzer-logging.h:34
Definition pending-diagnostic.h:208
Definition region-model.h:258
Definition region.h:125
Definition vec.h:1802
Definition diagnostic-event-id.h:37
Definition diagnostic-path.h:70
Definition diagnostic-path.h:188
Definition diagnostic-path.h:179
Definition pretty-print.h:244
Definition diagnostic-path.h:257
unsigned diagnostic_thread_id_t
Definition diagnostic-event-id.h:64
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2002
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Definition access-diagram.h:30
i
Definition poly-int.h:772
Definition checker-event.h:32
#define FOR_EACH_VEC_ELT(V, I, P)
Definition vec.h:1884