emergency_dump_function ();
/* Reset the pretty-printer. */
- pp_clear_output_area (context->printer);
+ pp_clear_output_area (context->m_printer);
/* Format the message into the pretty-printer. */
text_info tinfo (msgid, ap, errno);
- pp_format_verbatim (context->printer, &tinfo);
+ pp_format_verbatim (context->m_printer, &tinfo);
/* Extract a (writable) pointer to the formatted text. */
- buffer = xstrdup (pp_formatted_text (context->printer));
+ buffer = xstrdup (pp_formatted_text (context->m_printer));
/* Go up to the first newline. */
for (p = buffer; *p; p++)
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
log_user the_logger (NULL);
if (logfile)
the_logger.set_logger (new logger (logfile, 0, 0,
- *global_dc->printer));
+ *global_dc->m_printer));
stash_named_constants (the_logger.get_logger (), tu);
run_callbacks (the_logger.get_logger (), tu);
label_text
make_label_text (bool can_colorize, const char *fmt, ...)
{
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
pp_clear_output_area (pp);
if (!can_colorize)
const char *singular_fmt,
const char *plural_fmt, ...)
{
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
pp_clear_output_area (pp);
if (!can_colorize)
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (ext_state, &pp, simple);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, simple);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump (&pp);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, show_types);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, show_types);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, true);
pp_flush (&pp);
sd.get_index (), sd.m_d->get_kind (), sd.m_snode->m_index);
log ("num dupes: %i", sd.get_num_dupes ());
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
const exploded_path *epath = sd.get_best_epath ();
gcc_assert (epath);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, ext_state);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, ext_state);
pp_flush (&pp);
get_or_create_any_logfile ();
if (dump_fout)
the_logger.set_logger (new logger (dump_fout, 0, 0,
- *global_dc->printer));
+ *global_dc->m_printer));
LOG_SCOPE (the_logger.get_logger ());
impl_run_checkers (the_logger.get_logger ());
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
bool first = true;
for (auto iter : escaped_decls)
{
label_text
evdesc::event_desc::formatted_print (const char *fmt, ...) const
{
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
pp_show_color (pp) = m_colorize;
debug_diagnostic_context tmp_dc;
gcc_rich_location richloc (stmt->location);
diagnostic_show_locus (&tmp_dc, &richloc, DK_ERROR);
- pp_string (pp, pp_formatted_text (tmp_dc.printer));
+ pp_string (pp, pp_formatted_text (tmp_dc.m_printer));
}
/* class program_point. */
program_point::dump () const
{
pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
print (&pp, format (true));
pp_flush (&pp);
{
pretty_printer pp;
if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (outf);
dump_to_pp (&pp);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
print (NULL, simple, true, &pp);
pp_newline (&pp);
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (outf);
dump_to_pp (ext_state, summarize, multiline, &pp);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple, mgr);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple, true);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, simple, multiline);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (fp);
dump_to_pp (&pp, simple);
pp_flush (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
deallocator_set::dump () const
{
pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp);
pp_newline (&pp);
static bool sufficiently_similar_p (tree expr_a, tree expr_b)
{
- pretty_printer *pp_a = global_dc->printer->clone ();
- pretty_printer *pp_b = global_dc->printer->clone ();
+ pretty_printer *pp_a = global_dc->m_printer->clone ();
+ pretty_printer *pp_b = global_dc->m_printer->clone ();
pp_printf (pp_a, "%qE", expr_a);
pp_printf (pp_b, "%qE", expr_b);
bool result = (strcmp (pp_formatted_text (pp_a), pp_formatted_text (pp_b))
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple, true);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
pp_string (&pp, " cluster for: ");
m_base_region->dump_to_pp (&pp, simple);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple, true, NULL);
pp_newline (&pp);
void
supergraph::dump_dot_to_file (FILE *fp, const dump_args_t &dump_args) const
{
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
pp_show_color (pp) = 0;
/* %qE in logs for SSA_NAMEs should show the ssa names, rather than
trying to prettify things by showing the underlying var. */
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump (&pp);
pp_newline (&pp);
{
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
dump_to_pp (&pp, simple);
pp_newline (&pp);
{
if (nattrs)
pp_string (attrstr, ", ");
- pp_begin_quote (attrstr, pp_show_color (global_dc->printer));
+ pp_begin_quote (attrstr, pp_show_color (global_dc->m_printer));
pp_string (attrstr, blacklist[i]);
- pp_end_quote (attrstr, pp_show_color (global_dc->printer));
+ pp_end_quote (attrstr, pp_show_color (global_dc->m_printer));
++nattrs;
}
/* Format the type using the current pretty printer. The generic tree
printer does a terrible job. */
- pretty_printer *pp = global_dc->printer->clone ();
+ pretty_printer *pp = global_dc->m_printer->clone ();
pp_printf (pp, "%qT", type);
typstr = pp_formatted_text (pp);
delete pp;
" ~^ ~~~\n"
" | |\n"
" char* int\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
else
/* "char *", with a space. */
ASSERT_STREQ (" printf (\"msg: %i\\n\", msg);\n"
" | |\n"
" | int\n"
" char *\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Run all of the selftests within this file. */
const diagnostic_info *diagnostic,
diagnostic_t)
{
- char *saved_prefix = pp_take_prefix (context->printer);
- pp_set_prefix (context->printer, NULL);
- pp_newline (context->printer);
- diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
+ pretty_printer *const pp = context->m_printer;
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp, NULL);
+ pp_newline (pp);
+ diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind, pp);
/* By default print macro expansion contexts in the diagnostic
finalizer -- for tokens resulting from macro expansion. */
virt_loc_aware_diagnostic_finalizer (context, diagnostic);
- pp_set_prefix (context->printer, saved_prefix);
- pp_flush (context->printer);
+ pp_set_prefix (pp, saved_prefix);
+ pp_flush (pp);
}
/* Common default settings for diagnostics. */
void
c_initialize_diagnostics (diagnostic_context *context)
{
- pretty_printer *base = context->printer;
+ pretty_printer *base = context->m_printer;
c_pretty_printer *pp = XNEW (c_pretty_printer);
- context->printer = new (pp) c_pretty_printer ();
+ context->m_printer = new (pp) c_pretty_printer ();
/* It is safe to free this object because it was previously XNEW()'d. */
base->~pretty_printer ();
void
cxx_initialize_diagnostics (diagnostic_context *context)
{
- pretty_printer *base = context->printer;
+ pretty_printer *base = context->m_printer;
cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
- context->printer = new (pp) cxx_pretty_printer ();
+ context->m_printer = new (pp) cxx_pretty_printer ();
/* It is safe to free this object because it was previously XNEW()'d. */
base->~pretty_printer ();
else
prefix = NULL;
lhd_print_error_function (context, file, diagnostic);
- pp_set_prefix (context->printer, prefix);
+ pp_set_prefix (context->m_printer, prefix);
maybe_print_instantiation_context (context);
}
maybe_print_instantiation_context (context);
maybe_print_constexpr_context (context);
maybe_print_constraint_context (context);
- pp_set_prefix (context->printer, diagnostic_build_prefix (context,
- diagnostic));
+ pp_set_prefix (context->m_printer, diagnostic_build_prefix (context,
+ diagnostic));
}
/* Print current function onto BUFFER, in the process of reporting
return;
if (diagnostic_last_function_changed (context, diagnostic))
{
- char *old_prefix = pp_take_prefix (context->printer);
+ pretty_printer *const pp = context->m_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;
- pp_set_prefix (context->printer, new_prefix);
+ pp_set_prefix (pp, new_prefix);
if (current_function_decl == NULL)
- pp_string (context->printer, _("At global scope:"));
+ pp_string (pp, _("At global scope:"));
else
{
tree fndecl, ao;
else
fndecl = current_function_decl;
- pp_printf (context->printer, function_category (fndecl),
+ pp_printf (pp, function_category (fndecl),
fndecl);
while (abstract_origin)
if (fndecl)
{
expanded_location s = expand_location (*locus);
- pp_character (context->printer, ',');
- pp_newline (context->printer);
+ pp_character (pp, ',');
+ pp_newline (pp);
if (s.file != NULL)
{
if (context->m_show_column && s.column != 0)
- pp_printf (context->printer,
+ pp_printf (pp,
_(" inlined from %qD at %r%s:%d:%d%R"),
fndecl,
"locus", s.file, s.line, s.column);
else
- pp_printf (context->printer,
+ pp_printf (pp,
_(" inlined from %qD at %r%s:%d%R"),
fndecl,
"locus", s.file, s.line);
}
else
- pp_printf (context->printer, _(" inlined from %qD"),
+ pp_printf (pp, _(" inlined from %qD"),
fndecl);
}
}
- pp_character (context->printer, ':');
+ pp_character (pp, ':');
}
- pp_newline (context->printer);
+ pp_newline (pp);
diagnostic_set_last_function (context, diagnostic);
- context->printer->set_prefix (old_prefix);
+ pp->set_prefix (old_prefix);
}
}
if (p)
{
- pp_verbatim (context->printer,
+ pp_verbatim (context->m_printer,
p->list_p ()
? _("%s: In substitution of %qS:\n")
: _("%s: In instantiation of %q#D:\n"),
expanded_location xloc = expand_location (loc);
+ pretty_printer *const pp = context->m_printer;
+
if (context->m_show_column)
- pp_verbatim (context->printer, _("%r%s:%d:%d:%R "),
+ pp_verbatim (pp, _("%r%s:%d:%d:%R "),
"locus", xloc.file, xloc.line, xloc.column);
else
- pp_verbatim (context->printer, _("%r%s:%d:%R "),
+ pp_verbatim (pp, _("%r%s:%d:%R "),
"locus", xloc.file, xloc.line);
if (t != NULL)
{
if (t->list_p ())
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
recursive_p
? _("recursively required by substitution of %qS\n")
: _("required by substitution of %qS\n"),
t->get_node ());
else
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
recursive_p
? _("recursively required from %q#D\n")
: _("required from %q#D\n"),
}
else
{
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
recursive_p
? _("recursively required from here\n")
: _("required from here\n"));
}
gcc_rich_location rich_loc (loc);
- char *saved_prefix = pp_take_prefix (context->printer);
+ char *saved_prefix = pp_take_prefix (pp);
diagnostic_show_locus (context, &rich_loc, DK_NOTE);
- pp_set_prefix (context->printer, saved_prefix);
+ pp_set_prefix (pp, saved_prefix);
}
/* Same as print_instantiation_full_context but less verbose. */
{
expanded_location xloc;
xloc = expand_location (loc);
+ pretty_printer *const pp = context->m_printer;
if (context->m_show_column)
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
_("%r%s:%d:%d:%R [ skipping %d instantiation "
"contexts, use -ftemplate-backtrace-limit=0 to "
"disable ]\n"),
"locus", xloc.file, xloc.line, xloc.column, skip);
else
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
_("%r%s:%d:%R [ skipping %d instantiation "
"contexts, use -ftemplate-backtrace-limit=0 to "
"disable ]\n"),
{
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)
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
_("%r%s:%d:%d:%R in %<constexpr%> expansion of %qs"),
"locus", xloc.file, xloc.line, xloc.column, s);
else
- pp_verbatim (context->printer,
+ pp_verbatim (pp,
_("%r%s:%d:%R in %<constexpr%> expansion of %qs"),
"locus", xloc.file, xloc.line, s);
- pp_newline (context->printer);
+ pp_newline (pp);
}
}
\f
print_location (diagnostic_context *context, location_t loc)
{
expanded_location xloc = expand_location (loc);
+ pretty_printer *const pp = context->m_printer;
if (context->m_show_column)
- pp_verbatim (context->printer, _("%r%s:%d:%d:%R "),
+ pp_verbatim (pp, _("%r%s:%d:%d:%R "),
"locus", xloc.file, xloc.line, xloc.column);
else
- pp_verbatim (context->printer, _("%r%s:%d:%R "),
+ pp_verbatim (pp, _("%r%s:%d:%R "),
"locus", xloc.file, xloc.line);
}
print_constrained_decl_info (diagnostic_context *context, tree decl)
{
print_location (context, DECL_SOURCE_LOCATION (decl));
- pp_verbatim (context->printer, "required by the constraints of %q#D\n", decl);
+ pretty_printer *const pp = context->m_printer;
+ pp_verbatim (pp, "required by the constraints of %q#D\n", decl);
}
static void
print_location (context, DECL_SOURCE_LOCATION (tmpl));
- cxx_pretty_printer *pp = (cxx_pretty_printer *)context->printer;
+ cxx_pretty_printer *const pp = (cxx_pretty_printer *)context->m_printer;
pp_verbatim (pp, "required for the satisfaction of %qE", expr);
if (map && map != error_mark_node)
{
if (!src)
{
print_location (context, input_location);
- pp_verbatim (context->printer, "required for constraint satisfaction\n");
+ pretty_printer *const pp = context->m_printer;
+ pp_verbatim (pp, "required for constraint satisfaction\n");
return NULL_TREE;
}
if (DECL_P (src))
return;
print_location (context, cp_expr_loc_or_input_loc (expr));
- pp_verbatim (context->printer, "in requirements ");
+ cxx_pretty_printer *const pp
+ = static_cast <cxx_pretty_printer *> (context->m_printer);
+ pp_verbatim (pp, "in requirements ");
tree parms = TREE_OPERAND (expr, 0);
if (parms)
- pp_verbatim (context->printer, "with ");
+ pp_verbatim (pp, "with ");
while (parms)
{
- pp_verbatim (context->printer, "%q#D", parms);
+ pp_verbatim (pp, "%q#D", parms);
if (TREE_CHAIN (parms))
- pp_separate_with_comma ((cxx_pretty_printer *)context->printer);
+ pp_separate_with_comma (pp);
parms = TREE_CHAIN (parms);
}
- pp_cxx_parameter_mapping ((cxx_pretty_printer *)context->printer, map);
+ pp_cxx_parameter_mapping (pp, map);
- pp_verbatim (context->printer, "\n");
+ pp_verbatim (pp, "\n");
}
void
if (quiet_flag)
return false;
- pp_needs_newline (global_dc->printer) = true;
+ pp_needs_newline (global_dc->m_printer) = true;
diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
return true;
/* Write verbatim messages with no location direct to stream. */
text_info text (expand_d_format (format), &argp, errno, nullptr);
- pp_format_verbatim (global_dc->printer, &text);
- pp_newline_and_flush (global_dc->printer);
+ pretty_printer *const pp = global_dc->m_printer;
+ pp_format_verbatim (pp, &text);
+ pp_newline_and_flush (pp);
}
va_end (argp);
json_output_format::on_report_diagnostic (const diagnostic_info &diagnostic,
diagnostic_t orig_diag_kind)
{
- pp_output_formatted_text (m_context.printer, m_context.get_urlifier ());
+ pretty_printer *const pp = get_printer ();
+ pp_output_formatted_text (pp, m_context.get_urlifier ());
json::object *diag_obj = new json::object ();
}
// FIXME: encoding of the message (json::string requires UTF-8)
- diag_obj->set_string ("message", pp_formatted_text (m_context.printer));
- pp_clear_output_area (m_context.printer);
+ diag_obj->set_string ("message", pp_formatted_text (pp));
+ pp_clear_output_area (pp);
if (char *option_text = m_context.make_option_name (diagnostic.option_index,
orig_diag_kind,
context.set_path_format (DPF_NONE);
/* Don't colorize the text. */
- pp_show_color (context.printer) = false;
+ pp_show_color (context.m_printer) = false;
context.set_show_highlight_colors (false);
}
= builder.make_location_object (*this, *diagnostic.richloc, nullptr,
diagnostic_artifact_role::result_file);
auto message_obj
- = builder.make_message_object (pp_formatted_text (context.printer));
- pp_clear_output_area (context.printer);
+ = builder.make_message_object (pp_formatted_text (context.m_printer));
+ pp_clear_output_area (context.m_printer);
location_obj->set<sarif_message> ("message", std::move (message_obj));
add_related_location (std::move (location_obj));
/* "message" property (SARIF v2.1.0 section 3.85.5). */
auto message_obj
- = builder.make_message_object (pp_formatted_text (context.printer));
- pp_clear_output_area (context.printer);
+ = builder.make_message_object (pp_formatted_text (context.m_printer));
+ pp_clear_output_area (context.m_printer);
set<sarif_message> ("message", std::move (message_obj));
/* "level" property (SARIF v2.1.0 section 3.58.6). */
const diagnostic_info &diagnostic,
diagnostic_t orig_diag_kind)
{
- pp_output_formatted_text (context.printer, context.get_urlifier ());
+ pp_output_formatted_text (context.m_printer, context.get_urlifier ());
if (diagnostic.kind == DK_ICE || diagnostic.kind == DK_ICE_NOBT)
{
/* "message" property (SARIF v2.1.0 section 3.27.11). */
auto message_obj
- = make_message_object (pp_formatted_text (context.printer));
- pp_clear_output_area (context.printer);
+ = make_message_object (pp_formatted_text (context.m_printer));
+ pp_clear_output_area (context.m_printer);
result_obj->set<sarif_message> ("message", std::move (message_obj));
/* "locations" property (SARIF v2.1.0 section 3.27.12). */
std::unique_ptr<sarif_multiformat_message_string> result
= builder.make_multiformat_message_string
- (pp_formatted_text (dc.printer));
+ (pp_formatted_text (dc.m_printer));
diagnostic_finish (&dc);
/* "text" property (SARIF v2.1.0 section 3.11.8). */
message_obj->set_string ("text", diagram.get_alt_text ());
- char *saved_prefix = pp_take_prefix (context.printer);
- pp_set_prefix (context.printer, nullptr);
+ pretty_printer *const pp = context.m_printer;
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp, nullptr);
/* "To produce a code block in Markdown, simply indent every line of
the block by at least 4 spaces or 1 tab."
Here we use 4 spaces. */
- diagram.get_canvas ().print_to_pp (context.printer, " ");
- pp_set_prefix (context.printer, saved_prefix);
+ diagram.get_canvas ().print_to_pp (pp, " ");
+ pp_set_prefix (pp, saved_prefix);
/* "markdown" property (SARIF v2.1.0 section 3.11.9). */
- message_obj->set_string ("markdown", pp_formatted_text (context.printer));
+ message_obj->set_string ("markdown", pp_formatted_text (pp));
- pp_clear_output_area (context.printer);
+ pp_clear_output_area (pp);
return message_obj;
}
context.set_ice_handler_callback (sarif_ice_handler);
/* Don't colorize the text. */
- pp_show_color (context.printer) = false;
+ pp_show_color (context.m_printer) = false;
context.set_show_highlight_colors (false);
- context.printer->set_token_printer
+ context.m_printer->set_token_printer
(&fmt->get_builder ().get_token_printer ());
context.set_output_format (fmt.release ());
}
/* Some of the errors may actually have been warnings. */
if (m_context.diagnostic_count (DK_WERROR))
{
+ pretty_printer *pp = m_context.m_printer;
/* -Werror was given. */
if (m_context.warning_as_error_requested_p ())
- pp_verbatim (m_context.printer,
+ pp_verbatim (pp,
_("%s: all warnings being treated as errors"),
progname);
/* At least one -Werror= was given. */
else
- pp_verbatim (m_context.printer,
+ pp_verbatim (pp,
_("%s: some warnings being treated as errors"),
progname);
- pp_newline_and_flush (m_context.printer);
+ pp_newline_and_flush (pp);
}
}
on_report_diagnostic (const diagnostic_info &diagnostic,
diagnostic_t orig_diag_kind)
{
+ pretty_printer *pp = m_context.m_printer;
+
(*diagnostic_starter (&m_context)) (&m_context, &diagnostic);
- pp_output_formatted_text (m_context.printer, m_context.get_urlifier ());
+ pp_output_formatted_text (pp, m_context.get_urlifier ());
if (m_context.m_show_cwe)
print_any_cwe (diagnostic);
if (m_context.m_show_option_requested)
print_option_information (diagnostic, orig_diag_kind);
- (*diagnostic_finalizer (&m_context)) (&m_context, &diagnostic,
+ (*diagnostic_finalizer (&m_context)) (&m_context,
+ &diagnostic,
orig_diag_kind);
}
void
diagnostic_text_output_format::on_diagram (const diagnostic_diagram &diagram)
{
- char *saved_prefix = pp_take_prefix (m_context.printer);
- pp_set_prefix (m_context.printer, NULL);
+ pretty_printer *const pp = get_printer ();
+
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp, NULL);
/* Use a newline before and after and a two-space indent
to make the diagram stand out a little from the wall of text. */
- pp_newline (m_context.printer);
- diagram.get_canvas ().print_to_pp (m_context.printer, " ");
- pp_newline (m_context.printer);
- pp_set_prefix (m_context.printer, saved_prefix);
- pp_flush (m_context.printer);
+ pp_newline (pp);
+ diagram.get_canvas ().print_to_pp (pp, " ");
+ pp_newline (pp);
+ pp_set_prefix (pp, saved_prefix);
+ pp_flush (pp);
}
/* If DIAGNOSTIC has a CWE identifier, print it.
int cwe = diagnostic.metadata->get_cwe ();
if (cwe)
{
- pretty_printer * const pp = m_context.printer;
+ pretty_printer * const pp = get_printer ();
char *saved_prefix = pp_take_prefix (pp);
pp_string (pp, " [");
const char *kind_color = diagnostic_get_color_for_kind (diagnostic.kind);
= diagnostic.metadata->get_rule (idx);
if (char *desc = rule.make_description ())
{
- pretty_printer * const pp = m_context.printer;
+ pretty_printer * const pp = get_printer ();
char *saved_prefix = pp_take_prefix (pp);
pp_string (pp, " [");
const char *kind_color
orig_diag_kind, diagnostic.kind))
{
char *option_url = nullptr;
- pretty_printer * const pp = m_context.printer;
+ pretty_printer * const pp = get_printer ();
if (pp->supports_urls_p ())
option_url = m_context.make_option_url (diagnostic.option_index);
pp_string (pp, " [");
virtual void on_diagram (const diagnostic_diagram &diagram) = 0;
virtual bool machine_readable_stderr_p () const = 0;
+ pretty_printer *get_printer () const { return m_context.m_printer; }
+
protected:
diagnostic_output_format (diagnostic_context &context)
: m_context (context)
va_start (ap, gmsgid);
text_info text (_(gmsgid), &ap, errno);
- pp_format_verbatim (global_dc->printer, &text);
- pp_newline_and_flush (global_dc->printer);
+ pp_format_verbatim (global_dc->m_printer, &text);
+ pp_newline_and_flush (global_dc->m_printer);
va_end (ap);
}
/* Get the description of the event, perhaps with colorization:
normally, we don't colorize within a range_label, but this
is special-cased for diagnostic paths. */
- const bool colorize = pp_show_color (m_ctxt.printer);
+ const bool colorize = pp_show_color (m_ctxt.m_printer);
label_text event_text (event.get_desc (colorize));
gcc_assert (event_text.get ());
diagnostic_context &dc,
bool show_depths)
{
- pretty_printer *pp = dc.printer;
+ pretty_printer *const pp = dc.m_printer;
std::vector<thread_event_printer> thread_event_printers;
for (auto t : ps.m_per_thread_summary)
/* Consolidate related events. */
path_summary summary (*this, path, true,
m_source_printing.show_event_links_p);
- char *saved_prefix = pp_take_prefix (this->printer);
- pp_set_prefix (this->printer, NULL);
+ char *saved_prefix = pp_take_prefix (m_printer);
+ pp_set_prefix (m_printer, NULL);
print_path_summary_as_text (summary, *this,
show_path_depths_p ());
- pp_flush (this->printer);
- pp_set_prefix (this->printer, saved_prefix);
+ pp_flush (m_printer);
+ pp_set_prefix (m_printer, saved_prefix);
}
break;
}
print_path_summary_as_text (summary, dc, true);
ASSERT_STREQ ("",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that print_path_summary works on a purely intraprocedural path. */
ASSERT_STREQ (" `foo': events 1-2 (depth 0)\n"
" (1): first `free'\n"
" (2): double `free'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that print_path_summary works on an interprocedural path. */
" | (17): entering `wrapped_free'\n"
" | (18): calling free\n"
" |\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" │ (17): entering `wrapped_free'\n"
" │ (18): calling free\n"
" │\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" |\n"
" | (8): entering `baz'\n"
" |\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" │\n"
" │ (8): entering `baz'\n"
" │\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" |\n"
" | (7): entering `factorial'\n"
" |\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" │\n"
" │ (7): entering `factorial'\n"
" │\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
"| |\n"
"+-------->(2) ...to here\n"
" (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" |\n"
" (2) ...to here\n"
" (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" || |\n"
" |+-------->(2) ...to here\n"
" | (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" | |\n"
" | (2) ...to here\n"
" | (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
"│ |\n"
"└────────>(2) ...to here\n"
" (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" |│ |\n"
" |└────────>(2) ...to here\n"
" | (3) dereference of NULL `p'\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" || ^~~~\n"
" || |\n"
" |+----------------------------->(5) ...to here\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" || ^\n"
" || |\n"
" |+----------------->(5) ...to here\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
path_summary summary (dc, path, true);
print_path_summary_as_text (summary, dc, false);
ASSERT_STREQ_AT (loc, expected_str,
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Assert that if we make a path with an event with "from here..." at SRC_LOC
" || ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
" || | |\n"
" |+----------->(4) ...to here (5) allocated here\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" || ~~~~~~~~~~~~~\n"
" || |\n"
" |+------------->(5) ...to here\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
: m_options (context.m_source_printing),
m_line_table (richloc.get_line_table ()),
m_file_cache (context.get_file_cache ()),
- m_pp (pp ? pp : context.printer),
+ m_pp (pp ? pp : context.m_printer),
/* Ensure we have a non-null m_theme. */
m_theme (context.get_diagram_theme ()
? *context.get_diagram_theme ()
"that occupies 8 bytes and 4 display columns, starting at "
"column #102.\n"
" | ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Similar to the previous example, but now the offset called for would split
"that occupies 8 bytes and 4 display columns, starting at "
"column #102.\n"
" | ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
dc.m_tabstop = tabstop;
layout test_layout (dc, richloc, DK_ERROR, nullptr);
test_layout.print_line (1);
- const char *out = pp_formatted_text (dc.printer);
+ const char *out = pp_formatted_text (dc.m_printer);
ASSERT_EQ (NULL, strchr (out, '\t'));
const char *left_quote = strchr (out, '`');
const char *right_quote = strchr (out, '\'');
"display columns, starting at column #103.\n"
" | ^\n";
const char *expected_output = (extra_width[tabstop] ? output1 : output2);
- ASSERT_STREQ (expected_output, pp_formatted_text (dc.printer));
+ ASSERT_STREQ (expected_output, pp_formatted_text (dc.m_printer));
}
}
test_diagnostic_context dc;
rich_location richloc (line_table, UNKNOWN_LOCATION);
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
- ASSERT_STREQ ("", pp_formatted_text (dc.printer));
+ ASSERT_STREQ ("", pp_formatted_text (dc.m_printer));
}
/* Verify that diagnostic_show_locus works sanely for various
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* No column information (column == 0).
rich_location richloc (line_table, caret);
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Caret and range. */
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ~~~^~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Multiple ranges and carets. */
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ~A~ ~B~ ~~C~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Insertion fix-it hint: adding an "&" to the front of "bar.field". */
ASSERT_STREQ (" foo = bar.field;\n"
" ^\n"
" &\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Insertion fix-it hint: adding a "[0]" after "foo". */
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~\n"
" [0]\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Removal fix-it hint: removal of the ".field".
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~~~~\n"
" ------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of adding a prefix. */
{
test_diagnostic_context dc;
- pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
- pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:"));
+ pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
+ pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:"));
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("TEST PREFIX: foo = bar.field;\n"
"TEST PREFIX: ^~~~~~\n"
"TEST PREFIX: ------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Normal, with ruler. */
" foo = bar.field;\n"
" ^~~~~~\n"
" ------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of adding a prefix, with ruler. */
test_diagnostic_context dc;
dc.m_source_printing.show_ruler_p = true;
dc.m_source_printing.max_width = 50;
- pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
- pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:"));
+ pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
+ pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:"));
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("TEST PREFIX: 1 2 3 4 5\n"
"TEST PREFIX: 12345678901234567890123456789012345678901234567890\n"
"TEST PREFIX: foo = bar.field;\n"
"TEST PREFIX: ^~~~~~\n"
"TEST PREFIX: ------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of adding a prefix, with ruler and line numbers. */
dc.m_source_printing.show_ruler_p = true;
dc.m_source_printing.max_width = 50;
dc.m_source_printing.show_line_numbers_p = true;
- pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
- pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:"));
+ pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE;
+ pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:"));
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ ("TEST PREFIX: | 1 2 3 4 5\n"
"TEST PREFIX: | 12345678901234567890123456789012345678901234567890\n"
"TEST PREFIX: 1 | foo = bar.field;\n"
"TEST PREFIX: | ^~~~~~\n"
"TEST PREFIX: | ------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~~~\n"
" m_field\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace fix-it hint: replacing "field" with "m_field",
" ^\n"
" -----\n"
" m_field\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace fix-it hint: replacing "field" with "m_field",
ASSERT_STREQ (" foo = bar.field;\n"
" ^ ~~~~~\n"
" m_field\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that we can use ad-hoc locations when adding fixits to a
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~~~~~~~~ \n"
" test\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Remove. */
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~~~~~~~~ \n"
" -----------------------------------------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace. */
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~~~~~~~~ \n"
" test\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
ASSERT_STREQ (" foo = bar.field;\n"
" ^\n"
" aaaaaaaaaaaaaaaaaaa\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Ensure that we can add an arbitrary number of fix-it hints to a
ASSERT_STREQ (" foo = bar.field;\n"
" ^\n"
" a a a a a a a a a a a a a a a a a a a\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of labeling the ranges within a rich_location. */
" ^~~ ~~~ ~~~~~\n"
" | | |\n"
" 0 1 2\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that we can disable label-printing. */
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~ ~~~ ~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" | | label 2\n"
" | label 1\n"
" label 0\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of boundary conditions: label 0 and 1 have just enough clearance,
" | | |\n"
" | | c\n"
" aaaaa bbbb\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of out-of-order ranges (thus requiring a sort). */
" ~~~ ~~~ ^~~~~\n"
" | | |\n"
" 2 1 0\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Ensure we don't ICE if multiple ranges with labels are on
" label 0\n"
" label 1\n"
" label 2\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of out-of-order ranges (thus requiring a sort), where
" label 2a\n"
" label 2b\n"
" label 2c\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that a NULL result from range_label::get_text is
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar.field;\n"
" ^~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* TODO: example of formatted printing (needs to be in
"_field\xcf\x80"
";\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Caret and range. */
"_field\xcf\x80"
";\n"
" ~~~~~^~~~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Multiple ranges and carets. */
"_field\xcf\x80"
";\n"
" ~~~~A~ ~~~B~ ~~~~~C~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Insertion fix-it hint: adding an "&" to the front of "P_bar.field". */
";\n"
" ^\n"
" &\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Insertion fix-it hint: adding a "[0]" after "SS_foo". */
";\n"
" ^~~~~~\n"
" [0]\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Removal fix-it hint: removal of the ".SS_fieldP". */
";\n"
" ^~~~~~~~~~\n"
" ----------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP". */
" ^~~~~~~~~\n"
" m_\xf0\x9f\x98\x82"
"_field\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP",
" ---------\n"
" m_\xf0\x9f\x98\x82"
"_field\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP",
" ^ ~~~~~~~~~\n"
" m_\xf0\x9f\x98\x82"
"_field\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Verify that we can use ad-hoc locations when adding fixits to a
";\n"
" ^~~~~~~~~~~~~~~~ \n"
" test\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Remove. */
";\n"
" ^~~~~~~~~~~~~~~~ \n"
" -------------------------------------\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Replace. */
";\n"
" ^~~~~~~~~~~~~~~~ \n"
" test\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" ^\n"
" \xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@"
"\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Ensure that we can add an arbitrary number of fix-it hints to a
" ^\n"
" \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @"
" \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of labeling the ranges within a rich_location. */
" \xf0\x9f\x98\x82\xf0\x9f\x98\x82\xcf\x80"
" \xf0\x9f\x98\x82\xcf\x80\xf0\x9f\x98\x82"
"\xf0\x9f\x98\x82\xcf\x80\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" | | label 2\xcf\x80\n"
" | label 1\xcf\x80\n"
" label 0\xf0\x9f\x98\x82\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of boundary conditions: label 0 and 1 have just enough clearance,
" | | c\n"
" aaaaa\xf0\x9f\x98\x82\xcf\x80"
" bb\xf0\x9f\x98\x82\xf0\x9f\x98\x82\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of escaping the source lines. */
" label 0\xf0\x9f\x98\x82"
/* ... */ " label 1\xcf\x80"
/* ...................*/ " label 2\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
" label 0\xf0\x9f\x98\x82"
/* ... */ " label 1\xcf\x80"
/* ..........................*/ " label 2\xcf\x80\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
}
/* In order to avoid having the test depend on exactly how the colorization
was effected, just confirm there are two pi characters in the output. */
- const char *result = pp_formatted_text (dc.printer);
+ const char *result = pp_formatted_text (dc.m_printer);
const char *null_term = result + strlen (result);
const char *first_pi = strstr (result, "\xcf\x80");
ASSERT_TRUE (first_pi && first_pi <= null_term - 2);
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" struct same_line { double x; double y; ;\n"
" ~ ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Test of add_location_if_nearby on a different line to the
ASSERT_STREQ (" struct point origin = {x: 0.0,\n"
" ^\n"
" .=\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* The multiline case. The caret for the rich_location is on line 6;
" : 0.0};\n"
" ^\n"
" =\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* As above, but verify the behavior of multiple line spans
" 6 | : 0.0};\n"
" | ^\n"
" | =\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" ^~~~~~~~~~\n"
" -----------------\n"
" const_cast<foo *> (ptr->field)\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
/* Unit-test the line_corrections machinery. */
char_display_policy policy (make_policy (dc, richloc));
" -\n"
" CAST (-\n"
" ) ( )\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example where none are consolidated during printing. */
" -\n"
" CST ( -\n"
" ) ( )\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of deletion fix-it hints. */
" ^~~~~~~~~~\n"
" -------\n"
" (bar *)\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of deletion fix-it hints that would overlap. */
" ^~~~~~~~~~\n"
" -----------------\n"
" (longer *)(foo *)\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of insertion fix-it hints that would overlap. */
" ^~~~~~~~~~\n"
" -------\n"
" LONGER THAN THE CAST(foo *)TEST\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" const_cast<f\xf0\x9f\x98\x82"
" *> (ptr->field\xcf\x80"
")\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
/* Unit-test the line_corrections machinery. */
char_display_policy policy (make_policy (dc, richloc));
" -\n"
" CAST (-\n"
" ) ( )\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example where none are consolidated during printing. */
" -\n"
" CST ( -\n"
" ) ( )\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of deletion fix-it hints. */
" -------\n"
" (bar\xf0\x9f\x98\x82"
" *)\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of deletion fix-it hints that would overlap. */
" (long\xf0\x9f\x98\x82"
" *)(f\xf0\x9f\x98\x82"
" *)\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Example of insertion fix-it hints that would overlap. */
" L\xf0\x9f\x98\x82"
"NGER THAN THE CAST(f\xf0\x9f\x98\x82"
" *)TEST\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
ASSERT_STREQ (" int a5[][0][0] = { 1, 2 };\n"
" ^\n"
" } {\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Various overlapping insertions, some occurring "out of order"
" ^\n"
" { -----\n"
" {{1}}}}, {{{2 }}\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
"+ break;\n"
" case 'b':\n"
" ^~~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* With line numbers. */
" +++ |+ break;\n"
" 3 | case 'b':\n"
" | ^~~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" case 'b':\n"
" ^~~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
"FILENAME:3:2:\n"
" putchar (ch);\n"
" ^~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* With line-numbering, the line spans are close enough to be
" 2 | {\n"
" 3 | putchar (ch);\n"
" | ^~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" foo = bar ();\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Fix-it hint, attempting to delete a newline.
" ~^\n"
" );\n"
" ~ \n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
static void
test_layout.print_line (1);
ASSERT_STREQ (" This: ` ' is a tab.\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Confirm the display width was tracked correctly across the internal tab
test_layout.print_line (1);
ASSERT_STREQ (" This: ` ' is a tab.\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" before \1\2\3\v\x80\xff""after\n"
" ^ ~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
richloc.set_escape_on_output (true);
{
ASSERT_STREQ
(" before<U+0000><U+0001><U+0002><U+0003><U+000B><80><ff>after\n"
" ^~~~~~~~ ~~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" before<00><01><02><03><0b><80><ff>after\n"
" ^~~~ ~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" after\n"
" ^\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
richloc.set_escape_on_output (true);
{
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" <U+0000>after\n"
" ^~~~~~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
{
test_diagnostic_context dc;
diagnostic_show_locus (&dc, &richloc, DK_ERROR);
ASSERT_STREQ (" <00>after\n"
" ^~~~\n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
}
" | ~~~~~^~~~~~~~~~\n"
"11 | this is line 11\n"
" | ~~~~ \n",
- pp_formatted_text (dc.printer));
+ pp_formatted_text (dc.m_printer));
}
/* Run all of the selftests within this file. */
char *
file_name_as_prefix (diagnostic_context *context, const char *f)
{
+ pretty_printer *const pp = context->m_printer;
const char *locus_cs
- = colorize_start (pp_show_color (context->printer), "locus");
- const char *locus_ce = colorize_stop (pp_show_color (context->printer));
+ = colorize_start (pp_show_color (pp), "locus");
+ const char *locus_ce = colorize_stop (pp_show_color (pp));
return build_message_string ("%s%s:%s ", locus_cs, f, locus_ce);
}
{
/* One minus to account for the leading empty space. */
value = value ? value - 1
- : (isatty (fileno (pp_buffer (context->printer)->m_stream))
+ : (isatty (fileno (pp_buffer (context->m_printer)->m_stream))
? get_terminal_width () - 1: INT_MAX);
if (value <= 0)
{
/* Allocate a basic pretty-printer. Clients will replace this a
much more elaborated pretty-printer if they wish. */
- this->printer = XNEW (pretty_printer);
- new (this->printer) pretty_printer ();
+ m_printer = XNEW (pretty_printer);
+ new (m_printer) pretty_printer ();
m_file_cache = new file_cache ();
memset (m_diagnostic_count, 0, sizeof m_diagnostic_count);
m_n_opts = n_opts;
m_option_classifier.init (n_opts);
m_source_printing.enabled = false;
- diagnostic_set_caret_max_width (this, pp_line_cutoff (this->printer));
+ diagnostic_set_caret_max_width (this, pp_line_cutoff (m_printer));
for (int i = 0; i < rich_location::STATICALLY_ALLOCATED_RANGES; i++)
m_source_printing.caret_chars[i] = '^';
m_show_cwe = false;
else
value = DIAGNOSTICS_COLOR_DEFAULT;
}
- pp_show_color (this->printer)
+ pp_show_color (m_printer)
= colorize_init ((diagnostic_color_rule_t) value);
}
value = DIAGNOSTICS_URLS_DEFAULT;
}
- this->printer->set_url_format
+ m_printer->set_url_format
(determine_url_format ((diagnostic_url_rule_t) value));
}
/* diagnostic_context::initialize allocates this->printer using XNEW
and placement-new. */
- this->printer->~pretty_printer ();
- XDELETE (this->printer);
- this->printer = nullptr;
+ m_printer->~pretty_printer ();
+ XDELETE (m_printer);
+ m_printer = nullptr;
if (m_edit_context_ptr)
{
label_text
diagnostic_context::get_location_text (const expanded_location &s) const
{
- pretty_printer *pp = this->printer;
+ pretty_printer *pp = m_printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
const char *file = s.file ? s.file : progname;
const char *text = _(diagnostic_kind_text[diagnostic->kind]);
const char *text_cs = "", *text_ce = "";
- pretty_printer *pp = context->printer;
+ pretty_printer *pp = context->m_printer;
if (diagnostic_kind_color[diagnostic->kind])
{
void
diagnostic_context::report_current_module (location_t where)
{
+ pretty_printer *pp = m_printer;
const line_map_ordinary *map = NULL;
- if (pp_needs_newline (this->printer))
+ if (pp_needs_newline (m_printer))
{
- pp_newline (this->printer);
- pp_needs_newline (this->printer) = false;
+ pp_newline (pp);
+ pp_needs_newline (pp) = false;
}
if (where <= BUILTINS_LOCATION)
unsigned index = (was_module ? 6 : is_module ? 4
: need_inc ? 2 : 0) + !first;
- pp_verbatim (this->printer, "%s%s %r%s%s%R",
+ pp_verbatim (pp, "%s%s %r%s%s%R",
first ? "" : was_module ? ", " : ",\n",
_(msgs[index]),
"locus", s.file, line_col);
first = false, need_inc = was_module, was_module = is_module;
}
while (!includes_seen_p (map));
- pp_verbatim (this->printer, ":");
- pp_newline (this->printer);
+ pp_verbatim (pp, ":");
+ pp_newline (pp);
}
}
}
const diagnostic_info *diagnostic)
{
diagnostic_report_current_module (context, diagnostic_location (diagnostic));
- pp_set_prefix (context->printer, diagnostic_build_prefix (context,
- diagnostic));
+ pretty_printer *const pp = context->m_printer;
+ pp_set_prefix (pp, diagnostic_build_prefix (context, diagnostic));
}
void
expanded_location exploc)
{
label_text text = context->get_location_text (exploc);
- pp_string (context->printer, text.get ());
- pp_newline (context->printer);
+ pretty_printer *pp = context->m_printer;
+ pp_string (pp, text.get ());
+ pp_newline (pp);
}
void
const diagnostic_info *diagnostic,
diagnostic_t)
{
- char *saved_prefix = pp_take_prefix (context->printer);
- pp_set_prefix (context->printer, NULL);
- pp_newline (context->printer);
- diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
- pp_set_prefix (context->printer, saved_prefix);
- pp_flush (context->printer);
+ pretty_printer *const pp = context->m_printer;
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp, NULL);
+ pp_newline (pp);
+ diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind, pp);
+ pp_set_prefix (pp, saved_prefix);
+ pp_flush (pp);
}
/* Interface to specify diagnostic kind overrides. Returns the
through. Don't do this more than once. */
if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
&& m_lock == 1)
- pp_newline_and_flush (this->printer);
+ pp_newline_and_flush (m_printer);
else
error_recursion ();
}
m_output_format->on_begin_group ();
m_diagnostic_groups.m_emission_count++;
- pp_format (this->printer, &diagnostic->message);
+ pp_format (m_printer, &diagnostic->message);
/* Call vfunc in the output format. This is responsible for
phase 3 of formatting, and for printing the result. */
m_output_format->on_report_diagnostic (*diagnostic, orig_diag_kind);
break;
case EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1:
print_parseable_fixits (get_file_cache (),
- this->printer, diagnostic->richloc,
+ m_printer, diagnostic->richloc,
DIAGNOSTICS_COLUMN_UNIT_BYTE,
m_tabstop);
- pp_flush (this->printer);
+ pp_flush (m_printer);
break;
case EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2:
print_parseable_fixits (get_file_cache (),
- this->printer, diagnostic->richloc,
+ m_printer, diagnostic->richloc,
DIAGNOSTICS_COLUMN_UNIT_DISPLAY,
m_tabstop);
- pp_flush (this->printer);
+ pp_flush (m_printer);
break;
}
diagnostic_action_after_output (this, diagnostic->kind);
va_end (ap);
return;
}
- char *saved_prefix = pp_take_prefix (context->printer);
- pp_set_prefix (context->printer,
+ pretty_printer *pp = context->m_printer;
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp,
diagnostic_build_prefix (context, &diagnostic));
- pp_format (context->printer, &diagnostic.message);
- pp_output_formatted_text (context->printer);
- pp_destroy_prefix (context->printer);
- pp_set_prefix (context->printer, saved_prefix);
- pp_newline (context->printer);
- diagnostic_show_locus (context, &richloc, DK_NOTE);
+ pp_format (pp, &diagnostic.message);
+ pp_output_formatted_text (pp);
+ pp_destroy_prefix (pp);
+ pp_set_prefix (pp, saved_prefix);
+ pp_newline (pp);
+ diagnostic_show_locus (context, &richloc, DK_NOTE, pp);
va_end (ap);
}
diagnostic_context::error_recursion ()
{
if (m_lock < 3)
- pp_newline_and_flush (this->printer);
+ pp_newline_and_flush (m_printer);
fnotice (stderr,
"internal compiler error: error reporting routines re-entered.\n");
initialized yet, or might be in use by another thread).
Handle such cases as gracefully as possible by falling back to a
minimal abort handler that only relies on i18n. */
- if (global_dc->printer == NULL)
+ if (global_dc->m_printer == nullptr)
{
/* Print the error message. */
fnotice (stderr, diagnostic_kind_text[DK_ICE]);
void set_show_rules (bool val) { m_show_rules = val; }
void set_show_highlight_colors (bool val)
{
- pp_show_highlight_colors (printer) = val;
+ pp_show_highlight_colors (m_printer) = val;
}
void set_path_format (enum diagnostic_path_format val)
{
void print_path (const diagnostic_path &path);
/* Data members.
- Ideally, all of these would be private and have "m_" prefixes. */
+ Ideally, all of these would be private. */
public:
/* Where most of the diagnostic formatting work is done. */
- pretty_printer *printer;
+ pretty_printer *m_printer;
private:
/* Cache of source code. */
#define diagnostic_info_auxiliary_data(DI) (DI)->x_data
/* Same as pp_format_decoder. Works on 'diagnostic_context *'. */
-#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->printer)
+#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->m_printer)
/* Same as pp_prefixing_rule. Works on 'diagnostic_context *'. */
-#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->printer)
+#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->m_printer)
/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
inline void
inline bool
diagnostic_ready_p ()
{
- return global_dc->printer != nullptr;
+ return global_dc->m_printer != nullptr;
}
/* The number of errors that have been issued so far. Ideally, these
static void
gfc_clear_pp_buffer (output_buffer *this_buffer)
{
- pretty_printer *pp = global_dc->printer;
+ pretty_printer *pp = global_dc->m_printer;
output_buffer *tmp_buffer = pp_buffer (pp);
pp_buffer (pp) = this_buffer;
pp_clear_output_area (pp);
diagnostic_info diagnostic;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
bool fatal_errors = global_dc->m_fatal_errors;
- pretty_printer *pp = global_dc->printer;
+ pretty_printer *pp = global_dc->m_printer;
output_buffer *tmp_buffer = pp_buffer (pp);
gfc_clear_pp_buffer (pp_warning_buffer);
gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
const char *text = _(diagnostic_kind_text[diagnostic->kind]);
const char *text_cs = "", *text_ce = "";
- pretty_printer *pp = context->printer;
+ pretty_printer *const pp = context->m_printer;
if (diagnostic_kind_color[diagnostic->kind])
{
gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
expanded_location s)
{
- pretty_printer *pp = context->printer;
+ pretty_printer *const pp = context->m_printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
return (s.file == NULL
gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
expanded_location s, expanded_location s2)
{
- pretty_printer *pp = context->printer;
+ pretty_printer *const pp = context->m_printer;
const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
const char *locus_ce = colorize_stop (pp_show_color (pp));
gfc_diagnostic_starter (diagnostic_context *context,
const diagnostic_info *diagnostic)
{
+ pretty_printer *const pp = context->m_printer;
char * kind_prefix = gfc_diagnostic_build_kind_prefix (context, diagnostic);
expanded_location s1 = diagnostic_expand_location (diagnostic);
|| diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
|| diagnostic_location (diagnostic, 0) == context->m_last_location)
{
- pp_set_prefix (context->printer,
+ pp_set_prefix (pp,
concat (locus_prefix, " ", kind_prefix, NULL));
free (locus_prefix);
[locus]:[prefix]: (1)
and we flush with a new line before setting the new prefix. */
- pp_string (context->printer, "(1)");
- pp_newline (context->printer);
+ pp_string (pp, "(1)");
+ pp_newline (pp);
locus_prefix = gfc_diagnostic_build_locus_prefix (context, s2);
- pp_set_prefix (context->printer,
+ pp_set_prefix (pp,
concat (locus_prefix, " ", kind_prefix, NULL));
free (kind_prefix);
free (locus_prefix);
}
else
{
- pp_verbatim (context->printer, "%s", locus_prefix);
+ pp_verbatim (pp, "%s", locus_prefix);
free (locus_prefix);
/* Fortran uses an empty line between locus and caret line. */
- pp_newline (context->printer);
- pp_set_prefix (context->printer, NULL);
- pp_newline (context->printer);
- diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
+ pp_newline (pp);
+ pp_set_prefix (pp, NULL);
+ pp_newline (pp);
+ diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind,
+ pp);
/* If the caret line was shown, the prefix does not contain the
locus. */
- pp_set_prefix (context->printer, kind_prefix);
+ pp_set_prefix (pp, kind_prefix);
}
}
{
char *locus_prefix;
locus_prefix = gfc_diagnostic_build_locus_prefix (context, exploc);
- pp_verbatim (context->printer, "%s", locus_prefix);
+ pretty_printer * const pp = context->m_printer;
+ pp_verbatim (pp, "%s", locus_prefix);
free (locus_prefix);
- pp_newline (context->printer);
+ pp_newline (pp);
/* Fortran uses an empty line between locus and caret line. */
- pp_newline (context->printer);
+ pp_newline (pp);
}
const diagnostic_info *diagnostic ATTRIBUTE_UNUSED,
diagnostic_t orig_diag_kind ATTRIBUTE_UNUSED)
{
- pp_destroy_prefix (context->printer);
- pp_newline_and_flush (context->printer);
+ pretty_printer *const pp = context->m_printer;
+ pp_destroy_prefix (pp);
+ pp_newline_and_flush (pp);
}
/* Immediate warning (i.e. do not buffer the warning) with an explicit
{
if (! gfc_output_buffer_empty_p (pp_warning_buffer))
{
- pretty_printer *pp = global_dc->printer;
+ pretty_printer *pp = global_dc->m_printer;
output_buffer *tmp_buffer = pp_buffer (pp);
pp_buffer (pp) = pp_warning_buffer;
pp_really_flush (pp);
diagnostic_info diagnostic;
rich_location richloc (line_table, UNKNOWN_LOCATION);
bool fatal_errors = global_dc->m_fatal_errors;
- pretty_printer *pp = global_dc->printer;
+ pretty_printer *pp = global_dc->m_printer;
output_buffer *tmp_buffer = pp_buffer (pp);
gfc_clear_pp_buffer (pp_error_buffer);
|| ! gfc_output_buffer_empty_p (pp_error_buffer))
{
error_buffer.flag = false;
- pretty_printer *pp = global_dc->printer;
+ pretty_printer *pp = global_dc->m_printer;
output_buffer *tmp_buffer = pp_buffer (pp);
pp_buffer (pp) = pp_error_buffer;
pp_really_flush (pp);
/* Print a note with the valid memory models. */
pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
for (unsigned i = 0; valid[i] != UCHAR_MAX; ++i)
{
const char *modname = memory_models[valid[i]].modname;
{
/* At this point the text has been formatted into the pretty-printer's
output buffer. */
- pretty_printer *pp = diag_context->printer;
+ pretty_printer *pp = diag_context->m_printer;
const char *text = pp_formatted_text (pp);
/* Get location information (if any) from the diagnostic.
{
if (diagnostic_last_function_changed (context, diagnostic))
{
- char *old_prefix = pp_take_prefix (context->printer);
+ pretty_printer *const pp = context->m_printer;
+ char *old_prefix = pp_take_prefix (pp);
tree abstract_origin = diagnostic_abstract_origin (diagnostic);
char *new_prefix = (file && abstract_origin == NULL)
? file_name_as_prefix (context, file) : NULL;
- pp_set_prefix (context->printer, new_prefix);
+ pp_set_prefix (pp, new_prefix);
if (current_function_decl == NULL)
- pp_printf (context->printer, _("At top level:"));
+ pp_printf (pp, _("At top level:"));
else
{
tree fndecl, ao;
if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
pp_printf
- (context->printer, _("In member function %qs"),
+ (pp, _("In member function %qs"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
else
pp_printf
- (context->printer, _("In function %qs"),
+ (pp, _("In function %qs"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
while (abstract_origin)
if (fndecl)
{
expanded_location s = expand_location (*locus);
- pp_comma (context->printer);
- pp_newline (context->printer);
+ pp_comma (pp);
+ pp_newline (pp);
if (s.file != NULL)
{
if (context->m_show_column)
- pp_printf (context->printer,
+ pp_printf (pp,
_(" inlined from %qs at %r%s:%d:%d%R"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
"locus", s.file, s.line, s.column);
else
- pp_printf (context->printer,
+ pp_printf (pp,
_(" inlined from %qs at %r%s:%d%R"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
"locus", s.file, s.line);
}
else
- pp_printf (context->printer, _(" inlined from %qs"),
+ pp_printf (pp, _(" inlined from %qs"),
identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
}
}
- pp_colon (context->printer);
+ pp_colon (pp);
}
diagnostic_set_last_function (context, diagnostic);
- pp_newline_and_flush (context->printer);
- context->printer->set_prefix (old_prefix);
+ pp_newline_and_flush (pp);
+ pp->set_prefix (old_prefix);
}
}
void
print_lto_docs_link ()
{
- bool print_url = global_dc->printer->supports_urls_p ();
+ bool print_url = global_dc->m_printer->supports_urls_p ();
const char *url = global_dc->make_option_url (OPT_flto);
pretty_printer pp;
initial_lang_mask = lang_hooks.option_lang_mask ();
const bool show_highlight_colors
- = pp_show_highlight_colors (global_dc->printer);
+ = pp_show_highlight_colors (global_dc->m_printer);
lang_hooks.initialize_diagnostics (global_dc);
/* ??? Ideally, we should do this earlier and the FEs will override
break;
case OPT_fmessage_length_:
- pp_set_line_maximum_length (dc->printer, value);
+ pp_set_line_maximum_length (dc->m_printer, value);
diagnostic_set_caret_max_width (dc, value);
break;
{
/* In a few places we use the global dc's printer to determine
colorization so ensure this off during the tests. */
- const bool saved_show_color = pp_show_color (global_dc->printer);
- pp_show_color (global_dc->printer) = false;
+ pretty_printer *global_pp = global_dc->m_printer;
+ const bool saved_show_color = pp_show_color (global_pp);
+ pp_show_color (global_pp) = false;
auto_fix_quotes fix_quotes;
std::unique_ptr<pretty_printer> event_pp
- = std::unique_ptr<pretty_printer> (global_dc->printer->clone ());
+ = std::unique_ptr<pretty_printer> (global_pp->clone ());
test_intraprocedural_path (event_pp.get ());
- pp_show_color (global_dc->printer) = saved_show_color;
+ pp_show_color (global_pp) = saved_show_color;
}
} // namespace selftest
region_model_manager *mgr = model->get_manager ();
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (stderr);
for (const auto ®ion_refcnt : region_to_refcnt)
test_diagnostic_starter (diagnostic_context *context,
const diagnostic_info *diagnostic)
{
- pp_set_prefix (context->printer, xstrdup ("PREFIX: "));
+ pp_set_prefix (context->m_printer, xstrdup ("PREFIX: "));
}
/* Custom diagnostic callback, to avoid having the path in the
test_diagnostic_start_span_fn (diagnostic_context *context,
expanded_location exploc)
{
- pp_string (context->printer, "START_SPAN_FN: ");
- pp_newline (context->printer);
+ pp_string (context->m_printer, "START_SPAN_FN: ");
+ pp_newline (context->m_printer);
}
/* Custom output format subclass. */
void on_begin_group () final override
{
/* Loudly announce a new diagnostic group. */
- pp_string (m_context.printer,
+ pp_string (m_context.m_printer,
"================================= BEGIN GROUP ==============================");
- pp_newline (m_context.printer);
+ pp_newline (m_context.m_printer);
}
void on_end_group () final override
{
/* Loudly announce the end of a diagnostic group. */
- pp_set_prefix (m_context.printer, NULL);
- pp_string (m_context.printer,
+ pp_set_prefix (m_context.m_printer, NULL);
+ pp_string (m_context.m_printer,
"---------------------------------- END GROUP -------------------------------");
- pp_newline_and_flush (m_context.printer);
+ pp_newline_and_flush (m_context.m_printer);
}
};
{
auto_diagnostic_group d;
gcc_rich_location richloc (gimple_location (call_to_PyList_Append));
- simple_diagnostic_path path (global_dc->printer);
+ simple_diagnostic_path path (global_dc->m_printer);
diagnostic_event_id_t alloc_event_id
= path.add_event (gimple_location (call_to_PyList_New),
example_a_fun->decl, 0,
auto_diagnostic_group d;
gcc_rich_location richloc (call_to_free.m_loc);
- test_diagnostic_path path (global_dc->printer);
+ test_diagnostic_path path (global_dc->m_printer);
path.add_entry (entry_to_test, 0, "test");
path.add_call (call_to_make_boxed_int, 0,
entry_to_make_boxed_int, "make_boxed_int");
auto_diagnostic_group d;
gcc_rich_location richloc (call_to_fprintf.m_loc);
- test_diagnostic_path path (global_dc->printer);
+ test_diagnostic_path path (global_dc->m_printer);
path.add_entry (entry_to_test, 1, "test");
path.add_call (call_to_register_handler, 1,
entry_to_register_handler, "register_handler");
auto_diagnostic_group d;
gcc_rich_location richloc (call_to_acquire_lock_a_in_bar.m_loc);
- test_diagnostic_path path (global_dc->printer);
+ test_diagnostic_path path (global_dc->m_printer);
diagnostic_thread_id_t thread_1 = path.add_thread ("Thread 1");
diagnostic_thread_id_t thread_2 = path.add_thread ("Thread 2");
path.add_entry (entry_to_foo, 0, "foo", thread_1);
const diagnostic_info *diagnostic,
diagnostic_t)
{
- bool old_show_color = pp_show_color (context->printer);
+ pretty_printer *const pp = context->m_printer;
+ bool old_show_color = pp_show_color (pp);
if (force_show_locus_color)
- pp_show_color (context->printer) = true;
- char *saved_prefix = pp_take_prefix (context->printer);
- pp_set_prefix (context->printer, NULL);
- pp_newline (context->printer);
+ pp_show_color (pp) = true;
+ char *saved_prefix = pp_take_prefix (pp);
+ pp_set_prefix (pp, NULL);
+ pp_newline (pp);
diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
- pp_show_color (context->printer) = old_show_color;
- pp_set_prefix (context->printer, saved_prefix);
- pp_flush (context->printer);
+ pp_show_color (pp) = old_show_color;
+ pp_set_prefix (pp, saved_prefix);
+ pp_flush (pp);
}
/* Add a location to RICHLOC with caret==start at START, ranging to FINISH. */
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
if (outf == stderr)
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
pp.set_output_stream (outf);
text_art::theme *theme = global_dc->get_diagram_theme ();
fprintf (stderr, " %s",
identifier_to_locale (lang_hooks.decl_printable_name (decl, 2)));
fflush (stderr);
- pp_needs_newline (global_dc->printer) = true;
+ pp_needs_newline (global_dc->m_printer) = true;
diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
}
}
if (auto edit_context_ptr = global_dc->get_edit_context ())
{
pretty_printer pp;
- pp_show_color (&pp) = pp_show_color (global_dc->printer);
+ pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
edit_context_ptr->print_diff (&pp, true);
pp_flush (&pp);
}
default_tree_diagnostic_starter (diagnostic_context *context,
const diagnostic_info *diagnostic)
{
+ pretty_printer *pp = context->m_printer;
diagnostic_report_current_function (context, diagnostic);
- pp_set_prefix (context->printer, diagnostic_build_prefix (context,
- diagnostic));
+ pp_set_prefix (pp, diagnostic_build_prefix (context, diagnostic));
}
/* Default tree printer. Handles declarations only. */
continue;
}
- if (c != '\n' || !pp_is_wrapping_line (global_dc->printer))
+ if (c != '\n' || !pp_is_wrapping_line (global_dc->m_printer))
{
if (escaped == NULL)
{
ASSERT_STREQ ("foobar", (const char *) msg);
/* Ensure that we have -fmessage-length set to 0. */
- saved_cutoff = pp_line_cutoff (global_dc->printer);
- pp_line_cutoff (global_dc->printer) = 0;
+ pretty_printer *pp = global_dc->m_printer;
+ saved_cutoff = pp_line_cutoff (pp);
+ pp_line_cutoff (pp) = 0;
msg.escape ("foo\nbar");
ASSERT_STREQ ("foo\\nbar", (const char *) msg);
ASSERT_STREQ ("\\a\\b\\f\\n\\r\\t\\v", (const char *) msg);
/* Now repeat the tests with -fmessage-length set to 5. */
- pp_line_cutoff (global_dc->printer) = 5;
+ pp_line_cutoff (pp) = 5;
/* Note that the newline is not translated into an escape. */
msg.escape ("foo\nbar");
ASSERT_STREQ ("\\a\\b\\f\n\\r\\t\\v", (const char *) msg);
/* Restore the original message length setting. */
- pp_line_cutoff (global_dc->printer) = saved_cutoff;
+ pp_line_cutoff (pp) = saved_cutoff;
}
/* Run all of the selftests within this file. */