]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/analyzer/checker-path.h
Update copyright years.
[thirdparty/gcc.git] / gcc / analyzer / checker-path.h
CommitLineData
65752c1f 1/* Subclass of diagnostic_path for analyzer diagnostics.
83ffe9cd 2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
757bf1df
DM
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
65752c1f 24#include "analyzer/checker-event.h"
6cf276dd 25
75038aa6
DM
26namespace ana {
27
757bf1df
DM
28/* Subclass of diagnostic_path for analyzer diagnostics. */
29
30class checker_path : public diagnostic_path
31{
32public:
965ce1ba 33 checker_path (logger *logger) : diagnostic_path (), m_logger (logger) {}
757bf1df
DM
34
35 /* Implementation of diagnostic_path vfuncs. */
36
ff171cb1 37 unsigned num_events () const final override
757bf1df
DM
38 {
39 return m_events.length ();
40 }
41
ff171cb1 42 const diagnostic_event & get_event (int idx) const final override
757bf1df
DM
43 {
44 return *m_events[idx];
45 }
46
e2a538b1
DM
47 checker_event *get_checker_event (int idx)
48 {
49 return m_events[idx];
50 }
51
757bf1df
DM
52 void dump (pretty_printer *pp) const;
53 void debug () const;
54
55 void maybe_log (logger *logger, const char *desc) const;
56
965ce1ba 57 void add_event (std::unique_ptr<checker_event> event);
757bf1df
DM
58
59 void delete_event (int idx)
60 {
61 checker_event *event = m_events[idx];
62 m_events.ordered_remove (idx);
63 delete event;
64 }
65
eb06fdd4
DM
66 void delete_events (unsigned start_idx, unsigned len)
67 {
68 for (unsigned i = start_idx; i < start_idx + len; i++)
69 delete m_events[i];
70 m_events.block_remove (start_idx, len);
71 }
72
73 void replace_event (unsigned idx, checker_event *new_event)
74 {
75 delete m_events[idx];
76 m_events[idx] = new_event;
77 }
78
f5758fe5
DM
79 void add_region_creation_events (pending_diagnostic *pd,
80 const region *reg,
c81b60b8 81 const region_model *model,
e24fe128 82 const event_loc_info &loc_info,
c81b60b8 83 bool debug);
00e7d024 84
757bf1df
DM
85 /* After all event-pruning, a hook for notifying each event what
86 its ID will be. The events are notified in order, allowing
87 for later events to refer to the IDs of earlier events in
88 their descriptions. */
89 void prepare_for_emission (pending_diagnostic *pd)
90 {
91 checker_event *e;
92 int i;
93 FOR_EACH_VEC_ELT (m_events, i, e)
94 e->prepare_for_emission (this, pd, diagnostic_event_id_t (i));
95 }
96
66dde7bc
DM
97 void fixup_locations (pending_diagnostic *pd);
98
757bf1df
DM
99 void record_setjmp_event (const exploded_node *enode,
100 diagnostic_event_id_t setjmp_emission_id)
101 {
102 m_setjmp_event_ids.put (enode, setjmp_emission_id);
103 }
104
105 bool get_setjmp_event (const exploded_node *enode,
106 diagnostic_event_id_t *out_emission_id)
107 {
108 if (diagnostic_event_id_t *emission_id = m_setjmp_event_ids.get (enode))
109 {
110 *out_emission_id = *emission_id;
111 return true;
112 }
113 return false;
114 }
115
eb06fdd4
DM
116 bool cfg_edge_pair_at_p (unsigned idx) const;
117
63c07319
DM
118 void inject_any_inlined_call_events (logger *logger);
119
e2a538b1
DM
120private:
121 DISABLE_COPY_AND_ASSIGN(checker_path);
122
757bf1df
DM
123 /* The events that have occurred along this path. */
124 auto_delete_vec<checker_event> m_events;
125
126 /* During prepare_for_emission (and after), the setjmp_event for each
127 exploded_node *, so that rewind events can refer to them in their
128 descriptions. */
129 hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
965ce1ba
DM
130
131 logger *m_logger;
757bf1df
DM
132};
133
75038aa6
DM
134} // namespace ana
135
757bf1df 136#endif /* GCC_ANALYZER_CHECKER_PATH_H */