* [pushed] diagnostics: disable localization of events in selftest paths [PR115203]
@ 2024-05-28 17:11 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2024-05-28 17:11 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r15-866-g2dbb1c124c1e58.
gcc/ChangeLog:
PR analyzer/115203
* diagnostic-path.h
(simple_diagnostic_path::disable_event_localization): New.
(simple_diagnostic_path::m_localize_events): New field.
* diagnostic.cc
(simple_diagnostic_path::simple_diagnostic_path): Initialize
m_localize_events.
(simple_diagnostic_path::add_event): Only localize fmt if
m_localize_events is true.
* tree-diagnostic-path.cc
(test_diagnostic_path::test_diagnostic_path): Call
disable_event_localization.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
gcc/diagnostic-path.h | 3 +++
gcc/diagnostic.cc | 8 +++++---
gcc/tree-diagnostic-path.cc | 3 ++-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h
index 982d68b872ea..938bd583a3da 100644
--- a/gcc/diagnostic-path.h
+++ b/gcc/diagnostic-path.h
@@ -293,12 +293,15 @@ class simple_diagnostic_path : public diagnostic_path
void connect_to_next_event ();
+ void disable_event_localization () { m_localize_events = false; }
+
private:
auto_delete_vec<simple_diagnostic_thread> m_threads;
auto_delete_vec<simple_diagnostic_event> m_events;
/* (for use by add_event). */
pretty_printer *m_event_pp;
+ bool m_localize_events;
};
extern void debug (diagnostic_path *path);
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 1f30d1d7cdac..f27b2f1a492c 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -2517,7 +2517,8 @@ set_text_art_charset (enum diagnostic_text_art_charset charset)
/* class simple_diagnostic_path : public diagnostic_path. */
simple_diagnostic_path::simple_diagnostic_path (pretty_printer *event_pp)
- : m_event_pp (event_pp)
+: m_event_pp (event_pp),
+ m_localize_events (true)
{
add_thread ("main");
}
@@ -2563,7 +2564,7 @@ simple_diagnostic_path::add_thread (const char *name)
stack depth DEPTH.
Use m_context's printer to format FMT, as the text of the new
- event.
+ event. Localize FMT iff m_localize_events is set.
Return the id of the new event. */
@@ -2580,7 +2581,8 @@ simple_diagnostic_path::add_event (location_t loc, tree fndecl, int depth,
va_start (ap, fmt);
- text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc);
+ text_info ti (m_localize_events ? _(fmt) : fmt,
+ &ap, 0, nullptr, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc
index 743a8c2a1d29..0ad6c5beb81c 100644
--- a/gcc/tree-diagnostic-path.cc
+++ b/gcc/tree-diagnostic-path.cc
@@ -1016,7 +1016,7 @@ path_events_have_column_data_p (const diagnostic_path &path)
}
/* A subclass of simple_diagnostic_path that adds member functions
- for adding test events. */
+ for adding test events and suppresses translation of these events. */
class test_diagnostic_path : public simple_diagnostic_path
{
@@ -1024,6 +1024,7 @@ class test_diagnostic_path : public simple_diagnostic_path
test_diagnostic_path (pretty_printer *event_pp)
: simple_diagnostic_path (event_pp)
{
+ disable_event_localization ();
}
void add_entry (tree fndecl, int stack_depth)
--
2.26.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-28 17:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-28 17:11 [pushed] diagnostics: disable localization of events in selftest paths [PR115203] David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).