From 26ae91aa80915de88644f629eb195bfbd269cb96 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 29 Jul 2025 12:32:53 -0400 Subject: [PATCH 77/98] FIXME: non-working WIP on adding -fdiagnostics-set-output= to sarif-replay --- gcc/sarif-replay.cc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gcc/sarif-replay.cc b/gcc/sarif-replay.cc index 02da22434990..0edb152ebf3a 100644 --- a/gcc/sarif-replay.cc +++ b/gcc/sarif-replay.cc @@ -50,7 +50,7 @@ struct options replay_options m_replay_opts; std::vector m_sarif_filenames; - std::vector m_extra_output_specs; + std::vector m_output_specs; }; static void @@ -73,6 +73,10 @@ static const char *const usage_msg = ( "\n" "Options:\n" "\n" +" -fdiagnostics-set-output=SCHEME\n" +" Set the output sink when replaying diagnostics, as\n" +" per the gcc option\n" +"\n" " -fdiagnostics-add-output=SCHEME\n" " Add an additional output sink when replaying diagnostics, as\n" " per the gcc option\n" @@ -153,11 +157,19 @@ parse_options (int argc, char **argv, opts.m_replay_opts.m_echo_file = true; handled = true; } +#define SET_OUTPUT_OPTION "-fdiagnostics-set-output=" + else if (const char *arg + = str_starts_with (option, SET_OUTPUT_OPTION)) + { + opts.m_output_specs.clear (); + opts.m_output_specs.push_back (std::string (arg)); + handled = true; + } #define ADD_OUTPUT_OPTION "-fdiagnostics-add-output=" else if (const char *arg = str_starts_with (option, ADD_OUTPUT_OPTION)) { - opts.m_extra_output_specs.push_back (std::string (arg)); + opts.m_output_specs.push_back (std::string (arg)); handled = true; } else if (strcmp (option, "-fdiagnostics-color=never") == 0) @@ -240,6 +252,8 @@ main (int argc, char **argv) = control_mgr.add_text_sink (stderr, DIAGNOSTIC_COLORIZE_IF_TTY); options opts; + opts.m_output_specs.push_back ("text"); // FIXME: what about colorization + if (!parse_options (argc, argv, opts, control_text_sink)) { print_usage (); @@ -257,9 +271,7 @@ main (int argc, char **argv) libgdiagnostics::manager playback_mgr; playback_mgr.set_debug_physical_locations (opts.m_replay_opts.m_debug_physical_locations); - playback_mgr.add_text_sink (stderr, - opts.m_replay_opts.m_diagnostics_colorize); - for (auto spec : opts.m_extra_output_specs) + for (auto spec : opts.m_output_specs) if (playback_mgr.add_sink_from_spec (ADD_OUTPUT_OPTION, spec.c_str (), -- 2.49.0