-
David Malcolm authored
Various diagnostics build an intermediate string, potentially with colorization, and then use this in a diagnostic message. This won't work if we have multiple diagnostic sinks, where some might be colorized and some not. This patch reworks such places using "%e" and pp_element subclasses, so that any colorization happens within report_diagnostic's call to pp_format. gcc/analyzer/ChangeLog: PR other/116613 * kf-analyzer.cc: Include "pretty-print-markup.h". (kf_analyzer_dump_escaped::impl_call_pre): Defer colorization choices by eliminating the construction of a intermediate string, replacing it with a new pp_element subclass via "%e". gcc/ChangeLog: PR other/116613 * attribs.cc: Include "pretty-print-markup.h". (decls_mismatched_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. (maybe_diag_alias_attributes): As above, replacing pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e" in two places. * attribs.h (decls_mismatched_attributes): Update decl. * gimple-ssa-warn-access.cc: Include "pretty-print-markup.h". (pass_waccess::maybe_warn_memmodel): Defer colorization choices by replacing printing to a pretty_printer * param with use of pp_markup::comma_separated_quoted_strings and "%e". (pass_waccess::maybe_warn_memmodel): Likewise, replacing printing to a temporary buffer. * pretty-print-markup.h (class pp_markup::comma_separated_quoted_strings): New. * pretty-print.cc (pp_markup::comma_separated_quoted_strings::add_to_phase_2): New. (selftest::test_pp_printf_within_pp_element): New. (selftest::test_comma_separated_quoted_strings): New. (selftest::pretty_print_cc_tests): Call the new tests. gcc/cp/ChangeLog: PR other/116613 * pt.cc: Include "pretty-print-markup.h". (warn_spec_missing_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. Replace pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e". gcc/testsuite/ChangeLog: PR other/116613 * c-c++-common/analyzer/escaping-1.c: Update expected results to remove type information from C++ results. Previously we were using %qD with default_tree_printer, which used lang_hooks.decl_printable_name, whereas now we're using %qD with a clone of the cxx_pretty_printer. Signed-off-by:
David Malcolm <dmalcolm@redhat.com>
David Malcolm authoredVarious diagnostics build an intermediate string, potentially with colorization, and then use this in a diagnostic message. This won't work if we have multiple diagnostic sinks, where some might be colorized and some not. This patch reworks such places using "%e" and pp_element subclasses, so that any colorization happens within report_diagnostic's call to pp_format. gcc/analyzer/ChangeLog: PR other/116613 * kf-analyzer.cc: Include "pretty-print-markup.h". (kf_analyzer_dump_escaped::impl_call_pre): Defer colorization choices by eliminating the construction of a intermediate string, replacing it with a new pp_element subclass via "%e". gcc/ChangeLog: PR other/116613 * attribs.cc: Include "pretty-print-markup.h". (decls_mismatched_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. (maybe_diag_alias_attributes): As above, replacing pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e" in two places. * attribs.h (decls_mismatched_attributes): Update decl. * gimple-ssa-warn-access.cc: Include "pretty-print-markup.h". (pass_waccess::maybe_warn_memmodel): Defer colorization choices by replacing printing to a pretty_printer * param with use of pp_markup::comma_separated_quoted_strings and "%e". (pass_waccess::maybe_warn_memmodel): Likewise, replacing printing to a temporary buffer. * pretty-print-markup.h (class pp_markup::comma_separated_quoted_strings): New. * pretty-print.cc (pp_markup::comma_separated_quoted_strings::add_to_phase_2): New. (selftest::test_pp_printf_within_pp_element): New. (selftest::test_comma_separated_quoted_strings): New. (selftest::pretty_print_cc_tests): Call the new tests. gcc/cp/ChangeLog: PR other/116613 * pt.cc: Include "pretty-print-markup.h". (warn_spec_missing_attributes): Defer colorization choices by replacing printing to a pretty_printer * param with appending to a vec of strings. Replace pretty_printer with usage of pp_markup::comma_separated_quoted_strings and "%e". gcc/testsuite/ChangeLog: PR other/116613 * c-c++-common/analyzer/escaping-1.c: Update expected results to remove type information from C++ results. Previously we were using %qD with default_tree_printer, which used lang_hooks.decl_printable_name, whereas now we're using %qD with a clone of the cxx_pretty_printer. Signed-off-by:
David Malcolm <dmalcolm@redhat.com>