Commit da6ca2b5 by Gabriel Dos Reis Committed by Gabriel Dos Reis

pretty-print.h (output_buffer::output_buffer): Declare.

	* pretty-print.h (output_buffer::output_buffer): Declare.
	(pretty_printer::pretty_printer): Likewise.
	(pp_construct): Remove.
	* pretty-print.c (output_buffer::output_buffer): Define.
	(pretty_printer::pretty_printer): Rename from pp_construct.  Simplify.
	* gimple-pretty-print.c (print_gimple_stmt): Do not call pp_construct.
	(print_gimple_expr): Likewise.
	(print_gimple_seq): Likewise.
	(gimple_dump_bb): Likewise.
	* sched-vis.c (dump_value_slim): Likewise.
	(dump_insn_slim): Likewise.
	(dump_rtl_slim): Likewise.
	(str_pattern_slim): Likewise.
	* tree-mudflap.c (mf_varname_tree): Likewise.
	* graph.c (print_graph_cfg): Likewise.
	(start_graph_dump): Likewise.
	* tree-pretty-print.c (maybe_init_pretty_print): Likewise.  Use
	placement-new.
	* diagnostic.c (diagnostic_initialize): Simplify early diagnostic
	pretty printer initialization.
	* coretypes.h (diagnostic_context): Remove superflous type alias
	declaration.
	(pretty_printer): Likewise.  Declare directly as a class.
	(pretty_print_info): Remove declaration as class.
	* asan.c (asan_emit_stack_protection): Remove call to pp_construct
	and pp_clear_output_area.
	(asan_add_global): Likewise.

c/
	* c-objc-common.c (c_initialize_diagnostics): Simplify C pretty
	printer initialization.

c-family/
	* c-pretty-print.h (pp_c_pretty_printer_init): Remove.
	(c_pretty_printer::c_pretty_printer): Declare.
	* c-pretty-print.c (pretty_printer::c_pretty_printer): Rename from
	c_pretty_printer_init.  Adjust.
	(print_c_tree): Do not call c_pretty_printer_init.
	* c-ada-spec.c (dump_ads): Remove call to pp_construct.

cp/
	* error.c (init_error): Remove calls to pp_construct and
	pp_cxx_pretty_printer_init.  Initialize cxx_pp with placement-new.
	* cxx-pretty-print.h (cxx_pretty_printer::cxx_pretty_printer): Declare.
	(cxx_pretty_printer_init): Remove.
	* cxx-pretty-print.c (cxx_pretty_printer::cxx_pretty_printer):
	Rename from cxx_pretty_printer_init.  Adjust.
	* cp-objcp-common.c (cxx_initialize_diagnostics): Simplify
	initialization of C++ diagnostics pretty printer.

