1 /* Subclass of diagnostic_path for analyzer diagnostics.
2 Copyright (C) 2019-2022 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_CHECKER_PATH_H
22 #define GCC_ANALYZER_CHECKER_PATH_H
24 #include "analyzer/checker-event.h"
28 /* Subclass of diagnostic_path for analyzer diagnostics. */
30 class checker_path : public diagnostic_path
33 checker_path (logger *logger) : diagnostic_path (), m_logger (logger) {}
35 /* Implementation of diagnostic_path vfuncs. */
37 unsigned num_events () const final override
39 return m_events.length ();
42 const diagnostic_event & get_event (int idx) const final override
44 return *m_events[idx];
47 checker_event *get_checker_event (int idx)
52 void dump (pretty_printer *pp) const;
55 void maybe_log (logger *logger, const char *desc) const;
57 void add_event (std::unique_ptr<checker_event> event);
59 void delete_event (int idx)
61 checker_event *event = m_events[idx];
62 m_events.ordered_remove (idx);
66 void delete_events (unsigned start_idx, unsigned len)
68 for (unsigned i = start_idx; i < start_idx + len; i++)
70 m_events.block_remove (start_idx, len);
73 void replace_event (unsigned idx, checker_event *new_event)
76 m_events[idx] = new_event;
79 void add_region_creation_events (pending_diagnostic *pd,
81 const region_model *model,
83 tree fndecl, int depth,
86 /* After all event-pruning, a hook for notifying each event what
87 its ID will be. The events are notified in order, allowing
88 for later events to refer to the IDs of earlier events in
89 their descriptions. */
90 void prepare_for_emission (pending_diagnostic *pd)
94 FOR_EACH_VEC_ELT (m_events, i, e)
95 e->prepare_for_emission (this, pd, diagnostic_event_id_t (i));
98 void fixup_locations (pending_diagnostic *pd);
100 void record_setjmp_event (const exploded_node *enode,
101 diagnostic_event_id_t setjmp_emission_id)
103 m_setjmp_event_ids.put (enode, setjmp_emission_id);
106 bool get_setjmp_event (const exploded_node *enode,
107 diagnostic_event_id_t *out_emission_id)
109 if (diagnostic_event_id_t *emission_id = m_setjmp_event_ids.get (enode))
111 *out_emission_id = *emission_id;
117 bool cfg_edge_pair_at_p (unsigned idx) const;
119 void inject_any_inlined_call_events (logger *logger);
122 DISABLE_COPY_AND_ASSIGN(checker_path);
124 /* The events that have occurred along this path. */
125 auto_delete_vec<checker_event> m_events;
127 /* During prepare_for_emission (and after), the setjmp_event for each
128 exploded_node *, so that rewind events can refer to them in their
130 hash_map <const exploded_node *, diagnostic_event_id_t> m_setjmp_event_ids;
137 #endif /* GCC_ANALYZER_CHECKER_PATH_H */