From: David Malcolm Date: Tue, 28 May 2024 17:04:26 +0000 (-0400) Subject: diagnostics: disable localization of events in selftest paths [PR115203] X-Git-Tag: basepoints/gcc-16~8687 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dbb1c124c1e585dc413132d7a8d4be62c6b7baa;p=thirdparty%2Fgcc.git diagnostics: disable localization of events in selftest paths [PR115203] 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 --- diff --git a/gcc/diagnostic-path.h b/gcc/diagnostic-path.h index 982d68b872e..938bd583a3d 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 m_threads; auto_delete_vec 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 1f30d1d7cda..f27b2f1a492 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 743a8c2a1d2..0ad6c5beb81 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)