public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] lto: use diagnostics_context in print_lto_docs_link
@ 2022-04-26 10:40 Martin Liška
  2022-04-26 11:30 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2022-04-26 10:40 UTC (permalink / raw)
  To: gcc-patches

Properly parse OPT_fdiagnostics_urls_ and then initialize both urls
and colors for global_dc. Doing that we would follow the configure
option --with-documentation-root-url, -fdiagnostics-urls is respected.
Plus we'll print colored warning and note messages.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR lto/105364

gcc/ChangeLog:

	* lto-wrapper.cc (print_lto_docs_link): Use global_dc.
	(run_gcc): Parse OPT_fdiagnostics_urls_.
	(main): Initialize global_dc.
---
 gcc/lto-wrapper.cc | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 6027fd9efdd..285e6e96af5 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -1364,14 +1364,17 @@ jobserver_active_p (void)
 void
 print_lto_docs_link ()
 {
-  const char *url = get_option_url (NULL, OPT_flto);
+  bool print_url = global_dc->printer->url_format != URL_FORMAT_NONE;
+  const char *url = global_dc->get_option_url (global_dc, OPT_flto);
 
   pretty_printer pp;
   pp.url_format = URL_FORMAT_DEFAULT;
   pp_string (&pp, "see the ");
-  pp_begin_url (&pp, url);
+  if (print_url)
+    pp_begin_url (&pp, url);
   pp_string (&pp, "%<-flto%> option documentation");
-  pp_end_url (&pp);
+  if (print_url)
+    pp_end_url (&pp);
   pp_string (&pp, " for more information");
   inform (UNKNOWN_LOCATION, pp_formatted_text (&pp));
 }
@@ -1573,6 +1576,14 @@ run_gcc (unsigned argc, char *argv[])
 	  incoming_dumppfx = dumppfx = option->arg;
 	  break;
 
+	case OPT_fdiagnostics_urls_:
+	  diagnostic_urls_init (global_dc, option->value);
+	  break;
+
+	case OPT_fdiagnostics_color_:
+	  diagnostic_color_init (global_dc, option->value);
+	  break;
+
 	default:
 	  break;
 	}
@@ -2130,6 +2141,9 @@ main (int argc, char *argv[])
   gcc_init_libintl ();
 
   diagnostic_initialize (global_dc, 0);
+  diagnostic_color_init (global_dc);
+  diagnostic_urls_init (global_dc);
+  global_dc->get_option_url = get_option_url;
 
   if (atexit (lto_wrapper_cleanup) != 0)
     fatal_error (input_location, "%<atexit%> failed");
-- 
2.36.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] lto: use diagnostics_context in print_lto_docs_link
  2022-04-26 10:40 [PATCH] lto: use diagnostics_context in print_lto_docs_link Martin Liška
@ 2022-04-26 11:30 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-04-26 11:30 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Tue, Apr 26, 2022 at 12:41 PM Martin Liška <mliska@suse.cz> wrote:
>
> Properly parse OPT_fdiagnostics_urls_ and then initialize both urls
> and colors for global_dc. Doing that we would follow the configure
> option --with-documentation-root-url, -fdiagnostics-urls is respected.
> Plus we'll print colored warning and note messages.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

OK.

Thanks,
Richard.

> Thanks,
> Martin
>
>         PR lto/105364
>
> gcc/ChangeLog:
>
>         * lto-wrapper.cc (print_lto_docs_link): Use global_dc.
>         (run_gcc): Parse OPT_fdiagnostics_urls_.
>         (main): Initialize global_dc.
> ---
>  gcc/lto-wrapper.cc | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
> index 6027fd9efdd..285e6e96af5 100644
> --- a/gcc/lto-wrapper.cc
> +++ b/gcc/lto-wrapper.cc
> @@ -1364,14 +1364,17 @@ jobserver_active_p (void)
>  void
>  print_lto_docs_link ()
>  {
> -  const char *url = get_option_url (NULL, OPT_flto);
> +  bool print_url = global_dc->printer->url_format != URL_FORMAT_NONE;
> +  const char *url = global_dc->get_option_url (global_dc, OPT_flto);
>
>    pretty_printer pp;
>    pp.url_format = URL_FORMAT_DEFAULT;
>    pp_string (&pp, "see the ");
> -  pp_begin_url (&pp, url);
> +  if (print_url)
> +    pp_begin_url (&pp, url);
>    pp_string (&pp, "%<-flto%> option documentation");
> -  pp_end_url (&pp);
> +  if (print_url)
> +    pp_end_url (&pp);
>    pp_string (&pp, " for more information");
>    inform (UNKNOWN_LOCATION, pp_formatted_text (&pp));
>  }
> @@ -1573,6 +1576,14 @@ run_gcc (unsigned argc, char *argv[])
>           incoming_dumppfx = dumppfx = option->arg;
>           break;
>
> +       case OPT_fdiagnostics_urls_:
> +         diagnostic_urls_init (global_dc, option->value);
> +         break;
> +
> +       case OPT_fdiagnostics_color_:
> +         diagnostic_color_init (global_dc, option->value);
> +         break;
> +
>         default:
>           break;
>         }
> @@ -2130,6 +2141,9 @@ main (int argc, char *argv[])
>    gcc_init_libintl ();
>
>    diagnostic_initialize (global_dc, 0);
> +  diagnostic_color_init (global_dc);
> +  diagnostic_urls_init (global_dc);
> +  global_dc->get_option_url = get_option_url;
>
>    if (atexit (lto_wrapper_cleanup) != 0)
>      fatal_error (input_location, "%<atexit%> failed");
> --
> 2.36.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-26 11:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 10:40 [PATCH] lto: use diagnostics_context in print_lto_docs_link Martin Liška
2022-04-26 11:30 ` Richard Biener

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).