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;
44 {
45 if (m_fndecl)
46 return &m_logical_loc;
47 else
48 return nullptr;
49 }
50 meaning get_meaning () const final override
51 {
52 return meaning ();
53 }
54 bool connect_to_next_event_p () const final override
55 {
57 }
59 {
60 return m_thread_id;
61 }
62
67
68 tree get_fndecl () const { return m_fndecl; }
69
70 private:
71 location_t m_loc;
75 char *m_desc; // has been i18n-ed and formatted
78};
79
80/* A simple implementation of diagnostic_thread. */
81
83{
84public:
85 simple_diagnostic_thread (const char *name) : m_name (name) {}
86 label_text get_name (bool) const final override
87 {
88 return label_text::borrow (m_name);
89 }
90
91private:
92 const char *m_name; // has been i18n-ed and formatted
93};
94
95/* A simple implementation of diagnostic_path, as a vector of
96 simple_diagnostic_event instances. */
97
99{
100 public:
102
103 unsigned num_events () const final override { return m_events.length (); }
104 const diagnostic_event & get_event (int idx) const final override;
105 unsigned num_threads () const final override { return m_threads.length (); }
106 const diagnostic_thread &
107 get_thread (diagnostic_thread_id_t) const final override;
108 bool
109 same_function_p (int event_idx_a,
110 int event_idx_b) const final override;
111
112 diagnostic_thread_id_t add_thread (const char *name);
113
114 diagnostic_event_id_t add_event (location_t loc, tree fndecl, int depth,
115 const char *fmt, ...)
119 location_t loc, tree fndecl, int depth,
120 const char *fmt, ...)
122
123 void connect_to_next_event ();
124
126
127 private:
130
131 /* (for use by add_event). */
134};
135
136#endif /* ! GCC_SIMPLE_DIAGNOSTIC_PATH_H */
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 logical-location.h:55
Definition pretty-print.h:241
bool connect_to_next_event_p() const final override
Definition simple-diagnostic-path.h:54
const logical_location * get_logical_location() const final override
Definition simple-diagnostic-path.h:43
bool m_connected_to_next_event
Definition simple-diagnostic-path.h:76
meaning get_meaning() const final override
Definition simple-diagnostic-path.h:50
location_t get_location() const final override
Definition simple-diagnostic-path.h:40
tree_logical_location m_logical_loc
Definition simple-diagnostic-path.h:73
~simple_diagnostic_event()
Definition simple-diagnostic-path.cc:173
void print_desc(pretty_printer &pp) const final override
Definition simple-diagnostic-path.cc:179
int m_depth
Definition simple-diagnostic-path.h:74
tree m_fndecl
Definition simple-diagnostic-path.h:72
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:159
location_t m_loc
Definition simple-diagnostic-path.h:71
void connect_to_next_event()
Definition simple-diagnostic-path.h:63
diagnostic_thread_id_t get_thread_id() const final override
Definition simple-diagnostic-path.h:58
char * m_desc
Definition simple-diagnostic-path.h:75
diagnostic_thread_id_t m_thread_id
Definition simple-diagnostic-path.h:77
tree get_fndecl() const
Definition simple-diagnostic-path.h:68
int get_stack_depth() const final override
Definition simple-diagnostic-path.h:41
pretty_printer * m_event_pp
Definition simple-diagnostic-path.h:132
const diagnostic_event & get_event(int idx) const final override
Definition simple-diagnostic-path.cc:48
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:83
void disable_event_localization()
Definition simple-diagnostic-path.h:125
bool same_function_p(int event_idx_a, int event_idx_b) const final override
Definition simple-diagnostic-path.cc:60
auto_delete_vec< simple_diagnostic_event > m_events
Definition simple-diagnostic-path.h:129
unsigned num_events() const final override
Definition simple-diagnostic-path.h:103
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:112
bool m_localize_events
Definition simple-diagnostic-path.h:133
auto_delete_vec< simple_diagnostic_thread > m_threads
Definition simple-diagnostic-path.h:128
diagnostic_thread_id_t add_thread(const char *name)
Definition simple-diagnostic-path.cc:68
simple_diagnostic_path(pretty_printer *event_pp)
Definition simple-diagnostic-path.cc:37
const diagnostic_thread & get_thread(diagnostic_thread_id_t) const final override
Definition simple-diagnostic-path.cc:54
unsigned num_threads() const final override
Definition simple-diagnostic-path.h:105
diagnostic_event_id_t diagnostic_event_id_t void connect_to_next_event()
Definition simple-diagnostic-path.cc:148
const char * m_name
Definition simple-diagnostic-path.h:92
simple_diagnostic_thread(const char *name)
Definition simple-diagnostic-path.h:85
label_text get_name(bool) const final override
Definition simple-diagnostic-path.h:86
Definition tree-logical-location.h:43
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
Definition diagnostic-path.h:114