]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
diagnostics: disable localization of events in selftest paths [PR115203]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 28 May 2024 17:04:26 +0000 (13:04 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 28 May 2024 17:04:26 +0000 (13:04 -0400)
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
gcc/diagnostic.cc
gcc/tree-diagnostic-path.cc

index 982d68b872eab5be8081e7794da2e6f565b37ced..938bd583a3da5ebd57d0e67b8594df9891ee6872 100644 (file)
@@ -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);
index 1f30d1d7cdacb55e16106eaa54128e2e7125c461..f27b2f1a492cd862a1c0a845471d86d2d683572b 100644 (file)
@@ -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);
 
index 743a8c2a1d29f778d3d2441a8349353c044df21f..0ad6c5beb81c1f8bf58b02afb92fbc92b19a4a4e 100644 (file)
@@ -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)