diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-02-03 19:58:54 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-02-17 20:40:00 -0500 |
commit | abb4852434b3dee26301cc406472ac9450c621aa (patch) | |
tree | 9f6d5a947e9fc0982fdee66d899b1d4b5777e202 | |
parent | d8cde6f9c223f1b6d4f4e4e07088f08a629b7c2a (diff) | |
download | gcc-abb4852434b3dee26301cc406472ac9450c621aa.tar.gz |
diagnostics: don't generate URLs that won't be used
The two places in diagnostics.c where URLs are printed both do
non-trivial work to generate the URL strings (including malloc/free), so
don't do this work if URL-printing is disabled.
gcc/ChangeLog:
* diagnostic.c (print_any_cwe): Don't call get_cwe_url if URLs
won't be printed.
(print_option_information): Don't call get_option_url if URLs
won't be printed.
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/diagnostic.c | 15 |
2 files changed, 17 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a07e536789f..9f8ad15a29c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2020-02-17 David Malcolm <dmalcolm@redhat.com> + + * diagnostic.c (print_any_cwe): Don't call get_cwe_url if URLs + won't be printed. + (print_option_information): Don't call get_option_url if URLs + won't be printed. + 2020-02-17 Alexandre Oliva <oliva@adacore.com> * tree-emutls.c (new_emutls_decl, emutls_common_1): Complete diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index e4a08f76def..ed52bc03d17 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -983,12 +983,16 @@ print_any_cwe (diagnostic_context *context, pp_string (pp, " ["); pp_string (pp, colorize_start (pp_show_color (pp), diagnostic_kind_color[diagnostic->kind])); - char *cwe_url = get_cwe_url (cwe); - pp_begin_url (pp, cwe_url); - free (cwe_url); + if (pp->url_format != URL_FORMAT_NONE) + { + char *cwe_url = get_cwe_url (cwe); + pp_begin_url (pp, cwe_url); + free (cwe_url); + } pp_printf (pp, "CWE-%i", cwe); pp_set_prefix (context->printer, saved_prefix); - pp_end_url (pp); + if (pp->url_format != URL_FORMAT_NONE) + pp_end_url (pp); pp_string (pp, colorize_stop (pp_show_color (pp))); pp_character (pp, ']'); } @@ -1011,7 +1015,8 @@ print_option_information (diagnostic_context *context, if (option_text) { char *option_url = NULL; - if (context->get_option_url) + if (context->get_option_url + && context->printer->url_format != URL_FORMAT_NONE) option_url = context->get_option_url (context, diagnostic->option_index); pretty_printer *pp = context->printer; |