GCC Middle and Back End API Reference
simple-diagnostic-path.h
Go to the documentation of this file.
1/* Concrete classes for implementing diagnostic paths.
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 under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for 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_SIMPLE_DIAGNOSTIC_PATH_H
22#define GCC_SIMPLE_DIAGNOSTIC_PATH_H
23
24#include "diagnostic-path.h"
26
27/* Concrete subclasses of the abstract base classes
28 declared in diagnostic-path.h. */
29
30/* A simple implementation of diagnostic_event. */
31
33{
34 public:
35 simple_diagnostic_event (location_t loc, tree fndecl, int depth,
36 const char *desc,
37 diagnostic_thread_id_t thread_id = 0);
39
40 location_t get_location () const final override { return m_loc; }
41 int get_stack_depth () const final override { return m_depth; }
42 void print_desc (pretty_printer &pp) const final override;
47 meaning get_meaning () const final override
48 {
49 return meaning ();
50 }
51 bool connect_to_next_event_p () const final override
52 {
54 }
56 {
57 return m_thread_id;
58 }
59
64
65 tree get_fndecl () const { return m_fndecl; }
66
67 private:
68 location_t m_loc;
72 char *m_desc; // has been i18n-ed and formatted
75};
76
77/* A simple implementation of diagnostic_thread. */
78
80{
81public:
82 simple_diagnostic_thread (const char *name) : m_name (name) {}
83 label_text get_name (bool) const final override
84 {
85 return label_text::borrow (m_name);
86 }
87
88private:
89 const char *m_name; // has been i18n-ed and formatted
90};
91
92/* A simple implementation of diagnostic_path, as a vector of
93 simple_diagnostic_event instances. */
94
96{
97 public:
99 pretty_printer *event_pp);
100
101 unsigned num_events () const final override { return m_events.length (); }
102 const diagnostic_event & get_event (int idx) const final override;
103 unsigned num_threads () const final override { return m_threads.length (); }
104 const diagnostic_thread &
105 get_thread (diagnostic_thread_id_t) const final override;
106 bool
107 same_function_p (int event_idx_a,
108 int event_idx_b) const final override;
109
110 diagnostic_thread_id_t add_thread (const char *name);
111
112 diagnostic_event_id_t add_event (location_t loc, tree fndecl, int depth,
113 const char *fmt, ...)
117 location_t loc, tree fndecl, int depth,
118 const char *fmt, ...)
120
121 void connect_to_next_event ();
122
124
125 private:
128
129 /* (for use by add_event). */
132};
133
134#endif /* ! GCC_SIMPLE_DIAGNOSTIC_PATH_H */
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 pretty-print.h:241
bool connect_to_next_event_p() const final override
Definition simple-diagnostic-path.h:51
bool m_connected_to_next_event
Definition simple-diagnostic-path.h:73
meaning get_meaning() const final override
Definition simple-diagnostic-path.h:47
location_t get_location() const final override
Definition simple-diagnostic-path.h:40
logical_location get_logical_location() const final override
Definition simple-diagnostic-path.h:43
~simple_diagnostic_event()
Definition simple-diagnostic-path.cc:177
void print_desc(pretty_printer &pp) const final override
Definition simple-diagnostic-path.cc:183
int m_depth
Definition simple-diagnostic-path.h:71
tree m_fndecl
Definition simple-diagnostic-path.h:69
simple_diagnostic_event(location_t loc, tree fndecl, int depth, const char *desc, diagnostic_thread_id_t thread_id=0)
Definition simple-diagnostic-path.cc:162
location_t m_loc
Definition simple-diagnostic-path.h:68
void connect_to_next_event()
Definition simple-diagnostic-path.h:60
diagnostic_thread_id_t get_thread_id() const final override
Definition simple-diagnostic-path.h:55
char * m_desc
Definition simple-diagnostic-path.h:72
diagnostic_thread_id_t m_thread_id
Definition simple-diagnostic-path.h:74
tree get_fndecl() const
Definition simple-diagnostic-path.h:65
logical_location m_logical_loc
Definition simple-diagnostic-path.h:70
int get_stack_depth() const final override
Definition simple-diagnostic-path.h:41
pretty_printer * m_event_pp
Definition simple-diagnostic-path.h:130
const diagnostic_event & get_event(int idx) const final override
Definition simple-diagnostic-path.cc:51
diagnostic_event_id_t add_event(location_t loc, tree fndecl, int depth, const char *fmt,...) ATTRIBUTE_GCC_DIAG(5
Definition simple-diagnostic-path.cc:86
simple_diagnostic_path(const tree_logical_location_manager &logical_loc_mgr, pretty_printer *event_pp)
Definition simple-diagnostic-path.cc:38
void disable_event_localization()
Definition simple-diagnostic-path.h:123
bool same_function_p(int event_idx_a, int event_idx_b) const final override
Definition simple-diagnostic-path.cc:63
auto_delete_vec< simple_diagnostic_event > m_events
Definition simple-diagnostic-path.h:127
unsigned num_events() const final override
Definition simple-diagnostic-path.h:101
diagnostic_event_id_t diagnostic_event_id_t add_thread_event(diagnostic_thread_id_t thread_id, location_t loc, tree fndecl, int depth, const char *fmt,...) ATTRIBUTE_GCC_DIAG(6
Definition simple-diagnostic-path.cc:115
bool m_localize_events
Definition simple-diagnostic-path.h:131
auto_delete_vec< simple_diagnostic_thread > m_threads
Definition simple-diagnostic-path.h:126
diagnostic_thread_id_t add_thread(const char *name)
Definition simple-diagnostic-path.cc:71
const diagnostic_thread & get_thread(diagnostic_thread_id_t) const final override
Definition simple-diagnostic-path.cc:57
unsigned num_threads() const final override
Definition simple-diagnostic-path.h:103
diagnostic_event_id_t diagnostic_event_id_t void connect_to_next_event()
Definition simple-diagnostic-path.cc:151
const char * m_name
Definition simple-diagnostic-path.h:89
simple_diagnostic_thread(const char *name)
Definition simple-diagnostic-path.h:82
label_text get_name(bool) const final override
Definition simple-diagnostic-path.h:83
Definition tree-logical-location.h:31
static logical_location key_from_tree(tree node)
Definition tree-logical-location.h:44
union tree_node * tree
Definition coretypes.h:97
#define ATTRIBUTE_GCC_DIAG(m, n)
Definition diagnostic-core.h:103
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
logical_location_manager::key logical_location
Definition logical-location.h:173
Definition diagnostic-path.h:116