From f012c8ef4b35dcee9b5a3807868d050812d5b3b9 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 30 May 2017 20:38:14 +0000 Subject: C++ template type diff printing gcc/ChangeLog: * diagnostic-color.c (color_dict): Add "type-diff". (parse_gcc_colors): Update comment. * doc/invoke.texi (Diagnostic Message Formatting Options): Add -fdiagnostics-show-template-tree and -fno-elide-type. (GCC_COLORS): Add type-diff to example. (type-diff=): New. (-fdiagnostics-show-template-tree): New. (-fno-elide-type): New. * pretty-print.c (pp_format): Pass quote and formatters[argno] to the pp_format_decoder callback. Call any m_format_postprocessor's "handle" method. (pretty_printer::pretty_printer): Initialize m_format_postprocessor. (pretty_printer::~pretty_printer): Delete any m_format_postprocessor. * pretty-print.h (printer_fn): Add bool and const char ** parameters. (class format_postprocessor): New class. (struct pretty_printer::format_decoder): Document the new parameters. (struct pretty_printer::m_format_postprocessor): New field. * tree-diagnostic.c (default_tree_printer): Update for new bool and const char ** params. * tree-diagnostic.h (default_tree_printer): Likewise. gcc/c/ChangeLog: * c-objc-common.c (c_tree_printer): Gain bool and const char ** parameters. gcc/c-family/ChangeLog: * c-format.c (gcc_cxxdiag_char_table): Add 'H' and 'I' to format_chars. * c.opt (fdiagnostics-show-template-tree): New option. (felide-type): New option. gcc/cp/ChangeLog: * call.c (perform_implicit_conversion_flags): Convert "from %qT to %qT" to "from %qH to %qI" in diagnostic. (print_conversion_rejection): Replace pairs of %qT with %qH and %qI in various places. (build_user_type_conversion_1): Likewise. (build_integral_nontype_arg_conv): Likewise. (build_conditional_expr_1): Likewise. (convert_like_real): Likewise. (convert_arg_to_ellipsis): Likewise. (joust): Likewise. (initialize_reference): Likewise. * cvt.c (cp_convert_to_pointer): Likewise. (cp_convert_to_pointer): Likewise. (convert_to_reference): Likewise. (ocp_convert): Likewise. * error.c (cp_printer): Gain bool and const char ** parameters. (struct deferred_printed_type): New struct. (class cxx_format_postprocessor): New class. (cxx_initialize_diagnostics): Wire up a cxx_format_postprocessor to pp->m_format_postprocessor. (comparable_template_types_p): New function. (newline_and_indent): New function. (arg_to_string): New function. (print_nonequal_arg): New function. (print_template_differences): New function. (type_to_string_with_compare): New function. (print_template_tree_comparison): New function. (append_formatted_chunk): New function. (add_quotes): New function. (cxx_format_postprocessor::handle): New function. (defer_phase_2_of_type_diff): New function. (cp_printer): Add "quoted" and "buffer_ptr" params. Implement %H and %I. * typeck.c (cp_build_binary_op): Replace pairs of %qT with %qH and %qI in various places. (convert_member_func_to_ptr): Likewise. (build_reinterpret_cast_1): Likewise. (convert_for_assignment): Likewise. * typeck2.c (check_narrowing): Likewise. gcc/fortran/ChangeLog: * error.c (gfc_format_decoder): Update for new bool and const char ** params. gcc/testsuite/ChangeLog: * g++.dg/plugin/plugin.exp (plugin_test_list): Add... * g++.dg/plugin/show-template-tree-color-no-elide-type.C: New test case. * g++.dg/plugin/show-template-tree-color.C: New test case. * g++.dg/plugin/show_template_tree_color_plugin.c: New plugin. * g++.dg/template/show-template-tree-2.C: New test case. * g++.dg/template/show-template-tree-3.C: New test case. * g++.dg/template/show-template-tree-4.C: New test case. * g++.dg/template/show-template-tree-no-elide-type.C: New test case. * g++.dg/template/show-template-tree.C: New test case. From-SVN: r248698 --- gcc/pretty-print.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/pretty-print.c') diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index bcb1a70..570dec7 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -677,7 +677,8 @@ pp_format (pretty_printer *pp, text_info *text) gcc_assert (pp_format_decoder (pp)); ok = pp_format_decoder (pp) (pp, text, p, - precision, wide, plus, hash); + precision, wide, plus, hash, quote, + formatters[argno]); gcc_assert (ok); } } @@ -696,6 +697,11 @@ pp_format (pretty_printer *pp, text_info *text) for (; argno < PP_NL_ARGMAX; argno++) gcc_assert (!formatters[argno]); + /* If the client supplied a postprocessing object, call its "handle" + hook here. */ + if (pp->m_format_postprocessor) + pp->m_format_postprocessor->handle (pp); + /* Revert to normal obstack and wrapping mode. */ buffer->obstack = &buffer->formatted_obstack; buffer->line_length = 0; @@ -847,6 +853,7 @@ pretty_printer::pretty_printer (const char *p, int l) indent_skip (), wrapping (), format_decoder (), + m_format_postprocessor (NULL), emitted_prefix (), need_newline (), translate_identifiers (true), @@ -860,6 +867,8 @@ pretty_printer::pretty_printer (const char *p, int l) pretty_printer::~pretty_printer () { + if (m_format_postprocessor) + delete m_format_postprocessor; buffer->~output_buffer (); XDELETE (buffer); } -- cgit v1.1