diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-05-28 13:04:26 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-05-28 13:04:26 -0400 |
commit | 2dbb1c124c1e585dc413132d7a8d4be62c6b7baa (patch) | |
tree | 811abafc6c4d1c86bc2fc736d0e2b695c8f9bc97 /gcc | |
parent | b544ff88560e100e53ed8966d38f172c5bafce8d (diff) | |
download | gcc-2dbb1c124c1e585dc413132d7a8d4be62c6b7baa.zip gcc-2dbb1c124c1e585dc413132d7a8d4be62c6b7baa.tar.gz gcc-2dbb1c124c1e585dc413132d7a8d4be62c6b7baa.tar.bz2 |
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 <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/diagnostic-path.h | 3 | ||||
-rw-r--r-- | gcc/diagnostic.cc | 8 | ||||
-rw-r--r-- | 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 982d68b..938bd58 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 1f30d1d..f27b2f1 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 743a8c2..0ad6c5b 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) |