aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2024-09-20 18:51:55 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2024-09-20 18:51:55 -0400
commit7da682c896f949259eaf820be17b5781df2cbead (patch)
tree2cfa44bdd82a434677a2f7f8298fc864b5bbe8bd /gcc/cp
parent37604edf37b3799e0203ede4dfa60d547322fdfc (diff)
downloadgcc-7da682c896f949259eaf820be17b5781df2cbead.zip
gcc-7da682c896f949259eaf820be17b5781df2cbead.tar.gz
gcc-7da682c896f949259eaf820be17b5781df2cbead.tar.bz2
diagnostics: convert text hooks to use diagnostic_text_output_format [PR116613]
The diagnostic_starter and diagnostic_finalizer callbacks and most of their support subroutines are only used by the "text" output format. Emphasize this and reduce the binding with diagnostic_context by renaming the callbacks to add "_text" in their names, and converting the first param from diagnostic_context * to diagnostic_text_output_output &. Update the various subroutines used by diagnostic starter/finalizer callbacks to also take a diagnostic_text_output_output & rather than a diagnostic_context *. Move m_includes and m_last_seen from the context to the text output. Use the text_output's get_printer () rather than the context's m_printer, which should ease the transition to multiple output sinks. No functional change intended. gcc/c-family/ChangeLog: PR other/116613 * c-opts.cc: Include "diagnostic-format-text.h". (c_diagnostic_finalizer): Rename to... (c_diagnostic_text_finalizer): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (c_common_diagnostics_set_defaults): Update for renamings. gcc/ChangeLog: PR other/116613 * coretypes.h (class diagnostic_text_output_format): Add forward decl. * diagnostic-format-json.cc (json_output_format::after_diagnostic): New. * diagnostic-format-sarif.cc (sarif_output_format::after_diagnostic): New. * diagnostic-format-text.cc: Use pragmas to ignore -Wformat-diag. (diagnostic_text_output_format::~diagnostic_text_output_format): Use get_printer. Clean up m_includes_seen here, rather than in ~diagnostic_context. (diagnostic_text_output_format::on_report_diagnostic): Use get_printer. Update for callback renamings and pass *this to them, rather than &m_context. (diagnostic_text_output_format::after_diagnostic): New. (diagnostic_text_output_format::includes_seen_p): Move here from diagnostic_context/diagnostic.cc. (diagnostic_text_output_format::get_location_text): New. (maybe_line_and_column): Move here from diagnostic.cc and make non-static. (diagnostic_text_output_format::report_current_module): Move here from diagnostic_context/diagnostic.cc. (default_diagnostic_text_starter): Move here from diagnostic.cc, renaming from default_diagnostic_starter. (default_diagnostic_text_finalizer): Likewise, renaming from default_diagnostic_finalizer. * diagnostic-format-text.h (diagnostic_text_output_format::diagnostic_text_output_format): Initialize m_last_module and m_includes_seen. (diagnostic_text_output_format::after_diagnostic): New decl. (diagnostic_text_output_format::build_prefix): New decl. (diagnostic_text_output_format::report_current_module): New decl. (diagnostic_text_output_format::append_note): New decl. (diagnostic_text_output_format::file_name_as_prefix): New decl. (diagnostic_text_output_format::print_path): New decl. (diagnostic_text_output_format::show_column_p): New decl. (diagnostic_text_output_format::get_location_text): New decl. (diagnostic_text_output_format::includes_seen_p): New decl. (diagnostic_text_output_format::show_any_path): New decl. (diagnostic_text_output_format::m_last_module): New field. (diagnostic_text_output_format::m_includes_seen): New field. * diagnostic-format.h (diagnostic_output_format::after_diagnostic): New vfunc. (diagnostic_output_format::get_context): New. (diagnostic_output_format::get_diagram_theme): New. * diagnostic-macro-unwinding.cc: Include "diagnostic-format-text.h". (maybe_unwind_expanded_macro_loc): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (virt_loc_aware_diagnostic_finalizer): Likewise. * diagnostic-macro-unwinding.h (virt_loc_aware_diagnostic_finalizer): Likewise. (maybe_unwind_expanded_macro_loc): Likewise. * diagnostic-path.cc: Include "diagnostic-format-text.h". (path_label::path_label): Drop "ctxt" param and add "colorize" and "allow_emojis" params. Update initializations. (path_label::get_text): Use m_colorize rather than querying m_ctxt.m_printer. Use m_allow_emojis rather than querying m_ctxt's diagram theme. (path_label::m_ctxt): Drop field. (path_label::m_colorize): Drop field. (path_label::m_allow_emojis): Drop field. (event_range::event_range): Drop param "ctxt". Add params "colorize_labels" and "allow_emojis". (event_range::print): Convert first param from diagnostic_context & to diagnostic_text_output_format & and update accordingly. (path_summary::path_summary): Likewise. (path_summary::print_swimlane_for_event_range): Likewise. (print_path_summary_as_text): Likewise for 3rd param. (diagnostic_context::print_path): Convert to... (diagnostic_text_output_format::print_path): ...this. (selftest::test_empty_path): Update to use a diagnostic_text_output_format. (selftest::test_intraprocedural_path): Likewise. (selftest::test_interprocedural_path_1): Likewise. (selftest::test_interprocedural_path_2): Likewise. (selftest::test_recursion): Likewise. (selftest::test_control_flow_1): Likewise. (selftest::test_control_flow_2): Likewise. (selftest::test_control_flow_3): Likewise. (selftest::assert_cfg_edge_path_streq): Likewise. (selftest::test_control_flow_5): Likewise. (selftest::test_control_flow_6): Likewise. * diagnostic.cc (file_name_as_prefix): Convert to... (diagnostic_text_output_format::file_name_as_prefix): ...this. (diagnostic_context::initialize): Update for renamings. Move m_last_module and m_includes_seen into text output. (diagnostic_context::finish): Likewise. (diagnostic_context::get_location_text): Add "colorize" param. (diagnostic_build_prefix): Convert to... (diagnostic_text_output_format::build_prefix): ...this. (diagnostic_context::includes_seen_p): Move from here to diagnostic_text_output_format/diagnostic-format-text.cc. (diagnostic_context::report_current_module): Likewise. (diagnostic_context::show_any_path): Convert to... (diagnostic_text_output_format::show_any_path): ...this. (default_diagnostic_starter): Rename and move to diagnostic-format-text.cc. (default_diagnostic_start_span_fn): Pass colorize bool to get_location_text. (default_diagnostic_finalizer): Rename and move to diagnostic-format-text.cc. (diagnostic_context::report_diagnostic): Replace call to show_any_path with call to new output format "after_diagnostic" vfunc, moving show_any_path call to the text output format. (diagnostic_append_note): Convert to... (diagnostic_text_output_format::append_note): ...this. (selftest::assert_location_text): Pass in false for colorization. * diagnostic.h (diagnostic_starter_fn): Rename to... (diagnostic_text_starter_fn): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format &. (diagnostic_finalizer_fn, diagnostic_text_finalizer_fn): Likewise. (diagnostic_context): Update friends for renamings. (diagnostic_context::report_current_module): Move to text output format. (diagnostic_context::get_location_text): Add "colorize" bool. (diagnostic_context::includes_seen_p): Move to text output format. (diagnostic_context::show_any_path): Likewise. (diagnostic_context::print_path): Likewise. (diagnostic_context::m_text_callbacks): Update for renamings. (diagnostic_context::m_last_module): Move to text output format. (diagnostic_context::m_includes_seen): Likewise. (diagnostic_starter): Rename to... (diagnostic_text_starter): ...this and update return type. (diagnostic_finalizer): Rename to... (diagnostic_text_finalizer): ...this and update return type. (diagnostic_report_current_module): Drop decl in favor of a member function of diagnostic_text_output_format. (diagnostic_append_note): Likewise. (default_diagnostic_starter): Rename to... (default_diagnostic_text_starter): ...this, updating type. (default_diagnostic_finalizer): Rename to... (default_diagnostic_text_finalizer): ...this, updating type. (file_name_as_prefix): Drop decl. * langhooks-def.h (lhd_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * langhooks.cc: Include "diagnostic-format-text.h". (lhd_print_error_function): Likewise. Update accordingly * langhooks.h (lang_hooks::print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * tree-diagnostic.cc: Include "diagnostic-format-text.h". (diagnostic_report_current_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (default_tree_diagnostic_starter): Rename to... (default_tree_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (tree_diagnostics_defaults): Update for renamings. gcc/cp/ChangeLog: PR other/116613 * cp-tree.h (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format &. * error.cc: Include "diagnostic-format-text.h". (cxx_initialize_diagnostics): Update for renamings. (cxx_print_error_function): Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly (cp_diagnostic_starter): Rename to... (cp_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (cp_print_error_function): Likewise. (print_instantiation_full_context): Likewise. (print_instantiation_partial_context_line): Likewise. (print_instantiation_partial_context): Likewise. (maybe_print_instantiation_context): Likewise. (maybe_print_constexpr_context): Likewise. (print_location): Likewise. (print_constrained_decl_info): Likewise. (print_concept_check_info): Likewise. (print_constraint_context_head): Likewise. (print_requires_expression_info): Likewise. (maybe_print_single_constraint_context): Likewise. gcc/fortran/ChangeLog: PR other/116613 * error.cc: Include "diagnostic-format-text.h". (gfc_diagnostic_starter): Rename to... (gfc_diagnostic_text_starter): ...this. Convert first param from diagnostic_context * to diagnostic_text_output_format & and update accordingly. (gfc_diagnostic_finalizer, gfc_diagnostic_text_finalizer): Likewise. (gfc_diagnostics_init): Update for renamings. (gfc_diagnostics_finish): Likewise. gcc/jit/ChangeLog: PR other/116613 * dummy-frontend.cc: Include "diagnostic-format-text.h". (jit_begin_diagnostic): Convert first param from diagnostic_context * to diagnostic_text_output_format & (jit_end_diagnostic): Likewise. Update accordingly. (jit_langhook_init): Update for renamings. gcc/rust/ChangeLog: PR other/116613 * resolve/rust-ast-resolve-expr.cc (funny_ice_finalizer): : Convert first param from diagnostic_context * to diagnostic_text_output_format &. (ResolveExpr::visit): Update for renaming. gcc/testsuite/ChangeLog: PR other/116613 * g++.dg/plugin/show_template_tree_color_plugin.c (noop_starter_fn): Rename to... (noop_text_starter_fn): ...this. Update first param from dc to text_output. (plugin_init): Update for renamings. * gcc.dg/plugin/diagnostic_group_plugin.c (test_diagnostic_starter): Rename to... (test_diagnostic_text_starter): ...this. Update first param from dc to text_output. (plugin_init): Update for renaming. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Include "diagnostic-format-text.h". (custom_diagnostic_finalizer): Rename to... (custom_diagnostic_text_finalizer): ...this. Update first param from dc to text_output. (test_show_locus): Update for renamings. * gcc.dg/plugin/location_overflow_plugin.c: Include "diagnostic-format-text.h". (original_finalizer): Rename to... (original_text_finalizer): ...this and update type. (verify_unpacked_ranges): Update first param from dc to text_output. Update for this and for renamings. (verify_no_columns): Likewise. (plugin_init): Update for renamings. libcc1/ChangeLog: PR other/116613 * context.cc: Include "diagnostic-format-text.h". (plugin_print_error_function): Update first param from diagnostic_context * to diagnostic_text_output_format &. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/error.cc149
2 files changed, 81 insertions, 70 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 32252e7..4809576 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -8171,7 +8171,7 @@ extern void cxx_print_xnode (FILE *, tree, int);
extern void cxx_print_decl (FILE *, tree, int);
extern void cxx_print_type (FILE *, tree, int);
extern void cxx_print_identifier (FILE *, tree, int);
-extern void cxx_print_error_function (diagnostic_context *,
+extern void cxx_print_error_function (diagnostic_text_output_format &,
const char *,
const diagnostic_info *);
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index c241c3e..90e3630 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "pretty-print-format-impl.h"
#include "make-unique.h"
+#include "diagnostic-format-text.h"
#define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
@@ -98,16 +99,16 @@ static void dump_scope (cxx_pretty_printer *, tree, int);
static void dump_template_parms (cxx_pretty_printer *, tree, int, int);
static int get_non_default_template_args_count (tree, int);
static const char *function_category (tree);
-static void maybe_print_constexpr_context (diagnostic_context *);
-static void maybe_print_instantiation_context (diagnostic_context *);
-static void print_instantiation_full_context (diagnostic_context *);
-static void print_instantiation_partial_context (diagnostic_context *,
+static void maybe_print_constexpr_context (diagnostic_text_output_format &);
+static void maybe_print_instantiation_context (diagnostic_text_output_format &);
+static void print_instantiation_full_context (diagnostic_text_output_format &);
+static void print_instantiation_partial_context (diagnostic_text_output_format &,
struct tinst_level *,
location_t);
-static void maybe_print_constraint_context (diagnostic_context *);
-static void cp_diagnostic_starter (diagnostic_context *,
- const diagnostic_info *);
-static void cp_print_error_function (diagnostic_context *,
+static void maybe_print_constraint_context (diagnostic_text_output_format &);
+static void cp_diagnostic_text_starter (diagnostic_text_output_format &,
+ const diagnostic_info *);
+static void cp_print_error_function (diagnostic_text_output_format &,
const diagnostic_info *);
static bool cp_printer (pretty_printer *, text_info *, const char *,
@@ -284,8 +285,8 @@ cxx_initialize_diagnostics (diagnostic_context *context)
XDELETE (base);
c_common_diagnostics_set_defaults (context);
- diagnostic_starter (context) = cp_diagnostic_starter;
- /* diagnostic_finalizer is already c_diagnostic_finalizer. */
+ diagnostic_text_starter (context) = cp_diagnostic_text_starter;
+ /* diagnostic_finalizer is already c_diagnostic_text_finalizer. */
diagnostic_format_decoder (context) = cp_printer;
context->m_adjust_diagnostic_info = cp_adjust_diagnostic_info;
pp_format_postprocessor (pp) = new cxx_format_postprocessor ();
@@ -3665,7 +3666,8 @@ eh_spec_to_string (tree p, int /*v*/)
/* Langhook for print_error_function. */
void
-cxx_print_error_function (diagnostic_context *context, const char *file,
+cxx_print_error_function (diagnostic_text_output_format &text_output,
+ const char *file,
const diagnostic_info *diagnostic)
{
char *prefix;
@@ -3673,28 +3675,29 @@ cxx_print_error_function (diagnostic_context *context, const char *file,
prefix = xstrdup (file);
else
prefix = NULL;
- lhd_print_error_function (context, file, diagnostic);
- pp_set_prefix (context->m_printer, prefix);
- maybe_print_instantiation_context (context);
+ lhd_print_error_function (text_output, file, diagnostic);
+
+ pp_set_prefix (text_output.get_printer (), prefix);
+ maybe_print_instantiation_context (text_output);
}
static void
-cp_diagnostic_starter (diagnostic_context *context,
- const diagnostic_info *diagnostic)
+cp_diagnostic_text_starter (diagnostic_text_output_format &text_output,
+ const diagnostic_info *diagnostic)
{
- diagnostic_report_current_module (context, diagnostic_location (diagnostic));
- cp_print_error_function (context, diagnostic);
- maybe_print_instantiation_context (context);
- maybe_print_constexpr_context (context);
- maybe_print_constraint_context (context);
- pp_set_prefix (context->m_printer, diagnostic_build_prefix (context,
- diagnostic));
+ text_output.report_current_module (diagnostic_location (diagnostic));
+ cp_print_error_function (text_output, diagnostic);
+ maybe_print_instantiation_context (text_output);
+ maybe_print_constexpr_context (text_output);
+ maybe_print_constraint_context (text_output);
+ pp_set_prefix (text_output.get_printer (),
+ text_output.build_prefix (*diagnostic));
}
/* Print current function onto BUFFER, in the process of reporting
a diagnostic message. Called from cp_diagnostic_starter. */
static void
-cp_print_error_function (diagnostic_context *context,
+cp_print_error_function (diagnostic_text_output_format &text_output,
const diagnostic_info *diagnostic)
{
/* If we are in an instantiation context, current_function_decl is likely
@@ -3704,14 +3707,15 @@ cp_print_error_function (diagnostic_context *context,
/* The above is true for constraint satisfaction also. */
if (current_failed_constraint)
return;
+ diagnostic_context *const context = &text_output.get_context ();
if (diagnostic_last_function_changed (context, diagnostic))
{
- pretty_printer *const pp = context->m_printer;
+ pretty_printer *const pp = text_output.get_printer ();
char *old_prefix = pp_take_prefix (pp);
const char *file = LOCATION_FILE (diagnostic_location (diagnostic));
tree abstract_origin = diagnostic_abstract_origin (diagnostic);
char *new_prefix = (file && abstract_origin == NULL)
- ? file_name_as_prefix (context, file) : NULL;
+ ? text_output.file_name_as_prefix (file) : NULL;
pp_set_prefix (pp, new_prefix);
@@ -3773,7 +3777,7 @@ cp_print_error_function (diagnostic_context *context,
pp_newline (pp);
if (s.file != NULL)
{
- if (context->m_show_column && s.column != 0)
+ if (text_output.show_column_p () && s.column != 0)
pp_printf (pp,
_(" inlined from %qD at %r%s:%d:%d%R"),
fndecl,
@@ -3841,14 +3845,14 @@ function_category (tree fn)
/* Report the full context of a current template instantiation,
onto BUFFER. */
static void
-print_instantiation_full_context (diagnostic_context *context)
+print_instantiation_full_context (diagnostic_text_output_format &text_output)
{
struct tinst_level *p = current_instantiation ();
location_t location = input_location;
if (p)
{
- pp_verbatim (context->m_printer,
+ pp_verbatim (text_output.get_printer (),
p->list_p ()
? _("%s: In substitution of %qS:\n")
: _("%s: In instantiation of %q#D:\n"),
@@ -3859,14 +3863,14 @@ print_instantiation_full_context (diagnostic_context *context)
p = p->next;
}
- print_instantiation_partial_context (context, p, location);
+ print_instantiation_partial_context (text_output, p, location);
}
/* Helper function of print_instantiation_partial_context() that
prints a single line of instantiation context. */
static void
-print_instantiation_partial_context_line (diagnostic_context *context,
+print_instantiation_partial_context_line (diagnostic_text_output_format &text_output,
struct tinst_level *t,
location_t loc, bool recursive_p)
{
@@ -3875,9 +3879,9 @@ print_instantiation_partial_context_line (diagnostic_context *context,
expanded_location xloc = expand_location (loc);
- pretty_printer *const pp = context->m_printer;
+ pretty_printer *const pp = text_output.get_printer ();
- if (context->m_show_column)
+ if (text_output.show_column_p ())
pp_verbatim (pp, _("%r%s:%d:%d:%R "),
"locus", xloc.file, xloc.line, xloc.column);
else
@@ -3908,14 +3912,14 @@ print_instantiation_partial_context_line (diagnostic_context *context,
}
gcc_rich_location rich_loc (loc);
char *saved_prefix = pp_take_prefix (pp);
- diagnostic_show_locus (context, &rich_loc, DK_NOTE);
+ diagnostic_show_locus (&text_output.get_context (), &rich_loc, DK_NOTE, pp);
pp_set_prefix (pp, saved_prefix);
}
/* Same as print_instantiation_full_context but less verbose. */
static void
-print_instantiation_partial_context (diagnostic_context *context,
+print_instantiation_partial_context (diagnostic_text_output_format &text_output,
struct tinst_level *t0, location_t loc)
{
struct tinst_level *t;
@@ -3949,7 +3953,7 @@ print_instantiation_partial_context (diagnostic_context *context,
{
gcc_assert (t != NULL);
if (loc != t->locus)
- print_instantiation_partial_context_line (context, t, loc,
+ print_instantiation_partial_context_line (text_output, t, loc,
/*recursive_p=*/false);
loc = t->locus;
t = t->next;
@@ -3958,8 +3962,8 @@ print_instantiation_partial_context (diagnostic_context *context,
{
expanded_location xloc;
xloc = expand_location (loc);
- pretty_printer *const pp = context->m_printer;
- if (context->m_show_column)
+ pretty_printer *const pp = text_output.get_printer ();
+ if (text_output.show_column_p ())
pp_verbatim (pp,
_("%r%s:%d:%d:%R [ skipping %d instantiation "
"contexts, use -ftemplate-backtrace-limit=0 to "
@@ -3986,30 +3990,30 @@ print_instantiation_partial_context (diagnostic_context *context,
loc = t->locus;
t = t->next;
}
- print_instantiation_partial_context_line (context, t, loc,
+ print_instantiation_partial_context_line (text_output, t, loc,
t->locus == loc);
loc = t->locus;
t = t->next;
}
- print_instantiation_partial_context_line (context, NULL, loc,
+ print_instantiation_partial_context_line (text_output, NULL, loc,
/*recursive_p=*/false);
}
/* Called from cp_thing to print the template context for an error. */
static void
-maybe_print_instantiation_context (diagnostic_context *context)
+maybe_print_instantiation_context (diagnostic_text_output_format &text_output)
{
if (!problematic_instantiation_changed () || current_instantiation () == 0)
return;
record_last_problematic_instantiation ();
- print_instantiation_full_context (context);
+ print_instantiation_full_context (text_output);
}
/* Report what constexpr call(s) we're trying to expand, if any. */
void
-maybe_print_constexpr_context (diagnostic_context *context)
+maybe_print_constexpr_context (diagnostic_text_output_format &text_output)
{
vec<tree> call_stack = cx_error_context ();
unsigned ix;
@@ -4019,8 +4023,8 @@ maybe_print_constexpr_context (diagnostic_context *context)
{
expanded_location xloc = expand_location (EXPR_LOCATION (t));
const char *s = expr_as_string (t, 0);
- pretty_printer *const pp = context->m_printer;
- if (context->m_show_column)
+ pretty_printer *const pp = text_output.get_printer ();
+ if (text_output.show_column_p ())
pp_verbatim (pp,
_("%r%s:%d:%d:%R in %<constexpr%> expansion of %qs"),
"locus", xloc.file, xloc.line, xloc.column, s);
@@ -4034,11 +4038,12 @@ maybe_print_constexpr_context (diagnostic_context *context)
static void
-print_location (diagnostic_context *context, location_t loc)
+print_location (diagnostic_text_output_format &text_output,
+ location_t loc)
{
expanded_location xloc = expand_location (loc);
- pretty_printer *const pp = context->m_printer;
- if (context->m_show_column)
+ pretty_printer *const pp = text_output.get_printer ();
+ if (text_output.show_column_p ())
pp_verbatim (pp, _("%r%s:%d:%d:%R "),
"locus", xloc.file, xloc.line, xloc.column);
else
@@ -4047,23 +4052,26 @@ print_location (diagnostic_context *context, location_t loc)
}
static void
-print_constrained_decl_info (diagnostic_context *context, tree decl)
+print_constrained_decl_info (diagnostic_text_output_format &text_output,
+ tree decl)
{
- print_location (context, DECL_SOURCE_LOCATION (decl));
- pretty_printer *const pp = context->m_printer;
+ print_location (text_output, DECL_SOURCE_LOCATION (decl));
+ pretty_printer *const pp = text_output.get_printer ();
pp_verbatim (pp, "required by the constraints of %q#D\n", decl);
}
static void
-print_concept_check_info (diagnostic_context *context, tree expr, tree map, tree args)
+print_concept_check_info (diagnostic_text_output_format &text_output,
+ tree expr, tree map, tree args)
{
gcc_assert (concept_check_p (expr));
tree tmpl = TREE_OPERAND (expr, 0);
- print_location (context, DECL_SOURCE_LOCATION (tmpl));
+ print_location (text_output, DECL_SOURCE_LOCATION (tmpl));
- cxx_pretty_printer *const pp = (cxx_pretty_printer *)context->m_printer;
+ cxx_pretty_printer *const pp
+ = (cxx_pretty_printer *)text_output.get_printer ();
pp_verbatim (pp, "required for the satisfaction of %qE", expr);
if (map && map != error_mark_node)
{
@@ -4078,30 +4086,32 @@ print_concept_check_info (diagnostic_context *context, tree expr, tree map, tree
context, if any. */
static tree
-print_constraint_context_head (diagnostic_context *context, tree cxt, tree args)
+print_constraint_context_head (diagnostic_text_output_format &text_output,
+ tree cxt, tree args)
{
tree src = TREE_VALUE (cxt);
if (!src)
{
- print_location (context, input_location);
- pretty_printer *const pp = context->m_printer;
+ print_location (text_output, input_location);
+ pretty_printer *const pp = text_output.get_printer ();
pp_verbatim (pp, "required for constraint satisfaction\n");
return NULL_TREE;
}
if (DECL_P (src))
{
- print_constrained_decl_info (context, src);
+ print_constrained_decl_info (text_output, src);
return NULL_TREE;
}
else
{
- print_concept_check_info (context, src, TREE_PURPOSE (cxt), args);
+ print_concept_check_info (text_output, src, TREE_PURPOSE (cxt), args);
return TREE_CHAIN (cxt);
}
}
static void
-print_requires_expression_info (diagnostic_context *context, tree constr, tree args)
+print_requires_expression_info (diagnostic_text_output_format &text_output,
+ tree constr, tree args)
{
tree expr = ATOMIC_CONSTR_EXPR (constr);
@@ -4110,9 +4120,9 @@ print_requires_expression_info (diagnostic_context *context, tree constr, tree a
if (map == error_mark_node)
return;
- print_location (context, cp_expr_loc_or_input_loc (expr));
+ print_location (text_output, cp_expr_loc_or_input_loc (expr));
cxx_pretty_printer *const pp
- = static_cast <cxx_pretty_printer *> (context->m_printer);
+ = static_cast <cxx_pretty_printer *> (text_output.get_printer ());
pp_verbatim (pp, "in requirements ");
tree parms = TREE_OPERAND (expr, 0);
@@ -4131,7 +4141,8 @@ print_requires_expression_info (diagnostic_context *context, tree constr, tree a
}
void
-maybe_print_single_constraint_context (diagnostic_context *context, tree failed)
+maybe_print_single_constraint_context (diagnostic_text_output_format &text_output,
+ tree failed)
{
if (!failed)
return;
@@ -4145,23 +4156,23 @@ maybe_print_single_constraint_context (diagnostic_context *context, tree failed)
tree args = TREE_PURPOSE (failed);
/* Print the stack of requirements. */
- cxt = print_constraint_context_head (context, cxt, args);
+ cxt = print_constraint_context_head (text_output, cxt, args);
while (cxt && !DECL_P (TREE_VALUE (cxt)))
{
tree expr = TREE_VALUE (cxt);
tree map = TREE_PURPOSE (cxt);
- print_concept_check_info (context, expr, map, args);
+ print_concept_check_info (text_output, expr, map, args);
cxt = TREE_CHAIN (cxt);
}
/* For certain constraints, we can provide additional context. */
if (TREE_CODE (constr) == ATOMIC_CONSTR
&& TREE_CODE (ATOMIC_CONSTR_EXPR (constr)) == REQUIRES_EXPR)
- print_requires_expression_info (context, constr, args);
+ print_requires_expression_info (text_output, constr, args);
}
void
-maybe_print_constraint_context (diagnostic_context *context)
+maybe_print_constraint_context (diagnostic_text_output_format &text_output)
{
if (!current_failed_constraint)
return;
@@ -4171,10 +4182,10 @@ maybe_print_constraint_context (diagnostic_context *context)
/* Recursively print nested contexts. */
current_failed_constraint = TREE_CHAIN (current_failed_constraint);
if (current_failed_constraint)
- maybe_print_constraint_context (context);
+ maybe_print_constraint_context (text_output);
/* Print this context. */
- maybe_print_single_constraint_context (context, cur);
+ maybe_print_single_constraint_context (text_output, cur);
}
/* Return true iff TYPE_A and TYPE_B are template types that are