No functional change intended.
gcc/ada/ChangeLog:
* gcc-interface/misc.cc: Use text_info ctor.
gcc/analyzer/ChangeLog:
* analyzer-logging.cc (logger::log_va_partial): Use text_info
ctor.
* analyzer.cc (make_label_text): Likewise.
(make_label_text_n): Likewise.
* pending-diagnostic.cc (evdesc::event_desc::formatted_print):
Likewise.
gcc/c/ChangeLog:
* c-objc-common.cc (c_tree_printer): Update for "m_" prefixes to
text_info fields.
gcc/cp/ChangeLog:
* error.cc: Update for "m_" prefixes to text_info fields.
gcc/d/ChangeLog:
* d-diagnostic.cc (d_diagnostic_report_diagnostic): Use text_info
ctor.
gcc/ChangeLog:
* diagnostic.cc (diagnostic_set_info_translated): Update for "m_"
prefixes to text_info fields.
(diagnostic_report_diagnostic): Likewise.
(verbatim): Use text_info ctor.
(simple_diagnostic_path::add_event): Likewise.
(simple_diagnostic_path::add_thread_event): Likewise.
* dumpfile.cc (dump_pretty_printer::decode_format): Update for
"m_" prefixes to text_info fields.
(dump_context::dump_printf_va): Use text_info ctor.
* graphviz.cc (graphviz_out::graphviz_out): Use text_info ctor.
(graphviz_out::print): Likewise.
* opt-problem.cc (opt_problem::opt_problem): Likewise.
* pretty-print.cc (pp_format): Update for "m_" prefixes to
text_info fields.
(pp_printf): Use text_info ctor.
(pp_verbatim): Likewise.
(assert_pp_format_va): Likewise.
* pretty-print.h (struct text_info): Add ctors. Add "m_" prefix
to all fields.
* text-art/styled-string.cc (styled_string::from_fmt_va): Use
text_info ctor.
* tree-diagnostic.cc (default_tree_printer): Update for "m_"
prefixes to text_info fields.
* tree-pretty-print.h (pp_ti_abstract_origin): Likewise.
gcc/fortran/ChangeLog:
* error.cc (gfc_format_decoder): Update for "m_" prefixes to
text_info fields.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
internal_error_function (diagnostic_context *context, const char *msgid,
va_list *ap)
{
- text_info tinfo;
char *buffer, *p, *loc;
String_Template temp, temp_loc;
String_Pointer sp, sp_loc;
pp_clear_output_area (context->printer);
/* Format the message into the pretty-printer. */
- tinfo.format_spec = msgid;
- tinfo.args_ptr = ap;
- tinfo.err_no = errno;
+ text_info tinfo (msgid, ap, errno);
pp_format_verbatim (context->printer, &tinfo);
/* Extract a (writable) pointer to the formatted text. */
void
logger::log_va_partial (const char *fmt, va_list *ap)
{
- text_info text;
- text.format_spec = fmt;
- text.args_ptr = ap;
- text.err_no = 0;
+ text_info text (fmt, ap, 0);
pp_format (m_pp, &text);
pp_output_formatted_text (m_pp);
}
if (!can_colorize)
pp_show_color (pp) = false;
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_list ap;
va_start (ap, fmt);
- ti.format_spec = _(fmt);
- ti.args_ptr = ≈
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
-
+ text_info ti (_(fmt), &ap, 0, NULL, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
if (!can_colorize)
pp_show_color (pp) = false;
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_list ap;
const char *fmt = ngettext (singular_fmt, plural_fmt, n);
- ti.format_spec = fmt;
- ti.args_ptr = ≈
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
+ text_info ti (fmt, &ap, 0, NULL, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
pp_show_color (pp) = m_colorize;
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_list ap;
va_start (ap, fmt);
- ti.format_spec = _(fmt);
- ti.args_ptr = ≈
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
+ text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
va_end (ap);
if (*spec != 'v')
{
- t = va_arg (*text->args_ptr, tree);
+ t = va_arg (*text->m_args_ptr, tree);
if (set_locus)
text->set_location (0, DECL_SOURCE_LOCATION (t),
SHOW_RANGE_WITH_CARET);
return true;
case 'v':
- pp_c_cv_qualifiers (cpp, va_arg (*text->args_ptr, int), hash);
+ pp_c_cv_qualifiers (cpp, va_arg (*text->m_args_ptr, int), hash);
return true;
default:
const char *result;
tree t = NULL;
-#define next_tree (t = va_arg (*text->args_ptr, tree))
-#define next_tcode ((enum tree_code) va_arg (*text->args_ptr, int))
-#define next_lang ((enum languages) va_arg (*text->args_ptr, int))
-#define next_int va_arg (*text->args_ptr, int)
+#define next_tree (t = va_arg (*text->m_args_ptr, tree))
+#define next_tcode ((enum tree_code) va_arg (*text->m_args_ptr, int))
+#define next_lang ((enum languages) va_arg (*text->m_args_ptr, int))
+#define next_int va_arg (*text->m_args_ptr, int)
if (precision != 0 || wide)
return false;
else
{
/* Write verbatim messages with no location direct to stream. */
- text_info text;
- text.err_no = errno;
- text.args_ptr = &argp;
- text.format_spec = expand_d_format (format);
- text.x_data = NULL;
+ text_info text (expand_d_format (format), &argp, errno, nullptr);
pp_format_verbatim (global_dc->printer, &text);
pp_newline_and_flush (global_dc->printer);
diagnostic_t kind)
{
gcc_assert (richloc);
- diagnostic->message.err_no = errno;
- diagnostic->message.args_ptr = args;
- diagnostic->message.format_spec = msg;
+ diagnostic->message.m_err_no = errno;
+ diagnostic->message.m_args_ptr = args;
+ diagnostic->message.m_format_spec = msg;
diagnostic->message.m_richloc = richloc;
diagnostic->richloc = richloc;
diagnostic->metadata = NULL;
&& diagnostic->kind == DK_WARNING)
diagnostic->kind = DK_ERROR;
- diagnostic->message.x_data = &diagnostic->x_data;
+ diagnostic->message.m_data = &diagnostic->x_data;
/* Check to see if the diagnostic is enabled at the location and
not disabled by #pragma GCC diagnostic anywhere along the inlining
}
if (context->internal_error)
(*context->internal_error) (context,
- diagnostic->message.format_spec,
- diagnostic->message.args_ptr);
+ diagnostic->message.m_format_spec,
+ diagnostic->message.m_args_ptr);
}
if (diagnostic->kind == DK_ERROR && orig_diag_kind == DK_WARNING)
++diagnostic_kind_count (context, DK_WERROR);
void
verbatim (const char *gmsgid, ...)
{
- text_info text;
va_list ap;
va_start (ap, gmsgid);
- text.err_no = errno;
- text.args_ptr = ≈
- text.format_spec = _(gmsgid);
- text.x_data = NULL;
+ text_info text (_(gmsgid), &ap, errno);
pp_format_verbatim (global_dc->printer, &text);
pp_newline_and_flush (global_dc->printer);
va_end (ap);
pretty_printer *pp = m_event_pp;
pp_clear_output_area (pp);
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_list ap;
va_start (ap, fmt);
- ti.format_spec = _(fmt);
- ti.args_ptr = ≈
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
-
+ text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
pretty_printer *pp = m_event_pp;
pp_clear_output_area (pp);
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
va_list ap;
va_start (ap, fmt);
- ti.format_spec = _(fmt);
- ti.args_ptr = ≈
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
+ text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc);
pp_format (pp, &ti);
pp_output_formatted_text (pp);
{
case 'C':
{
- cgraph_node *node = va_arg (*text->args_ptr, cgraph_node *);
+ cgraph_node *node = va_arg (*text->m_args_ptr, cgraph_node *);
/* Make an item for the node, and stash it. */
optinfo_item *item = make_item_for_dump_symtab_node (node);
case 'E':
{
- gimple *stmt = va_arg (*text->args_ptr, gimple *);
+ gimple *stmt = va_arg (*text->m_args_ptr, gimple *);
/* Make an item for the stmt, and stash it. */
optinfo_item *item = make_item_for_dump_gimple_expr (stmt, 0, TDF_SLIM);
case 'G':
{
- gimple *stmt = va_arg (*text->args_ptr, gimple *);
+ gimple *stmt = va_arg (*text->m_args_ptr, gimple *);
/* Make an item for the stmt, and stash it. */
optinfo_item *item = make_item_for_dump_gimple_stmt (stmt, 0, TDF_SLIM);
case 'T':
{
- tree t = va_arg (*text->args_ptr, tree);
+ tree t = va_arg (*text->m_args_ptr, tree);
/* Make an item for the tree, and stash it. */
optinfo_item *item = make_item_for_dump_generic_expr (t, TDF_SLIM);
{
dump_pretty_printer pp (this, metadata.get_dump_flags ());
- text_info text;
- text.err_no = errno;
- text.args_ptr = ap;
- text.format_spec = format;
+ text_info text (format, ap, errno);
/* Phases 1 and 2, using pp_format. */
pp_format (&pp, &text);
if (*spec == 'C')
loc = &gfc_current_locus;
else
- loc = va_arg (*text->args_ptr, locus *);
+ loc = va_arg (*text->m_args_ptr, locus *);
gcc_assert (loc->nextc - loc->lb->line >= 0);
unsigned int offset = loc->nextc - loc->lb->line;
if (*spec == 'C' && *loc->nextc != '\0')
void
graphviz_out::print (const char *fmt, ...)
{
- text_info text;
va_list ap;
va_start (ap, fmt);
- text.err_no = errno;
- text.args_ptr = ≈
- text.format_spec = fmt;
+ text_info text (fmt, &ap, errno);
pp_format (m_pp, &text);
pp_output_formatted_text (m_pp);
va_end (ap);
void
graphviz_out::println (const char *fmt, ...)
{
- text_info text;
va_list ap;
write_indent ();
va_start (ap, fmt);
- text.err_no = errno;
- text.args_ptr = ≈
- text.format_spec = fmt;
+ text_info text (fmt, &ap, errno);
pp_format (m_pp, &text);
pp_output_formatted_text (m_pp);
va_end (ap);
{
dump_pretty_printer pp (&dump_context::get (), MSG_MISSED_OPTIMIZATION);
- text_info text;
- text.err_no = errno;
- text.args_ptr = ap;
- text.format_spec = fmt; /* No i18n is performed. */
+ text_info text (fmt, /* No i18n is performed. */
+ ap, errno);
/* Phases 1 and 2, using pp_format. */
pp_format (&pp, &text);
A format string can have at most 30 arguments. */
/* Formatting phases 1 and 2: render TEXT->format_spec plus
- TEXT->args_ptr into a series of chunks in pp_buffer (PP)->args[].
+ text->m_args_ptr into a series of chunks in pp_buffer (PP)->args[].
Phase 3 is in pp_output_formatted_text. */
void
memset (formatters, 0, sizeof formatters);
- for (p = text->format_spec; *p; )
+ for (p = text->m_format_spec; *p; )
{
while (*p != '\0' && *p != '%')
{
case 'm':
{
- const char *errstr = xstrerror (text->err_no);
+ const char *errstr = xstrerror (text->m_err_no);
obstack_grow (&buffer->chunk_obstack, errstr, strlen (errstr));
}
p++;
{
case 'r':
pp_string (pp, colorize_start (pp_show_color (pp),
- va_arg (*text->args_ptr,
+ va_arg (*text->m_args_ptr,
const char *)));
break;
/* When quoting, print alphanumeric, punctuation, and the space
character unchanged, and all others in hexadecimal with the
"\x" prefix. Otherwise print them all unchanged. */
- int chr = va_arg (*text->args_ptr, int);
+ int chr = va_arg (*text->m_args_ptr, int);
if (ISPRINT (chr) || !quote)
pp_character (pp, chr);
else
case 'd':
case 'i':
if (wide)
- pp_wide_integer (pp, va_arg (*text->args_ptr, HOST_WIDE_INT));
+ pp_wide_integer (pp, va_arg (*text->m_args_ptr, HOST_WIDE_INT));
else
pp_integer_with_precision
- (pp, *text->args_ptr, precision, int, "d");
+ (pp, *text->m_args_ptr, precision, int, "d");
break;
case 'o':
if (wide)
pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o",
- va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
+ va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
- (pp, *text->args_ptr, precision, unsigned, "o");
+ (pp, *text->m_args_ptr, precision, unsigned, "o");
break;
case 's':
if (quote)
- pp_quoted_string (pp, va_arg (*text->args_ptr, const char *));
+ pp_quoted_string (pp, va_arg (*text->m_args_ptr, const char *));
else
- pp_string (pp, va_arg (*text->args_ptr, const char *));
+ pp_string (pp, va_arg (*text->m_args_ptr, const char *));
break;
case 'p':
- pp_pointer (pp, va_arg (*text->args_ptr, void *));
+ pp_pointer (pp, va_arg (*text->m_args_ptr, void *));
break;
case 'u':
if (wide)
pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED,
- va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
+ va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
- (pp, *text->args_ptr, precision, unsigned, "u");
+ (pp, *text->m_args_ptr, precision, unsigned, "u");
break;
case 'f':
- pp_double (pp, va_arg (*text->args_ptr, double));
+ pp_double (pp, va_arg (*text->m_args_ptr, double));
break;
case 'Z':
{
- int *v = va_arg (*text->args_ptr, int *);
- unsigned len = va_arg (*text->args_ptr, unsigned);
+ int *v = va_arg (*text->m_args_ptr, int *);
+ unsigned len = va_arg (*text->m_args_ptr, unsigned);
for (unsigned i = 0; i < len; ++i)
{
case 'x':
if (wide)
pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
- va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
+ va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
else
pp_integer_with_precision
- (pp, *text->args_ptr, precision, unsigned, "x");
+ (pp, *text->m_args_ptr, precision, unsigned, "x");
break;
case '.':
gcc_assert (*p == '*');
p++;
gcc_assert (*p == 's');
- n = va_arg (*text->args_ptr, int);
+ n = va_arg (*text->m_args_ptr, int);
/* This consumes a second entry in the formatters array. */
gcc_assert (formatters[argno] == formatters[argno+1]);
argno++;
}
- s = va_arg (*text->args_ptr, const char *);
+ s = va_arg (*text->m_args_ptr, const char *);
/* Append the lesser of precision and strlen (s) characters
from the array (which need not be a nul-terminated string).
{
/* diagnostic_event_id_t *. */
diagnostic_event_id_ptr event_id
- = va_arg (*text->args_ptr, diagnostic_event_id_ptr);
+ = va_arg (*text->m_args_ptr, diagnostic_event_id_ptr);
gcc_assert (event_id->known_p ());
pp_string (pp, colorize_start (pp_show_color (pp), "path"));
break;
case '{':
- pp_begin_url (pp, va_arg (*text->args_ptr, const char *));
+ pp_begin_url (pp, va_arg (*text->m_args_ptr, const char *));
break;
default:
void
pp_printf (pretty_printer *pp, const char *msg, ...)
{
- text_info text;
va_list ap;
va_start (ap, msg);
- text.err_no = errno;
- text.args_ptr = ≈
- text.format_spec = msg;
+ text_info text (msg, &ap, errno);
pp_format (pp, &text);
pp_output_formatted_text (pp);
va_end (ap);
void
pp_verbatim (pretty_printer *pp, const char *msg, ...)
{
- text_info text;
va_list ap;
va_start (ap, msg);
- text.err_no = errno;
- text.args_ptr = ≈
- text.format_spec = msg;
+ text_info text (msg, &ap, errno);
pp_format_verbatim (pp, &text);
va_end (ap);
}
bool show_color, const char *fmt, va_list *ap)
{
pretty_printer pp;
- text_info ti;
rich_location rich_loc (line_table, UNKNOWN_LOCATION);
- ti.format_spec = fmt;
- ti.args_ptr = ap;
- ti.err_no = 0;
- ti.x_data = NULL;
- ti.m_richloc = &rich_loc;
+ text_info ti (fmt, ap, 0, nullptr, &rich_loc);
pp_show_color (&pp) = show_color;
pp_format (&pp, &ti);
along with a list of things. */
struct text_info
{
- const char *format_spec;
- va_list *args_ptr;
- int err_no; /* for %m */
- void **x_data;
- rich_location *m_richloc;
+ text_info () = default;
+ text_info (const char *format_spec,
+ va_list *args_ptr,
+ int err_no,
+ void **data = nullptr,
+ rich_location *rich_loc = nullptr)
+ : m_format_spec (format_spec),
+ m_args_ptr (args_ptr),
+ m_err_no (err_no),
+ m_data (data),
+ m_richloc (rich_loc)
+ {
+ }
void set_location (unsigned int idx, location_t loc,
enum range_display_kind range_display_kind);
location_t get_location (unsigned int index_of_location) const;
+
+ const char *m_format_spec;
+ va_list *m_args_ptr;
+ int m_err_no; /* for %m */
+ void **m_data;
+ rich_location *m_richloc;
};
/* How often diagnostics are prefixed by their locations:
const char *fmt,
va_list *args)
{
- text_info text;
- text.err_no = errno;
- text.args_ptr = args;
- text.format_spec = fmt;
+ text_info text (fmt, args, errno);
pretty_printer pp;
pp_show_color (&pp) = true;
pp.url_format = URL_FORMAT_DEFAULT;
switch (*spec)
{
case 'E':
- t = va_arg (*text->args_ptr, tree);
+ t = va_arg (*text->m_args_ptr, tree);
if (TREE_CODE (t) == IDENTIFIER_NODE)
{
pp_identifier (pp, IDENTIFIER_POINTER (t));
break;
case 'D':
- t = va_arg (*text->args_ptr, tree);
+ t = va_arg (*text->m_args_ptr, tree);
if (VAR_P (t) && DECL_HAS_DEBUG_EXPR_P (t))
t = DECL_DEBUG_EXPR (t);
break;
case 'F':
case 'T':
- t = va_arg (*text->args_ptr, tree);
+ t = va_arg (*text->m_args_ptr, tree);
break;
default:
pp_verbatim (PP, "%qs not supported by %s", \
get_tree_code_name (TREE_CODE (T)), __FUNCTION__)
-#define pp_ti_abstract_origin(TI) ((tree *) (TI)->x_data)
+#define pp_ti_abstract_origin(TI) ((tree *) (TI)->m_data)
extern void debug_generic_expr (tree);