From-SVN: r201918
parent 0e1474e5
2013-08-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* pretty-print.h (output_buffer::output_buffer): Declare.
(pretty_printer::pretty_printer): Likewise.
(pp_construct): Remove.
* pretty-print.c (output_buffer::output_buffer): Define.
(pretty_printer::pretty_printer): Rename from pp_construct. Simplify.
* gimple-pretty-print.c (print_gimple_stmt): Do not call pp_construct.
(print_gimple_expr): Likewise.
(print_gimple_seq): Likewise.
(gimple_dump_bb): Likewise.
* sched-vis.c (dump_value_slim): Likewise.
(dump_insn_slim): Likewise.
(dump_rtl_slim): Likewise.
(str_pattern_slim): Likewise.
* tree-mudflap.c (mf_varname_tree): Likewise.
* graph.c (print_graph_cfg): Likewise.
(start_graph_dump): Likewise.
* tree-pretty-print.c (maybe_init_pretty_print): Likewise. Use
placement-new.
* diagnostic.c (diagnostic_initialize): Simplify early diagnostic
pretty printer initialization.
* coretypes.h (diagnostic_context): Remove superflous type alias
declaration.
(pretty_printer): Likewise. Declare directly as a class.
(pretty_print_info): Remove declaration as class.
* asan.c (asan_emit_stack_protection): Remove call to pp_construct
and pp_clear_output_area.
(asan_add_global): Likewise.
2013-08-22 Jan Hubicka <jh@suse.cz> 2013-08-22 Jan Hubicka <jh@suse.cz>
* cgraphunit.c (analyze_functions) Use update_type_inheritance_graph. * cgraphunit.c (analyze_functions) Use update_type_inheritance_graph.
......
...@@ -938,9 +938,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls, ...@@ -938,9 +938,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls,
/* First of all, prepare the description string. */ /* First of all, prepare the description string. */
pretty_printer asan_pp; pretty_printer asan_pp;
pp_construct (&asan_pp, /* prefix */NULL, /* line-width */0);
pp_clear_output_area (&asan_pp);
if (DECL_NAME (current_function_decl)) if (DECL_NAME (current_function_decl))
pp_tree_identifier (&asan_pp, DECL_NAME (current_function_decl)); pp_tree_identifier (&asan_pp, DECL_NAME (current_function_decl));
else else
...@@ -1963,9 +1961,7 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v) ...@@ -1963,9 +1961,7 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
vec<constructor_elt, va_gc> *vinner = NULL; vec<constructor_elt, va_gc> *vinner = NULL;
pretty_printer asan_pp; pretty_printer asan_pp;
pp_construct (&asan_pp, /* prefix */NULL, /* line-width */0);
pp_clear_output_area (&asan_pp);
if (DECL_NAME (decl)) if (DECL_NAME (decl))
pp_tree_identifier (&asan_pp, DECL_NAME (decl)); pp_tree_identifier (&asan_pp, DECL_NAME (decl));
else else
......
2013-08-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-pretty-print.h (pp_c_pretty_printer_init): Remove.
(c_pretty_printer::c_pretty_printer): Declare.
* c-pretty-print.c (pretty_printer::c_pretty_printer): Rename from
c_pretty_printer_init. Adjust.
(print_c_tree): Do not call c_pretty_printer_init.
* c-ada-spec.c (dump_ads): Remove call to pp_construct.
2013-08-09 Arnaud Charlet <charlet@adacore.com> 2013-08-09 Arnaud Charlet <charlet@adacore.com>
* c-ada-spec.c (print_ada_declaration): Prevent accessing null asm name * c-ada-spec.c (print_ada_declaration): Prevent accessing null asm name
......
...@@ -3304,7 +3304,6 @@ dump_ads (const char *source_file, ...@@ -3304,7 +3304,6 @@ dump_ads (const char *source_file,
{ {
pretty_printer pp; pretty_printer pp;
pp_construct (&pp, NULL, 0);
pp_needs_newline (&pp) = true; pp_needs_newline (&pp) = true;
pp.buffer->stream = f; pp.buffer->stream = f;
......
...@@ -2318,39 +2318,37 @@ pp_c_statement (c_pretty_printer *pp, tree stmt) ...@@ -2318,39 +2318,37 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
/* Initialize the PRETTY-PRINTER for handling C codes. */ /* Initialize the PRETTY-PRINTER for handling C codes. */
void c_pretty_printer::c_pretty_printer ()
pp_c_pretty_printer_init (c_pretty_printer *pp) : pretty_printer ()
{ {
pp->offset_list = 0; offset_list = 0;
flags = 0;
pp->flags = 0; declaration = pp_c_declaration;
declaration_specifiers = pp_c_declaration_specifiers;
pp->declaration = pp_c_declaration; declarator = pp_c_declarator;
pp->declaration_specifiers = pp_c_declaration_specifiers; direct_declarator = pp_c_direct_declarator;
pp->declarator = pp_c_declarator; type_specifier_seq = pp_c_specifier_qualifier_list;
pp->direct_declarator = pp_c_direct_declarator; abstract_declarator = pp_c_abstract_declarator;
pp->type_specifier_seq = pp_c_specifier_qualifier_list; direct_abstract_declarator = pp_c_direct_abstract_declarator;
pp->abstract_declarator = pp_c_abstract_declarator; ptr_operator = pp_c_pointer;
pp->direct_abstract_declarator = pp_c_direct_abstract_declarator; parameter_list = pp_c_parameter_type_list;
pp->ptr_operator = pp_c_pointer; type_id = pp_c_type_id;
pp->parameter_list = pp_c_parameter_type_list; simple_type_specifier = pp_c_type_specifier;
pp->type_id = pp_c_type_id; function_specifier = pp_c_function_specifier;
pp->simple_type_specifier = pp_c_type_specifier; storage_class_specifier = pp_c_storage_class_specifier;
pp->function_specifier = pp_c_function_specifier;
pp->storage_class_specifier = pp_c_storage_class_specifier; statement = pp_c_statement;
pp->statement = pp_c_statement; constant = pp_c_constant;
id_expression = pp_c_id_expression;
pp->constant = pp_c_constant; primary_expression = pp_c_primary_expression;
pp->id_expression = pp_c_id_expression; postfix_expression = pp_c_postfix_expression;
pp->primary_expression = pp_c_primary_expression; unary_expression = pp_c_unary_expression;
pp->postfix_expression = pp_c_postfix_expression; initializer = pp_c_initializer;
pp->unary_expression = pp_c_unary_expression; multiplicative_expression = pp_c_multiplicative_expression;
pp->initializer = pp_c_initializer; conditional_expression = pp_c_conditional_expression;
pp->multiplicative_expression = pp_c_multiplicative_expression; assignment_expression = pp_c_assignment_expression;
pp->conditional_expression = pp_c_conditional_expression; expression = pp_c_expression;
pp->assignment_expression = pp_c_assignment_expression;
pp->expression = pp_c_expression;
} }
...@@ -2360,8 +2358,7 @@ void ...@@ -2360,8 +2358,7 @@ void
print_c_tree (FILE *file, tree t) print_c_tree (FILE *file, tree t)
{ {
c_pretty_printer pp; c_pretty_printer pp;
pp_construct (&pp, NULL, 0);
pp_c_pretty_printer_init (&pp);
pp_needs_newline (&pp) = true; pp_needs_newline (&pp) = true;
pp.buffer->stream = file; pp.buffer->stream = file;
pp_statement (&pp, t); pp_statement (&pp, t);
......
...@@ -49,6 +49,8 @@ typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree); ...@@ -49,6 +49,8 @@ typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree);
and cp/cxx-pretty-print.c for an example of derivation. */ and cp/cxx-pretty-print.c for an example of derivation. */
struct c_pretty_printer : pretty_printer struct c_pretty_printer : pretty_printer
{ {
c_pretty_printer ();
/* Points to the first element of an array of offset-list. /* Points to the first element of an array of offset-list.
Not used yet. */ Not used yet. */
int *offset_list; int *offset_list;
...@@ -120,7 +122,6 @@ struct c_pretty_printer : pretty_printer ...@@ -120,7 +122,6 @@ struct c_pretty_printer : pretty_printer
#define pp_expression(PP, E) (PP)->expression (PP, E) #define pp_expression(PP, E) (PP)->expression (PP, E)
extern void pp_c_pretty_printer_init (c_pretty_printer *);
void pp_c_whitespace (c_pretty_printer *); void pp_c_whitespace (c_pretty_printer *);
void pp_c_left_paren (c_pretty_printer *); void pp_c_left_paren (c_pretty_printer *);
void pp_c_right_paren (c_pretty_printer *); void pp_c_right_paren (c_pretty_printer *);
......
2013-08-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-objc-common.c (c_initialize_diagnostics): Simplify C pretty
printer initialization.
2013-08-19 Balaji V. Iyer <balaji.v.iyer@intel.com> 2013-08-19 Balaji V. Iyer <balaji.v.iyer@intel.com>
PR c/57490 PR c/57490
* c-array-notation.c (fix_conditional_array_notations_1): Added a * c-array-notation.c (fix_conditional_array_notations_1): Added a
check for truth values. check for truth values.
......
...@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h" #include "langhooks.h"
#include "c-objc-common.h" #include "c-objc-common.h"
#include <new> // For placement new.
static bool c_tree_printer (pretty_printer *, text_info *, const char *, static bool c_tree_printer (pretty_printer *, text_info *, const char *,
int, bool, bool, bool); int, bool, bool, bool);
...@@ -183,16 +185,11 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED) ...@@ -183,16 +185,11 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED)
void void
c_initialize_diagnostics (diagnostic_context *context) c_initialize_diagnostics (diagnostic_context *context)
{ {
pretty_printer *base;
c_pretty_printer *pp;
c_common_initialize_diagnostics (context); c_common_initialize_diagnostics (context);
base = context->printer; pretty_printer *base = context->printer;
pp = XNEW (c_pretty_printer); c_pretty_printer *pp = XNEW (c_pretty_printer);
memcpy (pp, base, sizeof (pretty_printer)); context->printer = new (pp) c_pretty_printer ();
pp_c_pretty_printer_init (pp);
context->printer = (pretty_printer *) pp;
/* It is safe to free this object because it was previously XNEW()'d. */ /* It is safe to free this object because it was previously XNEW()'d. */
XDELETE (base); XDELETE (base);
......
...@@ -73,9 +73,7 @@ struct cl_option; ...@@ -73,9 +73,7 @@ struct cl_option;
struct cl_decoded_option; struct cl_decoded_option;
struct cl_option_handlers; struct cl_option_handlers;
struct diagnostic_context; struct diagnostic_context;
typedef struct diagnostic_context diagnostic_context; struct pretty_printer;
struct pretty_print_info;
typedef struct pretty_print_info pretty_printer;
/* Address space number for named address space support. */ /* Address space number for named address space support. */
typedef unsigned char addr_space_t; typedef unsigned char addr_space_t;
......
2013-08-22 Gabriel Dos Reis <gdr@integrable-solutions.net>
* error.c (init_error): Remove calls to pp_construct and
pp_cxx_pretty_printer_init. Initialize cxx_pp with placement-new.
* cxx-pretty-print.h (cxx_pretty_printer::cxx_pretty_printer): Declare.
(cxx_pretty_printer_init): Remove.
* cxx-pretty-print.c (cxx_pretty_printer::cxx_pretty_printer):
Rename from cxx_pretty_printer_init. Adjust.
* cp-objcp-common.c (cxx_initialize_diagnostics): Simplify
initialization of C++ diagnostics pretty printer.
2013-08-21 Paolo Carlini <paolo.carlini@oracle.com> 2013-08-21 Paolo Carlini <paolo.carlini@oracle.com>
* call.c (build_new_method_call_1): Use INDIRECT_REF_P. * call.c (build_new_method_call_1): Use INDIRECT_REF_P.
......
...@@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -32,6 +32,8 @@ along with GCC; see the file COPYING3. If not see
#include "cxx-pretty-print.h" #include "cxx-pretty-print.h"
#include "cp-objcp-common.h" #include "cp-objcp-common.h"
#include <new> // For placement new.
/* Special routine to get the alias set for C++. */ /* Special routine to get the alias set for C++. */
alias_set_type alias_set_type
...@@ -131,19 +133,14 @@ cp_var_mod_type_p (tree type, tree fn) ...@@ -131,19 +133,14 @@ cp_var_mod_type_p (tree type, tree fn)
void void
cxx_initialize_diagnostics (diagnostic_context *context) cxx_initialize_diagnostics (diagnostic_context *context)
{ {
pretty_printer *base;
cxx_pretty_printer *pp;
c_common_initialize_diagnostics (context); c_common_initialize_diagnostics (context);
base = context->printer; pretty_printer *base = context->printer;
pp = XNEW (cxx_pretty_printer); cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
memcpy (pp, base, sizeof (pretty_printer)); context->printer = new (pp) cxx_pretty_printer ();
pp_cxx_pretty_printer_init (pp);
context->printer = (pretty_printer *) pp;
/* It is safe to free this object because it was previously malloc()'d. */ /* It is safe to free this object because it was previously XNEW()'d. */
free (base); XDELETE (base);
} }
/* This compares two types for equivalence ("compatible" in C-based languages). /* This compares two types for equivalence ("compatible" in C-based languages).
......
...@@ -2432,34 +2432,33 @@ typedef c_pretty_print_fn pp_fun; ...@@ -2432,34 +2432,33 @@ typedef c_pretty_print_fn pp_fun;
/* Initialization of a C++ pretty-printer object. */ /* Initialization of a C++ pretty-printer object. */
void cxx_pretty_printer::cxx_pretty_printer ()
pp_cxx_pretty_printer_init (cxx_pretty_printer *pp) : c_pretty_printer (),
enclosing_scope (global_namespace)
{ {
pp_c_pretty_printer_init (pp); pp_set_line_maximum_length (this, 0);
pp_set_line_maximum_length (pp, 0);
declaration = (pp_fun) pp_cxx_declaration;
pp->declaration = (pp_fun) pp_cxx_declaration; declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq;
pp->declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq; function_specifier = (pp_fun) pp_cxx_function_specifier;
pp->function_specifier = (pp_fun) pp_cxx_function_specifier; type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq;
pp->type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; declarator = (pp_fun) pp_cxx_declarator;
pp->declarator = (pp_fun) pp_cxx_declarator; direct_declarator = (pp_fun) pp_cxx_direct_declarator;
pp->direct_declarator = (pp_fun) pp_cxx_direct_declarator; parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause;
pp->parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; type_id = (pp_fun) pp_cxx_type_id;
pp->type_id = (pp_fun) pp_cxx_type_id; abstract_declarator = (pp_fun) pp_cxx_abstract_declarator;
pp->abstract_declarator = (pp_fun) pp_cxx_abstract_declarator; direct_abstract_declarator = (pp_fun) pp_cxx_direct_abstract_declarator;
pp->direct_abstract_declarator = (pp_fun) pp_cxx_direct_abstract_declarator; simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier;
pp->simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier;
/* pp->statement = (pp_fun) pp_cxx_statement; */ /* pp->statement = (pp_fun) pp_cxx_statement; */
pp->constant = (pp_fun) pp_cxx_constant; constant = (pp_fun) pp_cxx_constant;
pp->id_expression = (pp_fun) pp_cxx_id_expression; id_expression = (pp_fun) pp_cxx_id_expression;
pp->primary_expression = (pp_fun) pp_cxx_primary_expression; primary_expression = (pp_fun) pp_cxx_primary_expression;
pp->postfix_expression = (pp_fun) pp_cxx_postfix_expression; postfix_expression = (pp_fun) pp_cxx_postfix_expression;
pp->unary_expression = (pp_fun) pp_cxx_unary_expression; unary_expression = (pp_fun) pp_cxx_unary_expression;
pp->multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression; multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression;
pp->conditional_expression = (pp_fun) pp_cxx_conditional_expression; conditional_expression = (pp_fun) pp_cxx_conditional_expression;
pp->assignment_expression = (pp_fun) pp_cxx_assignment_expression; assignment_expression = (pp_fun) pp_cxx_assignment_expression;
pp->expression = (pp_fun) pp_cxx_expression; expression = (pp_fun) pp_cxx_expression;
pp->enclosing_scope = global_namespace;
} }
...@@ -31,6 +31,7 @@ enum cxx_pretty_printer_flags ...@@ -31,6 +31,7 @@ enum cxx_pretty_printer_flags
struct cxx_pretty_printer : c_pretty_printer struct cxx_pretty_printer : c_pretty_printer
{ {
cxx_pretty_printer ();
/* This is the enclosing scope of the entity being pretty-printed. */ /* This is the enclosing scope of the entity being pretty-printed. */
tree enclosing_scope; tree enclosing_scope;
}; };
...@@ -59,7 +60,6 @@ struct cxx_pretty_printer : c_pretty_printer ...@@ -59,7 +60,6 @@ struct cxx_pretty_printer : c_pretty_printer
#define pp_cxx_tree_identifier(PP, T) \ #define pp_cxx_tree_identifier(PP, T) \
pp_c_tree_identifier (PP, T) pp_c_tree_identifier (PP, T)
void pp_cxx_pretty_printer_init (cxx_pretty_printer *);
void pp_cxx_begin_template_argument_list (cxx_pretty_printer *); void pp_cxx_begin_template_argument_list (cxx_pretty_printer *);
void pp_cxx_end_template_argument_list (cxx_pretty_printer *); void pp_cxx_end_template_argument_list (cxx_pretty_printer *);
void pp_cxx_colon_colon (cxx_pretty_printer *); void pp_cxx_colon_colon (cxx_pretty_printer *);
......
...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see
#include "pointer-set.h" #include "pointer-set.h"
#include "c-family/c-objc.h" #include "c-family/c-objc.h"
#include <new> // For placement-new.
#define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',') #define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';') #define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
...@@ -109,8 +111,7 @@ init_error (void) ...@@ -109,8 +111,7 @@ init_error (void)
diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer; diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer;
diagnostic_format_decoder (global_dc) = cp_printer; diagnostic_format_decoder (global_dc) = cp_printer;
pp_construct (cxx_pp, NULL, 0); new (cxx_pp) cxx_pretty_printer ();
pp_cxx_pretty_printer_init (cxx_pp);
} }
/* Dump a scope, if deemed necessary. */ /* Dump a scope, if deemed necessary. */
......
...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h" #include "diagnostic.h"
#include "diagnostic-color.h" #include "diagnostic-color.h"
#include <new> // For placement new.
#define pedantic_warning_kind(DC) \ #define pedantic_warning_kind(DC) \
((DC)->pedantic_errors ? DK_ERROR : DK_WARNING) ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
#define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR) #define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
...@@ -120,11 +122,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts) ...@@ -120,11 +122,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
/* Allocate a basic pretty-printer. Clients will replace this a /* Allocate a basic pretty-printer. Clients will replace this a
much more elaborated pretty-printer if they wish. */ much more elaborated pretty-printer if they wish. */
context->printer = XNEW (pretty_printer); context->printer = XNEW (pretty_printer);
pp_construct (context->printer, NULL, 0); new (context->printer) pretty_printer ();
/* By default, diagnostics are sent to stderr. */
context->printer->buffer->stream = stderr;
/* By default, we emit prefixes once per message. */
context->printer->wrapping.rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;
memset (context->diagnostic_count, 0, sizeof context->diagnostic_count); memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
context->some_warnings_are_errors = false; context->some_warnings_are_errors = false;
......
...@@ -75,7 +75,6 @@ void ...@@ -75,7 +75,6 @@ void
print_gimple_stmt (FILE *file, gimple g, int spc, int flags) print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
{ {
pretty_printer buffer; pretty_printer buffer;
pp_construct (&buffer, NULL, 0);
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file; buffer.buffer->stream = file;
pp_gimple_stmt_1 (&buffer, g, spc, flags); pp_gimple_stmt_1 (&buffer, g, spc, flags);
...@@ -107,7 +106,6 @@ print_gimple_expr (FILE *file, gimple g, int spc, int flags) ...@@ -107,7 +106,6 @@ print_gimple_expr (FILE *file, gimple g, int spc, int flags)
{ {
flags |= TDF_RHS_ONLY; flags |= TDF_RHS_ONLY;
pretty_printer buffer; pretty_printer buffer;
pp_construct (&buffer, NULL, 0);
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file; buffer.buffer->stream = file;
pp_gimple_stmt_1 (&buffer, g, spc, flags); pp_gimple_stmt_1 (&buffer, g, spc, flags);
...@@ -143,7 +141,6 @@ void ...@@ -143,7 +141,6 @@ void
print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags) print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
{ {
pretty_printer buffer; pretty_printer buffer;
pp_construct (&buffer, NULL, 0);
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file; buffer.buffer->stream = file;
dump_gimple_seq (&buffer, seq, spc, flags); dump_gimple_seq (&buffer, seq, spc, flags);
...@@ -2270,7 +2267,6 @@ gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags) ...@@ -2270,7 +2267,6 @@ gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
if (bb->index >= NUM_FIXED_BLOCKS) if (bb->index >= NUM_FIXED_BLOCKS)
{ {
pretty_printer buffer; pretty_printer buffer;
pp_construct (&buffer, NULL, 0);
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
buffer.buffer->stream = file; buffer.buffer->stream = file;
gimple_dump_bb_buff (&buffer, bb, indent, flags); gimple_dump_bb_buff (&buffer, bb, indent, flags);
......
...@@ -278,7 +278,6 @@ print_graph_cfg (const char *base, struct function *fun) ...@@ -278,7 +278,6 @@ print_graph_cfg (const char *base, struct function *fun)
const char *funcname = function_name (fun); const char *funcname = function_name (fun);
FILE *fp = open_graph_file (base, "a"); FILE *fp = open_graph_file (base, "a");
pretty_printer graph_slim_pp; pretty_printer graph_slim_pp;
pp_construct (&graph_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
graph_slim_pp.buffer->stream = fp; graph_slim_pp.buffer->stream = fp;
pretty_printer *const pp = &graph_slim_pp; pretty_printer *const pp = &graph_slim_pp;
pp_printf (pp, "subgraph \"%s\" {\n" pp_printf (pp, "subgraph \"%s\" {\n"
...@@ -297,7 +296,6 @@ static void ...@@ -297,7 +296,6 @@ static void
start_graph_dump (FILE *fp, const char *base) start_graph_dump (FILE *fp, const char *base)
{ {
pretty_printer graph_slim_pp; pretty_printer graph_slim_pp;
pp_construct (&graph_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
graph_slim_pp.buffer->stream = fp; graph_slim_pp.buffer->stream = fp;
pretty_printer *const pp = &graph_slim_pp; pretty_printer *const pp = &graph_slim_pp;
pp_string (pp, "digraph \""); pp_string (pp, "digraph \"");
......
...@@ -25,10 +25,27 @@ along with GCC; see the file COPYING3. If not see ...@@ -25,10 +25,27 @@ along with GCC; see the file COPYING3. If not see
#include "pretty-print.h" #include "pretty-print.h"
#include "diagnostic-color.h" #include "diagnostic-color.h"
#include <new> // For placement-new.
#if HAVE_ICONV #if HAVE_ICONV
#include <iconv.h> #include <iconv.h>
#endif #endif
// Default construct an output buffer.
output_buffer::output_buffer ()
: formatted_obstack (),
chunk_obstack (),
obstack (&formatted_obstack),
cur_chunk_array (),
stream (stderr),
line_length (),
digit_buffer ()
{
obstack_init (&formatted_obstack);
obstack_init (&chunk_obstack);
}
/* A pointer to the formatted diagnostic message. */ /* A pointer to the formatted diagnostic message. */
#define pp_formatted_text_data(PP) \ #define pp_formatted_text_data(PP) \
((const char *) obstack_base ((PP)->buffer->obstack)) ((const char *) obstack_base ((PP)->buffer->obstack))
...@@ -736,19 +753,24 @@ pp_emit_prefix (pretty_printer *pp) ...@@ -736,19 +753,24 @@ pp_emit_prefix (pretty_printer *pp)
/* Construct a PRETTY-PRINTER with PREFIX and of MAXIMUM_LENGTH /* Construct a PRETTY-PRINTER with PREFIX and of MAXIMUM_LENGTH
characters per line. */ characters per line. */
void
pp_construct (pretty_printer *pp, const char *prefix, int maximum_length) pretty_printer::pretty_printer (const char *p, int l)
: buffer (new (XCNEW (output_buffer)) output_buffer ()),
prefix (),
padding (pp_none),
maximum_length (),
indent_skip (),
wrapping (),
format_decoder (),
emitted_prefix (),
need_newline (),
translate_identifiers(true),
show_color ()
{ {
memset (pp, 0, sizeof (pretty_printer)); pp_line_cutoff (this) = l;
pp->buffer = XCNEW (output_buffer); /* By default, we emit prefixes once per message. */
obstack_init (&pp->buffer->chunk_obstack); pp_prefixing_rule (this) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
obstack_init (&pp->buffer->formatted_obstack); pp_set_prefix (this, p);
pp->buffer->obstack = &pp->buffer->formatted_obstack;
pp->buffer->stream = stderr;
pp_line_cutoff (pp) = maximum_length;
pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
pp_set_prefix (pp, prefix);
pp_translate_identifiers (pp) = true;
} }
/* Append a string delimited by START and END to the output area of /* Append a string delimited by START and END to the output area of
......
...@@ -73,6 +73,8 @@ struct chunk_info ...@@ -73,6 +73,8 @@ struct chunk_info
whose fields should not be accessed directly by clients. */ whose fields should not be accessed directly by clients. */
struct output_buffer struct output_buffer
{ {
output_buffer ();
/* Obstack where the text is built up. */ /* Obstack where the text is built up. */
struct obstack formatted_obstack; struct obstack formatted_obstack;
...@@ -157,8 +159,12 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, ...@@ -157,8 +159,12 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
/* The data structure that contains the bare minimum required to do /* The data structure that contains the bare minimum required to do
proper pretty-printing. Clients may derived from this structure proper pretty-printing. Clients may derived from this structure
and add additional fields they need. */ and add additional fields they need. */
struct pretty_print_info struct pretty_printer
{ {
// Default construct a pretty printer with specified prefix
// and a maximum line length cut off limit.
explicit pretty_printer (const char* = NULL, int = 0);
/* Where we print external representation of ENTITY. */ /* Where we print external representation of ENTITY. */
output_buffer *buffer; output_buffer *buffer;
...@@ -283,7 +289,6 @@ pp_get_prefix (const pretty_printer *pp) { return pp->prefix; } ...@@ -283,7 +289,6 @@ pp_get_prefix (const pretty_printer *pp) { return pp->prefix; }
#define pp_buffer(PP) (PP)->buffer #define pp_buffer(PP) (PP)->buffer
extern void pp_construct (pretty_printer *, const char *, int);
extern void pp_set_line_maximum_length (pretty_printer *, int); extern void pp_set_line_maximum_length (pretty_printer *, int);
extern void pp_set_prefix (pretty_printer *, const char *); extern void pp_set_prefix (pretty_printer *, const char *);
extern void pp_destroy_prefix (pretty_printer *); extern void pp_destroy_prefix (pretty_printer *);
......
...@@ -766,7 +766,6 @@ void ...@@ -766,7 +766,6 @@ void
dump_value_slim (FILE *f, const_rtx x, int verbose) dump_value_slim (FILE *f, const_rtx x, int verbose)
{ {
pretty_printer rtl_slim_pp; pretty_printer rtl_slim_pp;
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
rtl_slim_pp.buffer->stream = f; rtl_slim_pp.buffer->stream = f;
print_value (&rtl_slim_pp, x, verbose); print_value (&rtl_slim_pp, x, verbose);
pp_flush (&rtl_slim_pp); pp_flush (&rtl_slim_pp);
...@@ -778,7 +777,6 @@ void ...@@ -778,7 +777,6 @@ void
dump_insn_slim (FILE *f, const_rtx x) dump_insn_slim (FILE *f, const_rtx x)
{ {
pretty_printer rtl_slim_pp; pretty_printer rtl_slim_pp;
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
rtl_slim_pp.buffer->stream = f; rtl_slim_pp.buffer->stream = f;
print_insn_with_notes (&rtl_slim_pp, x); print_insn_with_notes (&rtl_slim_pp, x);
pp_flush (&rtl_slim_pp); pp_flush (&rtl_slim_pp);
...@@ -793,7 +791,6 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last, ...@@ -793,7 +791,6 @@ dump_rtl_slim (FILE *f, const_rtx first, const_rtx last,
{ {
const_rtx insn, tail; const_rtx insn, tail;
pretty_printer rtl_slim_pp; pretty_printer rtl_slim_pp;
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
rtl_slim_pp.buffer->stream = f; rtl_slim_pp.buffer->stream = f;
tail = last ? NEXT_INSN (last) : NULL_RTX; tail = last ? NEXT_INSN (last) : NULL_RTX;
...@@ -842,7 +839,6 @@ const char * ...@@ -842,7 +839,6 @@ const char *
str_pattern_slim (const_rtx x) str_pattern_slim (const_rtx x)
{ {
pretty_printer rtl_slim_pp; pretty_printer rtl_slim_pp;
pp_construct (&rtl_slim_pp, /*prefix=*/NULL, /*linewidth=*/0);
print_pattern (&rtl_slim_pp, x, 0); print_pattern (&rtl_slim_pp, x, 0);
return ggc_strdup (pp_formatted_text (&rtl_slim_pp)); return ggc_strdup (pp_formatted_text (&rtl_slim_pp));
} }
......
...@@ -112,8 +112,6 @@ mf_varname_tree (tree decl) ...@@ -112,8 +112,6 @@ mf_varname_tree (tree decl)
gcc_assert (decl); gcc_assert (decl);
pretty_printer buf; pretty_printer buf;
pp_construct (&buf, /* prefix */ NULL, /* line-width */ 0);
pp_clear_output_area (&buf);
/* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */ /* Add FILENAME[:LINENUMBER[:COLUMNNUMBER]]. */
{ {
......
...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,8 @@ along with GCC; see the file COPYING3. If not see
#include "value-prof.h" #include "value-prof.h"
#include "predict.h" #include "predict.h"
#include <new> // For placement-new.
/* Local functions, macros and variables. */ /* Local functions, macros and variables. */
static const char *op_symbol (const_tree); static const char *op_symbol (const_tree);
static void pretty_print_string (pretty_printer *, const char*); static void pretty_print_string (pretty_printer *, const char*);
...@@ -3059,7 +3061,7 @@ maybe_init_pretty_print (FILE *file) ...@@ -3059,7 +3061,7 @@ maybe_init_pretty_print (FILE *file)
{ {
if (!initialized) if (!initialized)
{ {
pp_construct (&buffer, /* prefix */NULL, /* line-width */0); new (&buffer) pretty_printer ();
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
pp_translate_identifiers (&buffer) = false; pp_translate_identifiers (&buffer) = false;
initialized = 1; initialized = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment