Commit b066401f by Gabriel Dos Reis Committed by Gabriel Dos Reis

pretty-print.h (pp_base): Remove.

	* pretty-print.h (pp_base): Remove.  Adjust dependent macros.
	* diagnostic.h (diagnostic_flush_buffer): Adjust.
	* pretty-print.c (pp_formatted_text_data): Likewise.
	(pp_indent): Rename from pp_base_indent.
	(pp_format): Rename from pp_base_format.
	(pp_output_formatted_text): Rename from pp_base_output_formatted_text.
	(pp_format_verbatim): Rename from pp_base_format_verbatim.
	(pp_flush): Rename from pp_base_flush.
	(pp_set_line_maximum_length): Rename from
	pp_base_set_line_maximum_length.
	(pp_clear_output_area): Rename from pp_base_clear_output_area.
	(pp_set_prefix): Rename from pp_base_set_prefix.
	(pp_destroy_prefix): Rename from pp_base_destroy_prefix.
	(pp_emit_prefix): Rename from pp_base_emit_prefix.
	(pp_append_text): Rename from pp_base_append_text.
	(pp_formatted_text): Rename from pp_base_formatted_text.
	(pp_last_position_in_text): Rename from pp_base_last_position_in_text.
	(pp_remaining_character_count_for_line): Rename from
	pp_base_remaining_character_count_for_line.
	(pp_newline): Rename from pp_base_newline.
	(pp_character): Rename from pp_base_character.
	(pp_string): Rename from pp_base_string.
	(pp_maybe_space): Rename from pp_base_maybe_space.
	* asan.c (asan_pp_string): Adjust.
	(asan_emit_stack_protection): Likewise.
	(asan_add_global): Likewise.
	* sched-vis.c (str_pattern_slim): Adjust pretty printer function call.
	* tree-mudflap.c (mf_varname_tree): Likewise.
	* tree-pretty-print.c (pp_tree_identifier): Rename from
	pp_base_tree_identifier.
	* tree-pretty-print.h (pp_tree_identifier): Remove macro definition.
	Declare as function.

c/
	* c-objc-common.c (c_initialize_diagnostics): Don't call pp_base.

c-family/
	* c-pretty-print.h (c_pretty_printer): Derive from pretty_printer.
	(pp_base): Remove.
	(pp_c_base): Likewise.  Adjust users.
	* c-pretty-print.c (pp_c_maybe_whitespace): Adjust.
	(pp_c_whitespace): Do not call pp_base.
	(pp_c_left_paren): Likewise.
	(pp_c_right_paren): Likewise.
	(pp_c_left_brace): Likewise.
	(pp_c_right_brace): Likewise.
	(pp_c_left_bracket): Likewise.
	(pp_c_right_bracket): Likewise.
	(pp_c_dot): Likewise.
	(pp_c_ampersand): Likewise.
	(pp_c_star): Likewise.
	(pp_c_arrow): Likewise.
	(pp_c_semicolon): Likewise.
	(pp_c_complement): Likewise.
	(pp_c_exclamation): Likewise.
	(pp_c_direct_declarator): Likewise.
	(pp_c_ws_string): Likewise.
	(pp_c_identifier): Likewise.
	(pp_c_statement): Likewise.
	(print_c_tree): Likewise.

cp/
	* cxx-pretty-print.h (pp_c_base): Remove.
	(cxx_pretty_printer): Derive from c_pretty_printer.
	Adjust macros using pp_c_base.
	* cp-objcp-common.c (cxx_initialize_diagnostics): Do not call pp_base.
	* cxx-pretty-print.c (pp_cxx_nonconsecutive_character): Likewise.
	(pp_cxx_colon_colon): Likewise.
	(pp_cxx_separate_with): Likewise.
	(pp_cxx_storage_class_specifier): Do not call pp_c_base.
	(pp_cxx_expression_list): Likewise.
	(pp_cxx_space_for_pointer_operator): Likewise.
	(pp_cxx_init_declarator): Likewise.
	(pp_cxx_call_argument_list): Likewise.
	(pp_cxx_constant): Likewise.
	(pp_cxx_postfix_expression): Likewise.
	(pp_cxx_new_expression): Likewise.
	(pp_cxx_unary_expression): Likewise.
	(pp_cxx_cast_expression): Likewise.
	(pp_cxx_conditional_expression): Likewise.
	(pp_cxx_assignment_expression): Likewise.
	(pp_cxx_expression): Likewise.
	(pp_cxx_function_specifier): Likewise.
	(pp_cxx_decl_specifier_seq): Likewise.
	(pp_cxx_simple_type_specifier): Likewise.
	(pp_cxx_type_specifier_seq): Likewise.
	(pp_cxx_ptr_operator): Likewise.
	(pp_cxx_parameter_declaration_clause): Likewise.
	(pp_cxx_direct_declarator): Likewise.
	(pp_cxx_direct_abstract_declarator): Likewise.
	(pp_cxx_type_id): Likewise.
	(pp_cxx_statement): Likewise.
	(pp_cxx_pretty_printer_init): Tidy.
	* error.c (init_error): Do not use pp_base.
	(dump_aggr_type): Likewise.
	(dump_type_prefix): Likewise.
	(dump_type_suffix): Likewise.
	(dump_global_iord): Likewise.
	(dump_decl): Likewise.
	(dump_function_decl): Likewise.
	(dump_ref_qualifier): Likewise.
	(reinit_cxx_pp): Likewise.
	(decl_as_dwarf_string): Likewise.
	(lang_decl_dwarf_name): Likewise.
	(type_to_string): Likewise.
	(cv_to_string): Likewise.
	(cxx_print_error_function): Likewise.
	(cp_diagnostic_starter): Likewise.
	(cp_diagnostic_finalizer): Likewise.
	(cp_print_error_function): Likewise.
	(print_instantiation_context): Likewise.
	(cp_printer): Likewise.

From-SVN: r201479
parent 5edf2c60
2013-08-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* pretty-print.h (pp_base): Remove. Adjust dependent macros.
* diagnostic.h (diagnostic_flush_buffer): Adjust.
* pretty-print.c (pp_formatted_text_data): Likewise.
(pp_indent): Rename from pp_base_indent.
(pp_format): Rename from pp_base_format.
(pp_output_formatted_text): Rename from pp_base_output_formatted_text.
(pp_format_verbatim): Rename from pp_base_format_verbatim.
(pp_flush): Rename from pp_base_flush.
(pp_set_line_maximum_length): Rename from
pp_base_set_line_maximum_length.
(pp_clear_output_area): Rename from pp_base_clear_output_area.
(pp_set_prefix): Rename from pp_base_set_prefix.
(pp_destroy_prefix): Rename from pp_base_destroy_prefix.
(pp_emit_prefix): Rename from pp_base_emit_prefix.
(pp_append_text): Rename from pp_base_append_text.
(pp_formatted_text): Rename from pp_base_formatted_text.
(pp_last_position_in_text): Rename from pp_base_last_position_in_text.
(pp_remaining_character_count_for_line): Rename from
pp_base_remaining_character_count_for_line.
(pp_newline): Rename from pp_base_newline.
(pp_character): Rename from pp_base_character.
(pp_string): Rename from pp_base_string.
(pp_maybe_space): Rename from pp_base_maybe_space.
* asan.c (asan_pp_string): Adjust.
(asan_emit_stack_protection): Likewise.
(asan_add_global): Likewise.
* sched-vis.c (str_pattern_slim): Adjust pretty printer function call.
* tree-mudflap.c (mf_varname_tree): Likewise.
* tree-pretty-print.c (pp_tree_identifier): Rename from
pp_base_tree_identifier.
* tree-pretty-print.h (pp_tree_identifier): Remove macro definition.
Declare as function.
2013-08-03 Gabriel Dos Reis <gdr@integrable-solutions.net> 2013-08-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* pretty-print.h (pp_bar_bar): New. * pretty-print.h (pp_bar_bar): New.
......
...@@ -860,7 +860,7 @@ asan_pp_initialize (void) ...@@ -860,7 +860,7 @@ asan_pp_initialize (void)
static tree static tree
asan_pp_string (void) asan_pp_string (void)
{ {
const char *buf = pp_base_formatted_text (&asan_pp); const char *buf = pp_formatted_text (&asan_pp);
size_t len = strlen (buf); size_t len = strlen (buf);
tree ret = build_string (len + 1, buf); tree ret = build_string (len + 1, buf);
TREE_TYPE (ret) TREE_TYPE (ret)
...@@ -955,7 +955,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls, ...@@ -955,7 +955,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls,
pp_clear_output_area (&asan_pp); pp_clear_output_area (&asan_pp);
if (DECL_NAME (current_function_decl)) if (DECL_NAME (current_function_decl))
pp_base_tree_identifier (&asan_pp, DECL_NAME (current_function_decl)); pp_tree_identifier (&asan_pp, DECL_NAME (current_function_decl));
else else
pp_string (&asan_pp, "<unknown>"); pp_string (&asan_pp, "<unknown>");
pp_space (&asan_pp); pp_space (&asan_pp);
...@@ -972,7 +972,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls, ...@@ -972,7 +972,7 @@ asan_emit_stack_protection (rtx base, HOST_WIDE_INT *offsets, tree *decls,
{ {
pp_decimal_int (&asan_pp, IDENTIFIER_LENGTH (DECL_NAME (decl))); pp_decimal_int (&asan_pp, IDENTIFIER_LENGTH (DECL_NAME (decl)));
pp_space (&asan_pp); pp_space (&asan_pp);
pp_base_tree_identifier (&asan_pp, DECL_NAME (decl)); pp_tree_identifier (&asan_pp, DECL_NAME (decl));
} }
else else
pp_string (&asan_pp, "9 <unknown>"); pp_string (&asan_pp, "9 <unknown>");
...@@ -1981,7 +1981,7 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v) ...@@ -1981,7 +1981,7 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
pp_clear_output_area (&asan_pp); pp_clear_output_area (&asan_pp);
if (DECL_NAME (decl)) if (DECL_NAME (decl))
pp_base_tree_identifier (&asan_pp, DECL_NAME (decl)); pp_tree_identifier (&asan_pp, DECL_NAME (decl));
else else
pp_string (&asan_pp, "<unknown>"); pp_string (&asan_pp, "<unknown>");
pp_space (&asan_pp); pp_space (&asan_pp);
......
2013-08-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-pretty-print.h (c_pretty_printer): Derive from pretty_printer.
(pp_base): Remove.
(pp_c_base): Likewise. Adjust users.
* c-pretty-print.c (pp_c_maybe_whitespace): Adjust.
(pp_c_whitespace): Do not call pp_base.
(pp_c_left_paren): Likewise.
(pp_c_right_paren): Likewise.
(pp_c_left_brace): Likewise.
(pp_c_right_brace): Likewise.
(pp_c_left_bracket): Likewise.
(pp_c_right_bracket): Likewise.
(pp_c_dot): Likewise.
(pp_c_ampersand): Likewise.
(pp_c_star): Likewise.
(pp_c_arrow): Likewise.
(pp_c_semicolon): Likewise.
(pp_c_complement): Likewise.
(pp_c_exclamation): Likewise.
(pp_c_direct_declarator): Likewise.
(pp_c_ws_string): Likewise.
(pp_c_identifier): Likewise.
(pp_c_statement): Likewise.
(print_c_tree): Likewise.
2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net> 2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net>
PR c++/58072 PR c++/58072
......
...@@ -43,7 +43,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -43,7 +43,7 @@ along with GCC; see the file COPYING3. If not see
#define pp_c_maybe_whitespace(PP) \ #define pp_c_maybe_whitespace(PP) \
do { \ do { \
if (pp_base (PP)->padding == pp_before) \ if ((PP)->padding == pp_before) \
pp_c_whitespace (PP); \ pp_c_whitespace (PP); \
} while (0) } while (0)
...@@ -75,98 +75,98 @@ void ...@@ -75,98 +75,98 @@ void
pp_c_whitespace (c_pretty_printer *pp) pp_c_whitespace (c_pretty_printer *pp)
{ {
pp_space (pp); pp_space (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_left_paren (c_pretty_printer *pp) pp_c_left_paren (c_pretty_printer *pp)
{ {
pp_left_paren (pp); pp_left_paren (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_right_paren (c_pretty_printer *pp) pp_c_right_paren (c_pretty_printer *pp)
{ {
pp_right_paren (pp); pp_right_paren (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_left_brace (c_pretty_printer *pp) pp_c_left_brace (c_pretty_printer *pp)
{ {
pp_left_brace (pp); pp_left_brace (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_right_brace (c_pretty_printer *pp) pp_c_right_brace (c_pretty_printer *pp)
{ {
pp_right_brace (pp); pp_right_brace (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_left_bracket (c_pretty_printer *pp) pp_c_left_bracket (c_pretty_printer *pp)
{ {
pp_left_bracket (pp); pp_left_bracket (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_right_bracket (c_pretty_printer *pp) pp_c_right_bracket (c_pretty_printer *pp)
{ {
pp_right_bracket (pp); pp_right_bracket (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_dot (c_pretty_printer *pp) pp_c_dot (c_pretty_printer *pp)
{ {
pp_dot (pp); pp_dot (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_ampersand (c_pretty_printer *pp) pp_c_ampersand (c_pretty_printer *pp)
{ {
pp_ampersand (pp); pp_ampersand (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_star (c_pretty_printer *pp) pp_c_star (c_pretty_printer *pp)
{ {
pp_star (pp); pp_star (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_arrow (c_pretty_printer *pp) pp_c_arrow (c_pretty_printer *pp)
{ {
pp_arrow (pp); pp_arrow (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_semicolon (c_pretty_printer *pp) pp_c_semicolon (c_pretty_printer *pp)
{ {
pp_semicolon (pp); pp_semicolon (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_complement (c_pretty_printer *pp) pp_c_complement (c_pretty_printer *pp)
{ {
pp_complement (pp); pp_complement (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
pp_c_exclamation (c_pretty_printer *pp) pp_c_exclamation (c_pretty_printer *pp)
{ {
pp_exclamation (pp); pp_exclamation (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
/* Print out the external representation of QUALIFIERS. */ /* Print out the external representation of QUALIFIERS. */
...@@ -703,7 +703,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t) ...@@ -703,7 +703,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t)
case FUNCTION_DECL: case FUNCTION_DECL:
pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t))); pp_c_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t)));
pp_c_tree_decl_identifier (pp, t); pp_c_tree_decl_identifier (pp, t);
if (pp_c_base (pp)->flags & pp_c_flag_abstract) if (pp->flags & pp_c_flag_abstract)
pp_abstract_declarator (pp, TREE_TYPE (t)); pp_abstract_declarator (pp, TREE_TYPE (t));
else else
{ {
...@@ -1184,7 +1184,7 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str) ...@@ -1184,7 +1184,7 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str)
{ {
pp_c_maybe_whitespace (pp); pp_c_maybe_whitespace (pp);
pp_string (pp, str); pp_string (pp, str);
pp_base (pp)->padding = pp_before; pp->padding = pp_before;
} }
/* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences /* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences
...@@ -1196,7 +1196,7 @@ pp_c_identifier (c_pretty_printer *pp, const char *id) ...@@ -1196,7 +1196,7 @@ pp_c_identifier (c_pretty_printer *pp, const char *id)
{ {
pp_c_maybe_whitespace (pp); pp_c_maybe_whitespace (pp);
pp_identifier (pp, id); pp_identifier (pp, id);
pp_base (pp)->padding = pp_before; pp->padding = pp_before;
} }
/* Pretty-print a C primary-expression. /* Pretty-print a C primary-expression.
...@@ -2312,7 +2312,7 @@ pp_c_statement (c_pretty_printer *pp, tree stmt) ...@@ -2312,7 +2312,7 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
if (pp_needs_newline (pp)) if (pp_needs_newline (pp))
pp_newline_and_indent (pp, 0); pp_newline_and_indent (pp, 0);
dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true); dump_generic_node (pp, stmt, pp_indentation (pp), 0, true);
} }
...@@ -2366,11 +2366,11 @@ print_c_tree (FILE *file, tree t) ...@@ -2366,11 +2366,11 @@ print_c_tree (FILE *file, tree t)
if (!initialized) if (!initialized)
{ {
initialized = 1; initialized = 1;
pp_construct (pp_base (pp), NULL, 0); pp_construct (pp, NULL, 0);
pp_c_pretty_printer_init (pp); pp_c_pretty_printer_init (pp);
pp_needs_newline (pp) = true; pp_needs_newline (pp) = true;
} }
pp_base (pp)->buffer->stream = file; pp->buffer->stream = file;
pp_statement (pp, t); pp_statement (pp, t);
......
...@@ -26,35 +26,29 @@ along with GCC; see the file COPYING3. If not see ...@@ -26,35 +26,29 @@ along with GCC; see the file COPYING3. If not see
#include "pretty-print.h" #include "pretty-print.h"
typedef enum enum pp_c_pretty_print_flags
{ {
pp_c_flag_abstract = 1 << 1, pp_c_flag_abstract = 1 << 1,
pp_c_flag_gnu_v3 = 1 << 2, pp_c_flag_gnu_v3 = 1 << 2,
pp_c_flag_last_bit = 3 pp_c_flag_last_bit = 3
} pp_c_pretty_print_flags; };
/* The data type used to bundle information necessary for pretty-printing /* The data type used to bundle information necessary for pretty-printing
a C or C++ entity. */ a C or C++ entity. */
typedef struct c_pretty_print_info c_pretty_printer; struct c_pretty_printer;
/* The type of a C pretty-printer 'member' function. */ /* The type of a C pretty-printer 'member' function. */
typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree); typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree);
/* The datatype that contains information necessary for pretty-printing /* The datatype that contains information necessary for pretty-printing
a tree that represents a C construct. Any pretty-printer for a a tree that represents a C construct. Any pretty-printer for a
language using C/c++ syntax can derive from this datatype and reuse language using C syntax can derive from this datatype and reuse
facilities provided here. It can do so by having a subobject of type facilities provided here. A derived pretty-printer can override
c_pretty_printer and override the macro pp_c_base to return a pointer any function listed in the vtable below. See cp/cxx-pretty-print.h
to that subobject. Such a pretty-printer has the responsibility to and cp/cxx-pretty-print.c for an example of derivation. */
initialize the pp_base() part, then call pp_c_pretty_printer_init struct c_pretty_printer : pretty_printer
to set up the components that are specific to the C pretty-printer.
A derived pretty-printer can override any function listed in the
vtable below. See cp/cxx-pretty-print.h and cp/cxx-pretty-print.c
for an example of derivation. */
struct c_pretty_print_info
{ {
pretty_printer base;
/* 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;
...@@ -91,70 +85,40 @@ struct c_pretty_print_info ...@@ -91,70 +85,40 @@ struct c_pretty_print_info
c_pretty_print_fn expression; c_pretty_print_fn expression;
}; };
/* Override the pp_base macro. Derived pretty-printers should not
touch this macro. Instead they should override pp_c_base instead. */
#undef pp_base
#define pp_base(PP) (&pp_c_base (PP)->base)
#define pp_c_tree_identifier(PPI, ID) \ #define pp_c_tree_identifier(PPI, ID) \
pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
#define pp_declaration(PPI, T) \ #define pp_declaration(PP, T) (PP)->declaration (PP, T)
pp_c_base (PPI)->declaration (pp_c_base (PPI), T) #define pp_declaration_specifiers(PP, D) \
#define pp_declaration_specifiers(PPI, D) \ (PP)->declaration_specifiers (PP, D)
pp_c_base (PPI)->declaration_specifiers (pp_c_base (PPI), D) #define pp_abstract_declarator(PP, D) (PP)->abstract_declarator (PP, D)
#define pp_abstract_declarator(PP, D) \ #define pp_type_specifier_seq(PP, D) (PP)->type_specifier_seq (PP, D)
pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D) #define pp_declarator(PP, D) (PP)->declarator (PP, D)
#define pp_type_specifier_seq(PPI, D) \ #define pp_direct_declarator(PP, D) (PP)->direct_declarator (PP, D)
pp_c_base (PPI)->type_specifier_seq (pp_c_base (PPI), D)
#define pp_declarator(PPI, D) \
pp_c_base (PPI)->declarator (pp_c_base (PPI), D)
#define pp_direct_declarator(PPI, D) \
pp_c_base (PPI)->direct_declarator (pp_c_base (PPI), D)
#define pp_direct_abstract_declarator(PP, D) \ #define pp_direct_abstract_declarator(PP, D) \
pp_c_base (PP)->direct_abstract_declarator (pp_c_base (PP), D) (PP)->direct_abstract_declarator (PP, D)
#define pp_ptr_operator(PP, D) \ #define pp_ptr_operator(PP, D) (PP)->ptr_operator (PP, D)
pp_c_base (PP)->ptr_operator (pp_c_base (PP), D) #define pp_parameter_list(PP, T) (PP)->parameter_list (PP, T)
#define pp_parameter_list(PPI, T) \ #define pp_type_id(PP, D) (PP)->type_id (PP, D)
pp_c_base (PPI)->parameter_list (pp_c_base (PPI), T) #define pp_simple_type_specifier(PP, T) (PP)->simple_type_specifier (PP, T)
#define pp_type_id(PPI, D) \ #define pp_function_specifier(PP, D) (PP)->function_specifier (PP, D)
pp_c_base (PPI)->type_id (pp_c_base (PPI), D)
#define pp_simple_type_specifier(PP, T) \
pp_c_base (PP)->simple_type_specifier (pp_c_base (PP), T)
#define pp_function_specifier(PP, D) \
pp_c_base (PP)->function_specifier (pp_c_base (PP), D)
#define pp_storage_class_specifier(PP, D) \ #define pp_storage_class_specifier(PP, D) \
pp_c_base (PP)->storage_class_specifier (pp_c_base (PP), D); (PP)->storage_class_specifier (PP, D);
#define pp_statement(PPI, S) \ #define pp_statement(PP, S) (PP)->statement (PP, S)
pp_c_base (PPI)->statement (pp_c_base (PPI), S)
#define pp_constant(PP, E) (PP)->constant (PP, E)
#define pp_constant(PP, E) \ #define pp_id_expression(PP, E) (PP)->id_expression (PP, E)
pp_c_base (PP)->constant (pp_c_base (PP), E) #define pp_primary_expression(PP, E) (PP)->primary_expression (PP, E)
#define pp_id_expression(PP, E) \ #define pp_postfix_expression(PP, E) (PP)->postfix_expression (PP, E)
pp_c_base (PP)->id_expression (pp_c_base (PP), E) #define pp_unary_expression(PP, E) (PP)->unary_expression (PP, E)
#define pp_primary_expression(PPI, E) \ #define pp_initializer(PP, E) (PP)->initializer (PP, E)
pp_c_base (PPI)->primary_expression (pp_c_base (PPI), E) #define pp_multiplicative_expression(PP, E) \
#define pp_postfix_expression(PPI, E) \ (PP)->multiplicative_expression (PP, E)
pp_c_base (PPI)->postfix_expression (pp_c_base (PPI), E) #define pp_conditional_expression(PP, E) (PP)->conditional_expression (PP, E)
#define pp_unary_expression(PPI, E) \ #define pp_assignment_expression(PP, E) (PP)->assignment_expression (PP, E)
pp_c_base (PPI)->unary_expression (pp_c_base (PPI), E) #define pp_expression(PP, E) (PP)->expression (PP, E)
#define pp_initializer(PPI, E) \
pp_c_base (PPI)->initializer (pp_c_base (PPI), E)
#define pp_multiplicative_expression(PPI, E) \
pp_c_base (PPI)->multiplicative_expression (pp_c_base (PPI), E)
#define pp_conditional_expression(PPI, E) \
pp_c_base (PPI)->conditional_expression (pp_c_base (PPI), E)
#define pp_assignment_expression(PPI, E) \
pp_c_base (PPI)->assignment_expression (pp_c_base (PPI), E)
#define pp_expression(PP, E) \
pp_c_base (PP)->expression (pp_c_base (PP), E)
/* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
macro must be overridden by any subclass of c_pretty_print_info. */
#define pp_c_base(PP) (PP)
extern void pp_c_pretty_printer_init (c_pretty_printer *); extern void pp_c_pretty_printer_init (c_pretty_printer *);
void pp_c_whitespace (c_pretty_printer *); void pp_c_whitespace (c_pretty_printer *);
......
2013-08-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-objc-common.c (c_initialize_diagnostics): Don't call pp_base.
2013-07-23 Joseph Myers <joseph@codesourcery.com> 2013-07-23 Joseph Myers <joseph@codesourcery.com>
* c-parser.c (struct c_generic_association): Fix typo. * c-parser.c (struct c_generic_association): Fix typo.
......
...@@ -190,7 +190,7 @@ c_initialize_diagnostics (diagnostic_context *context) ...@@ -190,7 +190,7 @@ c_initialize_diagnostics (diagnostic_context *context)
base = context->printer; base = context->printer;
pp = XNEW (c_pretty_printer); pp = XNEW (c_pretty_printer);
memcpy (pp_base (pp), base, sizeof (pretty_printer)); memcpy (pp, base, sizeof (pretty_printer));
pp_c_pretty_printer_init (pp); pp_c_pretty_printer_init (pp);
context->printer = (pretty_printer *) pp; context->printer = (pretty_printer *) pp;
......
2013-08-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cxx-pretty-print.h (pp_c_base): Remove.
(cxx_pretty_printer): Derive from c_pretty_printer.
Adjust macros using pp_c_base.
* cp-objcp-common.c (cxx_initialize_diagnostics): Do not call pp_base.
* cxx-pretty-print.c (pp_cxx_nonconsecutive_character): Likewise.
(pp_cxx_colon_colon): Likewise.
(pp_cxx_separate_with): Likewise.
(pp_cxx_storage_class_specifier): Do not call pp_c_base.
(pp_cxx_expression_list): Likewise.
(pp_cxx_space_for_pointer_operator): Likewise.
(pp_cxx_init_declarator): Likewise.
(pp_cxx_call_argument_list): Likewise.
(pp_cxx_constant): Likewise.
(pp_cxx_postfix_expression): Likewise.
(pp_cxx_new_expression): Likewise.
(pp_cxx_unary_expression): Likewise.
(pp_cxx_cast_expression): Likewise.
(pp_cxx_conditional_expression): Likewise.
(pp_cxx_assignment_expression): Likewise.
(pp_cxx_expression): Likewise.
(pp_cxx_function_specifier): Likewise.
(pp_cxx_decl_specifier_seq): Likewise.
(pp_cxx_simple_type_specifier): Likewise.
(pp_cxx_type_specifier_seq): Likewise.
(pp_cxx_ptr_operator): Likewise.
(pp_cxx_parameter_declaration_clause): Likewise.
(pp_cxx_direct_declarator): Likewise.
(pp_cxx_direct_abstract_declarator): Likewise.
(pp_cxx_type_id): Likewise.
(pp_cxx_statement): Likewise.
(pp_cxx_pretty_printer_init): Tidy.
* error.c (init_error): Do not use pp_base.
(dump_aggr_type): Likewise.
(dump_type_prefix): Likewise.
(dump_type_suffix): Likewise.
(dump_global_iord): Likewise.
(dump_decl): Likewise.
(dump_function_decl): Likewise.
(dump_ref_qualifier): Likewise.
(reinit_cxx_pp): Likewise.
(decl_as_dwarf_string): Likewise.
(lang_decl_dwarf_name): Likewise.
(type_to_string): Likewise.
(cv_to_string): Likewise.
(cxx_print_error_function): Likewise.
(cp_diagnostic_starter): Likewise.
(cp_diagnostic_finalizer): Likewise.
(cp_print_error_function): Likewise.
(print_instantiation_context): Likewise.
(cp_printer): Likewise.
2013-08-03 Gabriel Dos Reis <gdr@integrable-solutions.net> 2013-08-03 Gabriel Dos Reis <gdr@integrable-solutions.net>
* error.c (dump_type_prefix): Use specialized pretty printer * error.c (dump_type_prefix): Use specialized pretty printer
......
...@@ -138,7 +138,7 @@ cxx_initialize_diagnostics (diagnostic_context *context) ...@@ -138,7 +138,7 @@ cxx_initialize_diagnostics (diagnostic_context *context)
base = context->printer; base = context->printer;
pp = XNEW (cxx_pretty_printer); pp = XNEW (cxx_pretty_printer);
memcpy (pp_base (pp), base, sizeof (pretty_printer)); memcpy (pp, base, sizeof (pretty_printer));
pp_cxx_pretty_printer_init (pp); pp_cxx_pretty_printer_init (pp);
context->printer = (pretty_printer *) pp; context->printer = (pretty_printer *) pp;
......
...@@ -58,25 +58,25 @@ pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c) ...@@ -58,25 +58,25 @@ pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c)
if (p != NULL && *p == c) if (p != NULL && *p == c)
pp_cxx_whitespace (pp); pp_cxx_whitespace (pp);
pp_character (pp, c); pp_character (pp, c);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
#define pp_cxx_storage_class_specifier(PP, T) \ #define pp_cxx_storage_class_specifier(PP, T) \
pp_c_storage_class_specifier (pp_c_base (PP), T) pp_c_storage_class_specifier (PP, T)
#define pp_cxx_expression_list(PP, T) \ #define pp_cxx_expression_list(PP, T) \
pp_c_expression_list (pp_c_base (PP), T) pp_c_expression_list (PP, T)
#define pp_cxx_space_for_pointer_operator(PP, T) \ #define pp_cxx_space_for_pointer_operator(PP, T) \
pp_c_space_for_pointer_operator (pp_c_base (PP), T) pp_c_space_for_pointer_operator (PP, T)
#define pp_cxx_init_declarator(PP, T) \ #define pp_cxx_init_declarator(PP, T) \
pp_c_init_declarator (pp_c_base (PP), T) pp_c_init_declarator (PP, T)
#define pp_cxx_call_argument_list(PP, T) \ #define pp_cxx_call_argument_list(PP, T) \
pp_c_call_argument_list (pp_c_base (PP), T) pp_c_call_argument_list (PP, T)
void void
pp_cxx_colon_colon (cxx_pretty_printer *pp) pp_cxx_colon_colon (cxx_pretty_printer *pp)
{ {
pp_colon_colon (pp); pp_colon_colon (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
void void
...@@ -95,7 +95,7 @@ void ...@@ -95,7 +95,7 @@ void
pp_cxx_separate_with (cxx_pretty_printer *pp, int c) pp_cxx_separate_with (cxx_pretty_printer *pp, int c)
{ {
pp_separate_with (pp, c); pp_separate_with (pp, c);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
/* Expressions. */ /* Expressions. */
...@@ -331,7 +331,7 @@ pp_cxx_constant (cxx_pretty_printer *pp, tree t) ...@@ -331,7 +331,7 @@ pp_cxx_constant (cxx_pretty_printer *pp, tree t)
const bool in_parens = PAREN_STRING_LITERAL_P (t); const bool in_parens = PAREN_STRING_LITERAL_P (t);
if (in_parens) if (in_parens)
pp_cxx_left_paren (pp); pp_cxx_left_paren (pp);
pp_c_constant (pp_c_base (pp), t); pp_c_constant (pp, t);
if (in_parens) if (in_parens)
pp_cxx_right_paren (pp); pp_cxx_right_paren (pp);
} }
...@@ -346,7 +346,7 @@ pp_cxx_constant (cxx_pretty_printer *pp, tree t) ...@@ -346,7 +346,7 @@ pp_cxx_constant (cxx_pretty_printer *pp, tree t)
/* else fall through. */ /* else fall through. */
default: default:
pp_c_constant (pp_c_base (pp), t); pp_c_constant (pp, t);
break; break;
} }
} }
...@@ -465,7 +465,7 @@ pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t) ...@@ -465,7 +465,7 @@ pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_primary_expression (pp_c_base (pp), t); pp_c_primary_expression (pp, t);
break; break;
} }
} }
...@@ -643,7 +643,7 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) ...@@ -643,7 +643,7 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_postfix_expression (pp_c_base (pp), t); pp_c_postfix_expression (pp, t);
break; break;
} }
} }
...@@ -699,7 +699,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) ...@@ -699,7 +699,7 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
{ {
pp_left_paren (pp); pp_left_paren (pp);
if (TREE_CODE (init) == TREE_LIST) if (TREE_CODE (init) == TREE_LIST)
pp_c_expression_list (pp_c_base (pp), init); pp_c_expression_list (pp, init);
else if (init == void_zero_node) else if (init == void_zero_node)
; /* OK, empty initializer list. */ ; /* OK, empty initializer list. */
else else
...@@ -736,7 +736,7 @@ pp_cxx_delete_expression (cxx_pretty_printer *pp, tree t) ...@@ -736,7 +736,7 @@ pp_cxx_delete_expression (cxx_pretty_printer *pp, tree t)
pp_right_bracket (pp); pp_right_bracket (pp);
pp_space (pp); pp_space (pp);
} }
pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 0)); pp_c_cast_expression (pp, TREE_OPERAND (t, 0));
break; break;
default: default:
...@@ -835,7 +835,7 @@ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t) ...@@ -835,7 +835,7 @@ pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_unary_expression (pp_c_base (pp), t); pp_c_unary_expression (pp, t);
break; break;
} }
} }
...@@ -856,7 +856,7 @@ pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t) ...@@ -856,7 +856,7 @@ pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_cast_expression (pp_c_base (pp), t); pp_c_cast_expression (pp, t);
break; break;
} }
} }
...@@ -939,7 +939,7 @@ pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e) ...@@ -939,7 +939,7 @@ pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e)
{ {
if (TREE_CODE (e) == COND_EXPR) if (TREE_CODE (e) == COND_EXPR)
{ {
pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
pp_space (pp); pp_space (pp);
pp_question (pp); pp_question (pp);
pp_space (pp); pp_space (pp);
...@@ -948,7 +948,7 @@ pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e) ...@@ -948,7 +948,7 @@ pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e)
pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2)); pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
} }
else else
pp_c_logical_or_expression (pp_c_base (pp), e); pp_c_logical_or_expression (pp, e);
} }
/* Pretty-print a compound assignment operator token as indicated by T. */ /* Pretty-print a compound assignment operator token as indicated by T. */
...@@ -1007,7 +1007,7 @@ pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e) ...@@ -1007,7 +1007,7 @@ pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e)
{ {
case MODIFY_EXPR: case MODIFY_EXPR:
case INIT_EXPR: case INIT_EXPR:
pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
pp_space (pp); pp_space (pp);
pp_equal (pp); pp_equal (pp);
pp_space (pp); pp_space (pp);
...@@ -1021,7 +1021,7 @@ pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e) ...@@ -1021,7 +1021,7 @@ pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e)
break; break;
case MODOP_EXPR: case MODOP_EXPR:
pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
pp_cxx_assignment_operator (pp, TREE_OPERAND (e, 1)); pp_cxx_assignment_operator (pp, TREE_OPERAND (e, 1));
pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2)); pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
break; break;
...@@ -1174,7 +1174,7 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t) ...@@ -1174,7 +1174,7 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_expression (pp_c_base (pp), t); pp_c_expression (pp, t);
break; break;
} }
} }
...@@ -1198,7 +1198,7 @@ pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t) ...@@ -1198,7 +1198,7 @@ pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t)
else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t)) else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t))
pp_cxx_ws_string (pp, "explicit"); pp_cxx_ws_string (pp, "explicit");
else else
pp_c_function_specifier (pp_c_base (pp), t); pp_c_function_specifier (pp, t);
default: default:
break; break;
...@@ -1242,7 +1242,7 @@ pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t) ...@@ -1242,7 +1242,7 @@ pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t)
pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t))); pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t)));
else else
default: default:
pp_c_declaration_specifiers (pp_c_base (pp), t); pp_c_declaration_specifiers (pp, t);
break; break;
} }
} }
...@@ -1287,7 +1287,7 @@ pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t) ...@@ -1287,7 +1287,7 @@ pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_type_specifier (pp_c_base (pp), t); pp_c_type_specifier (pp, t);
break; break;
} }
} }
...@@ -1342,7 +1342,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) ...@@ -1342,7 +1342,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
default: default:
if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t))) if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t)))
pp_c_specifier_qualifier_list (pp_c_base (pp), t); pp_c_specifier_qualifier_list (pp, t);
} }
} }
...@@ -1362,8 +1362,7 @@ pp_cxx_ptr_operator (cxx_pretty_printer *pp, tree t) ...@@ -1362,8 +1362,7 @@ pp_cxx_ptr_operator (cxx_pretty_printer *pp, tree t)
case POINTER_TYPE: case POINTER_TYPE:
if (TYPE_PTR_OR_PTRMEM_P (TREE_TYPE (t))) if (TYPE_PTR_OR_PTRMEM_P (TREE_TYPE (t)))
pp_cxx_ptr_operator (pp, TREE_TYPE (t)); pp_cxx_ptr_operator (pp, TREE_TYPE (t));
pp_c_attributes_display (pp_c_base (pp), pp_c_attributes_display (pp, TYPE_ATTRIBUTES (TREE_TYPE (t)));
TYPE_ATTRIBUTES (TREE_TYPE (t)));
if (TYPE_PTR_P (t)) if (TYPE_PTR_P (t))
{ {
pp_star (pp); pp_star (pp);
...@@ -1436,8 +1435,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t) ...@@ -1436,8 +1435,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
tree args = TYPE_P (t) ? NULL : FUNCTION_FIRST_USER_PARM (t); tree args = TYPE_P (t) ? NULL : FUNCTION_FIRST_USER_PARM (t);
tree types = tree types =
TYPE_P (t) ? TYPE_ARG_TYPES (t) : FUNCTION_FIRST_USER_PARMTYPE (t); TYPE_P (t) ? TYPE_ARG_TYPES (t) : FUNCTION_FIRST_USER_PARMTYPE (t);
const bool abstract = args == NULL const bool abstract = args == NULL || pp->flags & pp_c_flag_abstract;
|| pp_c_base (pp)->flags & pp_c_flag_abstract;
bool first = true; bool first = true;
/* Skip artificial parameter for nonstatic member functions. */ /* Skip artificial parameter for nonstatic member functions. */
...@@ -1451,7 +1449,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t) ...@@ -1451,7 +1449,7 @@ pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t)
pp_cxx_separate_with (pp, ','); pp_cxx_separate_with (pp, ',');
first = false; first = false;
pp_cxx_parameter_declaration (pp, abstract ? TREE_VALUE (types) : args); pp_cxx_parameter_declaration (pp, abstract ? TREE_VALUE (types) : args);
if (!abstract && pp_c_base (pp)->flags & pp_cxx_flag_default_argument) if (!abstract && pp->flags & pp_cxx_flag_default_argument)
{ {
pp_cxx_whitespace (pp); pp_cxx_whitespace (pp);
pp_equal (pp); pp_equal (pp);
...@@ -1557,7 +1555,7 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) ...@@ -1557,7 +1555,7 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t)
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t)) if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t))
{ {
pp_base (pp)->padding = pp_before; pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (pp, pp_cxx_implicit_parameter_type (t)); pp_cxx_cv_qualifier_seq (pp, pp_cxx_implicit_parameter_type (t));
} }
...@@ -1572,7 +1570,7 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) ...@@ -1572,7 +1570,7 @@ pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_direct_declarator (pp_c_base (pp), t); pp_c_direct_declarator (pp, t);
break; break;
} }
} }
...@@ -1690,7 +1688,7 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) ...@@ -1690,7 +1688,7 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t)
pp_cxx_direct_abstract_declarator (pp, TREE_TYPE (t)); pp_cxx_direct_abstract_declarator (pp, TREE_TYPE (t));
if (TREE_CODE (t) == METHOD_TYPE) if (TREE_CODE (t) == METHOD_TYPE)
{ {
pp_base (pp)->padding = pp_before; pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (t)); pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (t));
} }
pp_cxx_exception_specification (pp, t); pp_cxx_exception_specification (pp, t);
...@@ -1704,7 +1702,7 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) ...@@ -1704,7 +1702,7 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_direct_abstract_declarator (pp_c_base (pp), t); pp_c_direct_abstract_declarator (pp, t);
break; break;
} }
} }
...@@ -1715,8 +1713,8 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) ...@@ -1715,8 +1713,8 @@ pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t)
static void static void
pp_cxx_type_id (cxx_pretty_printer *pp, tree t) pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
{ {
pp_flags saved_flags = pp_c_base (pp)->flags; pp_flags saved_flags = pp->flags;
pp_c_base (pp)->flags |= pp_c_flag_abstract; pp->flags |= pp_c_flag_abstract;
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
...@@ -1744,11 +1742,11 @@ pp_cxx_type_id (cxx_pretty_printer *pp, tree t) ...@@ -1744,11 +1742,11 @@ pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_type_id (pp_c_base (pp), t); pp_c_type_id (pp, t);
break; break;
} }
pp_c_base (pp)->flags = saved_flags; pp->flags = saved_flags;
} }
/* template-argument-list: /* template-argument-list:
...@@ -2021,7 +2019,7 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t) ...@@ -2021,7 +2019,7 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
break; break;
default: default:
pp_c_statement (pp_c_base (pp), t); pp_c_statement (pp, t);
break; break;
} }
} }
...@@ -2437,32 +2435,31 @@ typedef c_pretty_print_fn pp_fun; ...@@ -2437,32 +2435,31 @@ typedef c_pretty_print_fn pp_fun;
void void
pp_cxx_pretty_printer_init (cxx_pretty_printer *pp) pp_cxx_pretty_printer_init (cxx_pretty_printer *pp)
{ {
pp_c_pretty_printer_init (pp_c_base (pp)); pp_c_pretty_printer_init (pp);
pp_set_line_maximum_length (pp, 0); pp_set_line_maximum_length (pp, 0);
pp->c_base.declaration = (pp_fun) pp_cxx_declaration; pp->declaration = (pp_fun) pp_cxx_declaration;
pp->c_base.declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq; pp->declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq;
pp->c_base.function_specifier = (pp_fun) pp_cxx_function_specifier; pp->function_specifier = (pp_fun) pp_cxx_function_specifier;
pp->c_base.type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; pp->type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq;
pp->c_base.declarator = (pp_fun) pp_cxx_declarator; pp->declarator = (pp_fun) pp_cxx_declarator;
pp->c_base.direct_declarator = (pp_fun) pp_cxx_direct_declarator; pp->direct_declarator = (pp_fun) pp_cxx_direct_declarator;
pp->c_base.parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; pp->parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause;
pp->c_base.type_id = (pp_fun) pp_cxx_type_id; pp->type_id = (pp_fun) pp_cxx_type_id;
pp->c_base.abstract_declarator = (pp_fun) pp_cxx_abstract_declarator; pp->abstract_declarator = (pp_fun) pp_cxx_abstract_declarator;
pp->c_base.direct_abstract_declarator = pp->direct_abstract_declarator = (pp_fun) pp_cxx_direct_abstract_declarator;
(pp_fun) pp_cxx_direct_abstract_declarator; pp->simple_type_specifier = (pp_fun) pp_cxx_simple_type_specifier;
pp->c_base.simple_type_specifier = (pp_fun)pp_cxx_simple_type_specifier;
/* pp->statement = (pp_fun) pp_cxx_statement; */
/* pp->c_base.statement = (pp_fun) pp_cxx_statement; */
pp->constant = (pp_fun) pp_cxx_constant;
pp->c_base.constant = (pp_fun) pp_cxx_constant; pp->id_expression = (pp_fun) pp_cxx_id_expression;
pp->c_base.id_expression = (pp_fun) pp_cxx_id_expression; pp->primary_expression = (pp_fun) pp_cxx_primary_expression;
pp->c_base.primary_expression = (pp_fun) pp_cxx_primary_expression; pp->postfix_expression = (pp_fun) pp_cxx_postfix_expression;
pp->c_base.postfix_expression = (pp_fun) pp_cxx_postfix_expression; pp->unary_expression = (pp_fun) pp_cxx_unary_expression;
pp->c_base.unary_expression = (pp_fun) pp_cxx_unary_expression; pp->multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression;
pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression; pp->conditional_expression = (pp_fun) pp_cxx_conditional_expression;
pp->c_base.conditional_expression = (pp_fun) pp_cxx_conditional_expression; pp->assignment_expression = (pp_fun) pp_cxx_assignment_expression;
pp->c_base.assignment_expression = (pp_fun) pp_cxx_assignment_expression; pp->expression = (pp_fun) pp_cxx_expression;
pp->c_base.expression = (pp_fun) pp_cxx_expression;
pp->enclosing_scope = global_namespace; pp->enclosing_scope = global_namespace;
} }
...@@ -23,46 +23,41 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,46 +23,41 @@ along with GCC; see the file COPYING3. If not see
#include "c-family/c-pretty-print.h" #include "c-family/c-pretty-print.h"
#undef pp_c_base enum cxx_pretty_printer_flags
#define pp_c_base(PP) (&(PP)->c_base)
typedef enum
{ {
/* Ask for a qualified-id. */ /* Ask for a qualified-id. */
pp_cxx_flag_default_argument = 1 << pp_c_flag_last_bit pp_cxx_flag_default_argument = 1 << pp_c_flag_last_bit
};
} cxx_pretty_printer_flags; struct cxx_pretty_printer : c_pretty_printer
typedef struct
{ {
c_pretty_printer c_base;
/* 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;
} cxx_pretty_printer; };
#define pp_cxx_cv_qualifier_seq(PP, T) \ #define pp_cxx_cv_qualifier_seq(PP, T) \
pp_c_type_qualifier_list (pp_c_base (PP), T) pp_c_type_qualifier_list (PP, T)
#define pp_cxx_cv_qualifiers(PP, CV) \ #define pp_cxx_cv_qualifiers(PP, CV) \
pp_c_cv_qualifiers (pp_c_base (PP), CV, false) pp_c_cv_qualifiers (PP, CV, false)
#define pp_cxx_whitespace(PP) pp_c_whitespace (pp_c_base (PP)) #define pp_cxx_whitespace(PP) pp_c_whitespace (PP)
#define pp_cxx_left_paren(PP) pp_c_left_paren (pp_c_base (PP)) #define pp_cxx_left_paren(PP) pp_c_left_paren (PP)
#define pp_cxx_right_paren(PP) pp_c_right_paren (pp_c_base (PP)) #define pp_cxx_right_paren(PP) pp_c_right_paren (PP)
#define pp_cxx_left_brace(PP) pp_c_left_brace (pp_c_base (PP)) #define pp_cxx_left_brace(PP) pp_c_left_brace (PP)
#define pp_cxx_right_brace(PP) pp_c_right_brace (pp_c_base (PP)) #define pp_cxx_right_brace(PP) pp_c_right_brace (PP)
#define pp_cxx_left_bracket(PP) pp_c_left_bracket (pp_c_base (PP)) #define pp_cxx_left_bracket(PP) pp_c_left_bracket (PP)
#define pp_cxx_right_bracket(PP) pp_c_right_bracket (pp_c_base (PP)) #define pp_cxx_right_bracket(PP) pp_c_right_bracket (PP)
#define pp_cxx_dot(PP) pp_c_dot (pp_c_base (PP)) #define pp_cxx_dot(PP) pp_c_dot (PP)
#define pp_cxx_ampersand(PP) pp_c_ampersand (pp_c_base (PP)) #define pp_cxx_ampersand(PP) pp_c_ampersand (PP)
#define pp_cxx_star(PP) pp_c_star (pp_c_base (PP)) #define pp_cxx_star(PP) pp_c_star (PP)
#define pp_cxx_arrow(PP) pp_c_arrow (pp_c_base (PP)) #define pp_cxx_arrow(PP) pp_c_arrow (PP)
#define pp_cxx_semicolon(PP) pp_c_semicolon (pp_c_base (PP)) #define pp_cxx_semicolon(PP) pp_c_semicolon (PP)
#define pp_cxx_complement(PP) pp_c_complement (pp_c_base (PP)) #define pp_cxx_complement(PP) pp_c_complement (PP)
#define pp_cxx_ws_string(PP, I) pp_c_ws_string (pp_c_base (PP), I) #define pp_cxx_ws_string(PP, I) pp_c_ws_string (PP, I)
#define pp_cxx_identifier(PP, I) pp_c_identifier (pp_c_base (PP), I) #define pp_cxx_identifier(PP, I) pp_c_identifier (PP, I)
#define pp_cxx_tree_identifier(PP, T) \ #define pp_cxx_tree_identifier(PP, T) \
pp_c_tree_identifier (pp_c_base (PP), T) pp_c_tree_identifier (PP, T)
void pp_cxx_pretty_printer_init (cxx_pretty_printer *); 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 *);
......
...@@ -108,7 +108,7 @@ init_error (void) ...@@ -108,7 +108,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 (pp_base (cxx_pp), NULL, 0); pp_construct (cxx_pp, NULL, 0);
pp_cxx_pretty_printer_init (cxx_pp); pp_cxx_pretty_printer_init (cxx_pp);
} }
...@@ -654,7 +654,7 @@ dump_aggr_type (tree t, int flags) ...@@ -654,7 +654,7 @@ dump_aggr_type (tree t, int flags)
if (flags & TFF_CLASS_KEY_OR_ENUM) if (flags & TFF_CLASS_KEY_OR_ENUM)
pp_string (cxx_pp, M_("<anonymous>")); pp_string (cxx_pp, M_("<anonymous>"));
else else
pp_printf (pp_base (cxx_pp), M_("<anonymous %s>"), variety); pp_printf (cxx_pp, M_("<anonymous %s>"), variety);
} }
else if (LAMBDA_TYPE_P (t)) else if (LAMBDA_TYPE_P (t))
{ {
...@@ -706,8 +706,7 @@ dump_type_prefix (tree t, int flags) ...@@ -706,8 +706,7 @@ dump_type_prefix (tree t, int flags)
{ {
pp_cxx_whitespace (cxx_pp); pp_cxx_whitespace (cxx_pp);
pp_cxx_left_paren (cxx_pp); pp_cxx_left_paren (cxx_pp);
pp_c_attributes_display (pp_c_base (cxx_pp), pp_c_attributes_display (cxx_pp, TYPE_ATTRIBUTES (sub));
TYPE_ATTRIBUTES (sub));
} }
if (TYPE_PTR_P (t)) if (TYPE_PTR_P (t))
pp_star (cxx_pp); pp_star (cxx_pp);
...@@ -718,7 +717,7 @@ dump_type_prefix (tree t, int flags) ...@@ -718,7 +717,7 @@ dump_type_prefix (tree t, int flags)
else else
pp_ampersand (cxx_pp); pp_ampersand (cxx_pp);
} }
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (cxx_pp, t);
} }
break; break;
...@@ -736,7 +735,7 @@ dump_type_prefix (tree t, int flags) ...@@ -736,7 +735,7 @@ dump_type_prefix (tree t, int flags)
} }
pp_cxx_star (cxx_pp); pp_cxx_star (cxx_pp);
pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_cxx_cv_qualifier_seq (cxx_pp, t);
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
break; break;
/* This can be reached without a pointer when dealing with /* This can be reached without a pointer when dealing with
...@@ -782,7 +781,7 @@ dump_type_prefix (tree t, int flags) ...@@ -782,7 +781,7 @@ dump_type_prefix (tree t, int flags)
case FIXED_POINT_TYPE: case FIXED_POINT_TYPE:
case NULLPTR_TYPE: case NULLPTR_TYPE:
dump_type (t, flags); dump_type (t, flags);
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
break; break;
default: default:
...@@ -829,7 +828,7 @@ dump_type_suffix (tree t, int flags) ...@@ -829,7 +828,7 @@ dump_type_suffix (tree t, int flags)
anyway; they may in g++, but we'll just pretend otherwise. */ anyway; they may in g++, but we'll just pretend otherwise. */
dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS);
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
pp_cxx_cv_qualifiers (cxx_pp, type_memfn_quals (t)); pp_cxx_cv_qualifiers (cxx_pp, type_memfn_quals (t));
dump_ref_qualifier (t, flags); dump_ref_qualifier (t, flags);
dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags); dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags);
...@@ -918,7 +917,7 @@ dump_global_iord (tree t) ...@@ -918,7 +917,7 @@ dump_global_iord (tree t)
else else
gcc_unreachable (); gcc_unreachable ();
pp_printf (pp_base (cxx_pp), p, input_filename); pp_printf (cxx_pp, p, input_filename);
} }
static void static void
...@@ -1048,7 +1047,7 @@ dump_decl (tree t, int flags) ...@@ -1048,7 +1047,7 @@ dump_decl (tree t, int flags)
flags &= ~TFF_UNQUALIFIED_NAME; flags &= ~TFF_UNQUALIFIED_NAME;
if (DECL_NAME (t) == NULL_TREE) if (DECL_NAME (t) == NULL_TREE)
{ {
if (!(pp_c_base (cxx_pp)->flags & pp_c_flag_gnu_v3)) if (!(cxx_pp->flags & pp_c_flag_gnu_v3))
pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); pp_cxx_ws_string (cxx_pp, M_("{anonymous}"));
else else
pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)"));
...@@ -1457,14 +1456,14 @@ dump_function_decl (tree t, int flags) ...@@ -1457,14 +1456,14 @@ dump_function_decl (tree t, int flags)
if (TREE_CODE (fntype) == METHOD_TYPE) if (TREE_CODE (fntype) == METHOD_TYPE)
{ {
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype)); pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype));
dump_ref_qualifier (fntype, flags); dump_ref_qualifier (fntype, flags);
} }
if (flags & TFF_EXCEPTION_SPECIFICATION) if (flags & TFF_EXCEPTION_SPECIFICATION)
{ {
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
dump_exception_spec (exceptions, flags); dump_exception_spec (exceptions, flags);
} }
...@@ -1549,7 +1548,7 @@ dump_ref_qualifier (tree t, int flags ATTRIBUTE_UNUSED) ...@@ -1549,7 +1548,7 @@ dump_ref_qualifier (tree t, int flags ATTRIBUTE_UNUSED)
{ {
if (FUNCTION_REF_QUALIFIED (t)) if (FUNCTION_REF_QUALIFIED (t))
{ {
pp_base (cxx_pp)->padding = pp_before; cxx_pp->padding = pp_before;
if (FUNCTION_RVALUE_QUALIFIED (t)) if (FUNCTION_RVALUE_QUALIFIED (t))
pp_cxx_ws_string (cxx_pp, "&&"); pp_cxx_ws_string (cxx_pp, "&&");
else else
...@@ -2615,7 +2614,7 @@ static void ...@@ -2615,7 +2614,7 @@ static void
reinit_cxx_pp (void) reinit_cxx_pp (void)
{ {
pp_clear_output_area (cxx_pp); pp_clear_output_area (cxx_pp);
pp_base (cxx_pp)->padding = pp_none; cxx_pp->padding = pp_none;
pp_indentation (cxx_pp) = 0; pp_indentation (cxx_pp) = 0;
pp_needs_newline (cxx_pp) = false; pp_needs_newline (cxx_pp) = false;
cxx_pp->enclosing_scope = current_function_decl; cxx_pp->enclosing_scope = current_function_decl;
...@@ -2659,10 +2658,10 @@ decl_as_dwarf_string (tree decl, int flags) ...@@ -2659,10 +2658,10 @@ decl_as_dwarf_string (tree decl, int flags)
const char *name; const char *name;
/* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
here will be adequate to get the desired behaviour. */ here will be adequate to get the desired behaviour. */
pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; cxx_pp->flags |= pp_c_flag_gnu_v3;
name = decl_as_string (decl, flags); name = decl_as_string (decl, flags);
/* Subsequent calls to the pretty printer shouldn't use this style. */ /* Subsequent calls to the pretty printer shouldn't use this style. */
pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; cxx_pp->flags &= ~pp_c_flag_gnu_v3;
return name; return name;
} }
...@@ -2691,10 +2690,10 @@ lang_decl_dwarf_name (tree decl, int v, bool translate) ...@@ -2691,10 +2690,10 @@ lang_decl_dwarf_name (tree decl, int v, bool translate)
const char *name; const char *name;
/* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
here will be adequate to get the desired behaviour. */ here will be adequate to get the desired behaviour. */
pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; cxx_pp->flags |= pp_c_flag_gnu_v3;
name = lang_decl_name (decl, v, translate); name = lang_decl_name (decl, v, translate);
/* Subsequent calls to the pretty printer shouldn't use this style. */ /* Subsequent calls to the pretty printer shouldn't use this style. */
pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; cxx_pp->flags &= ~pp_c_flag_gnu_v3;
return name; return name;
} }
...@@ -2861,7 +2860,7 @@ type_to_string (tree typ, int verbose) ...@@ -2861,7 +2860,7 @@ type_to_string (tree typ, int verbose)
&& !uses_template_parms (typ)) && !uses_template_parms (typ))
{ {
int aka_start; char *p; int aka_start; char *p;
struct obstack *ob = pp_base (cxx_pp)->buffer->obstack; struct obstack *ob = cxx_pp->buffer->obstack;
/* Remember the end of the initial dump. */ /* Remember the end of the initial dump. */
int len = obstack_object_size (ob); int len = obstack_object_size (ob);
tree aka = strip_typedefs (typ); tree aka = strip_typedefs (typ);
...@@ -2943,7 +2942,7 @@ static const char * ...@@ -2943,7 +2942,7 @@ static const char *
cv_to_string (tree p, int v) cv_to_string (tree p, int v)
{ {
reinit_cxx_pp (); reinit_cxx_pp ();
pp_base (cxx_pp)->padding = v ? pp_before : pp_none; cxx_pp->padding = v ? pp_before : pp_none;
pp_cxx_cv_qualifier_seq (cxx_pp, p); pp_cxx_cv_qualifier_seq (cxx_pp, p);
return pp_formatted_text (cxx_pp); return pp_formatted_text (cxx_pp);
} }
...@@ -2954,7 +2953,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file, ...@@ -2954,7 +2953,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file,
diagnostic_info *diagnostic) diagnostic_info *diagnostic)
{ {
lhd_print_error_function (context, file, diagnostic); lhd_print_error_function (context, file, diagnostic);
pp_base_set_prefix (context->printer, file); pp_set_prefix (context->printer, file);
maybe_print_instantiation_context (context); maybe_print_instantiation_context (context);
} }
...@@ -2966,7 +2965,7 @@ cp_diagnostic_starter (diagnostic_context *context, ...@@ -2966,7 +2965,7 @@ cp_diagnostic_starter (diagnostic_context *context,
cp_print_error_function (context, diagnostic); cp_print_error_function (context, diagnostic);
maybe_print_instantiation_context (context); maybe_print_instantiation_context (context);
maybe_print_constexpr_context (context); maybe_print_constexpr_context (context);
pp_base_set_prefix (context->printer, diagnostic_build_prefix (context, pp_set_prefix (context->printer, diagnostic_build_prefix (context,
diagnostic)); diagnostic));
} }
...@@ -2975,7 +2974,7 @@ cp_diagnostic_finalizer (diagnostic_context *context, ...@@ -2975,7 +2974,7 @@ cp_diagnostic_finalizer (diagnostic_context *context,
diagnostic_info *diagnostic) diagnostic_info *diagnostic)
{ {
virt_loc_aware_diagnostic_finalizer (context, diagnostic); virt_loc_aware_diagnostic_finalizer (context, diagnostic);
pp_base_destroy_prefix (context->printer); pp_destroy_prefix (context->printer);
} }
/* Print current function onto BUFFER, in the process of reporting /* Print current function onto BUFFER, in the process of reporting
...@@ -2996,10 +2995,10 @@ cp_print_error_function (diagnostic_context *context, ...@@ -2996,10 +2995,10 @@ cp_print_error_function (diagnostic_context *context,
char *new_prefix = (file && abstract_origin == NULL) char *new_prefix = (file && abstract_origin == NULL)
? file_name_as_prefix (context, file) : NULL; ? file_name_as_prefix (context, file) : NULL;
pp_base_set_prefix (context->printer, new_prefix); pp_set_prefix (context->printer, new_prefix);
if (current_function_decl == NULL) if (current_function_decl == NULL)
pp_base_string (context->printer, _("At global scope:")); pp_string (context->printer, _("At global scope:"));
else else
{ {
tree fndecl, ao; tree fndecl, ao;
...@@ -3062,8 +3061,8 @@ cp_print_error_function (diagnostic_context *context, ...@@ -3062,8 +3061,8 @@ cp_print_error_function (diagnostic_context *context,
if (fndecl) if (fndecl)
{ {
expanded_location s = expand_location (*locus); expanded_location s = expand_location (*locus);
pp_base_character (context->printer, ','); pp_character (context->printer, ',');
pp_base_newline (context->printer); pp_newline (context->printer);
if (s.file != NULL) if (s.file != NULL)
{ {
if (context->show_column && s.column != 0) if (context->show_column && s.column != 0)
...@@ -3083,12 +3082,12 @@ cp_print_error_function (diagnostic_context *context, ...@@ -3083,12 +3082,12 @@ cp_print_error_function (diagnostic_context *context,
cxx_printable_name_translate (fndecl, 2)); cxx_printable_name_translate (fndecl, 2));
} }
} }
pp_base_character (context->printer, ':'); pp_character (context->printer, ':');
} }
pp_base_newline (context->printer); pp_newline (context->printer);
diagnostic_set_last_function (context, diagnostic); diagnostic_set_last_function (context, diagnostic);
pp_base_destroy_prefix (context->printer); pp_destroy_prefix (context->printer);
context->printer->prefix = old_prefix; context->printer->prefix = old_prefix;
} }
} }
...@@ -3267,7 +3266,7 @@ print_instantiation_partial_context (diagnostic_context *context, ...@@ -3267,7 +3266,7 @@ print_instantiation_partial_context (diagnostic_context *context,
} }
print_instantiation_partial_context_line (context, NULL, loc, print_instantiation_partial_context_line (context, NULL, loc,
/*recursive_p=*/false); /*recursive_p=*/false);
pp_base_newline (context->printer); pp_newline (context->printer);
} }
/* Called from cp_thing to print the template context for an error. */ /* Called from cp_thing to print the template context for an error. */
...@@ -3287,7 +3286,7 @@ print_instantiation_context (void) ...@@ -3287,7 +3286,7 @@ print_instantiation_context (void)
{ {
print_instantiation_partial_context print_instantiation_partial_context
(global_dc, current_instantiation (), input_location); (global_dc, current_instantiation (), input_location);
pp_base_newline (global_dc->printer); pp_newline (global_dc->printer);
diagnostic_flush_buffer (global_dc); diagnostic_flush_buffer (global_dc);
} }
...@@ -3312,7 +3311,7 @@ maybe_print_constexpr_context (diagnostic_context *context) ...@@ -3312,7 +3311,7 @@ maybe_print_constexpr_context (diagnostic_context *context)
pp_verbatim (context->printer, pp_verbatim (context->printer,
_("%r%s:%d:%R in constexpr expansion of %qs"), _("%r%s:%d:%R in constexpr expansion of %qs"),
"locus", xloc.file, xloc.line, s); "locus", xloc.file, xloc.line, s);
pp_base_newline (context->printer); pp_newline (context->printer);
} }
} }
...@@ -3384,7 +3383,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, ...@@ -3384,7 +3383,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
return false; return false;
} }
pp_base_string (pp, result); pp_string (pp, result);
if (set_locus && t != NULL) if (set_locus && t != NULL)
*text->locus = location_of (t); *text->locus = location_of (t);
return true; return true;
......
...@@ -211,7 +211,7 @@ diagnostic_inhibit_notes (diagnostic_context * context) ...@@ -211,7 +211,7 @@ diagnostic_inhibit_notes (diagnostic_context * context)
Zero means don't wrap lines. */ Zero means don't wrap lines. */
#define diagnostic_line_cutoff(DC) ((DC)->printer->wrapping.line_cutoff) #define diagnostic_line_cutoff(DC) ((DC)->printer->wrapping.line_cutoff)
#define diagnostic_flush_buffer(DC) pp_base_flush ((DC)->printer) #define diagnostic_flush_buffer(DC) pp_flush ((DC)->printer)
/* True if the last module or file in which a diagnostic was reported is /* True if the last module or file in which a diagnostic was reported is
different from the current one. */ different from the current one. */
......
...@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
/* 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_base (PP)->buffer->obstack)) ((const char *) obstack_base ((PP)->buffer->obstack))
/* Format an integer given by va_arg (ARG, type-specifier T) where /* Format an integer given by va_arg (ARG, type-specifier T) where
type-specifier is a precision modifier as indicated by PREC. F is type-specifier is a precision modifier as indicated by PREC. F is
...@@ -207,7 +207,7 @@ pp_append_r (pretty_printer *pp, const char *start, int length) ...@@ -207,7 +207,7 @@ pp_append_r (pretty_printer *pp, const char *start, int length)
the column position to the current indentation level, assuming that a the column position to the current indentation level, assuming that a
newline has just been written to the buffer. */ newline has just been written to the buffer. */
void void
pp_base_indent (pretty_printer *pp) pp_indent (pretty_printer *pp)
{ {
int n = pp_indentation (pp); int n = pp_indentation (pp);
int i; int i;
...@@ -252,10 +252,10 @@ pp_base_indent (pretty_printer *pp) ...@@ -252,10 +252,10 @@ pp_base_indent (pretty_printer *pp)
/* Formatting phases 1 and 2: render TEXT->format_spec plus /* Formatting phases 1 and 2: render TEXT->format_spec plus
TEXT->args_ptr into a series of chunks in PP->buffer->args[]. TEXT->args_ptr into a series of chunks in PP->buffer->args[].
Phase 3 is in pp_base_format_text. */ Phase 3 is in pp_format_text. */
void void
pp_base_format (pretty_printer *pp, text_info *text) pp_format (pretty_printer *pp, text_info *text)
{ {
output_buffer *buffer = pp->buffer; output_buffer *buffer = pp->buffer;
const char *p; const char *p;
...@@ -617,7 +617,7 @@ pp_base_format (pretty_printer *pp, text_info *text) ...@@ -617,7 +617,7 @@ pp_base_format (pretty_printer *pp, text_info *text)
/* Format of a message pointed to by TEXT. */ /* Format of a message pointed to by TEXT. */
void void
pp_base_output_formatted_text (pretty_printer *pp) pp_output_formatted_text (pretty_printer *pp)
{ {
unsigned int chunk; unsigned int chunk;
output_buffer *buffer = pp_buffer (pp); output_buffer *buffer = pp_buffer (pp);
...@@ -627,7 +627,7 @@ pp_base_output_formatted_text (pretty_printer *pp) ...@@ -627,7 +627,7 @@ pp_base_output_formatted_text (pretty_printer *pp)
gcc_assert (buffer->obstack == &buffer->formatted_obstack); gcc_assert (buffer->obstack == &buffer->formatted_obstack);
gcc_assert (buffer->line_length == 0); gcc_assert (buffer->line_length == 0);
/* This is a third phase, first 2 phases done in pp_base_format_args. /* This is a third phase, first 2 phases done in pp_format_args.
Now we actually print it. */ Now we actually print it. */
for (chunk = 0; args[chunk]; chunk++) for (chunk = 0; args[chunk]; chunk++)
pp_string (pp, args[chunk]); pp_string (pp, args[chunk]);
...@@ -641,7 +641,7 @@ pp_base_output_formatted_text (pretty_printer *pp) ...@@ -641,7 +641,7 @@ pp_base_output_formatted_text (pretty_printer *pp)
/* Helper subroutine of output_verbatim and verbatim. Do the appropriate /* Helper subroutine of output_verbatim and verbatim. Do the appropriate
settings needed by BUFFER for a verbatim formatting. */ settings needed by BUFFER for a verbatim formatting. */
void void
pp_base_format_verbatim (pretty_printer *pp, text_info *text) pp_format_verbatim (pretty_printer *pp, text_info *text)
{ {
/* Set verbatim mode. */ /* Set verbatim mode. */
pp_wrapping_mode_t oldmode = pp_set_verbatim_wrapping (pp); pp_wrapping_mode_t oldmode = pp_set_verbatim_wrapping (pp);
...@@ -656,7 +656,7 @@ pp_base_format_verbatim (pretty_printer *pp, text_info *text) ...@@ -656,7 +656,7 @@ pp_base_format_verbatim (pretty_printer *pp, text_info *text)
/* Flush the content of BUFFER onto the attached stream. */ /* Flush the content of BUFFER onto the attached stream. */
void void
pp_base_flush (pretty_printer *pp) pp_flush (pretty_printer *pp)
{ {
pp_write_text_to_stream (pp); pp_write_text_to_stream (pp);
pp_clear_state (pp); pp_clear_state (pp);
...@@ -667,7 +667,7 @@ pp_base_flush (pretty_printer *pp) ...@@ -667,7 +667,7 @@ pp_base_flush (pretty_printer *pp)
output in line-wrapping mode. A LENGTH value 0 suppresses output in line-wrapping mode. A LENGTH value 0 suppresses
line-wrapping. */ line-wrapping. */
void void
pp_base_set_line_maximum_length (pretty_printer *pp, int length) pp_set_line_maximum_length (pretty_printer *pp, int length)
{ {
pp_line_cutoff (pp) = length; pp_line_cutoff (pp) = length;
pp_set_real_maximum_length (pp); pp_set_real_maximum_length (pp);
...@@ -675,7 +675,7 @@ pp_base_set_line_maximum_length (pretty_printer *pp, int length) ...@@ -675,7 +675,7 @@ pp_base_set_line_maximum_length (pretty_printer *pp, int length)
/* Clear PRETTY-PRINTER output area text info. */ /* Clear PRETTY-PRINTER output area text info. */
void void
pp_base_clear_output_area (pretty_printer *pp) pp_clear_output_area (pretty_printer *pp)
{ {
obstack_free (pp->buffer->obstack, obstack_base (pp->buffer->obstack)); obstack_free (pp->buffer->obstack, obstack_base (pp->buffer->obstack));
pp->buffer->line_length = 0; pp->buffer->line_length = 0;
...@@ -683,7 +683,7 @@ pp_base_clear_output_area (pretty_printer *pp) ...@@ -683,7 +683,7 @@ pp_base_clear_output_area (pretty_printer *pp)
/* Set PREFIX for PRETTY-PRINTER. */ /* Set PREFIX for PRETTY-PRINTER. */
void void
pp_base_set_prefix (pretty_printer *pp, const char *prefix) pp_set_prefix (pretty_printer *pp, const char *prefix)
{ {
pp->prefix = prefix; pp->prefix = prefix;
pp_set_real_maximum_length (pp); pp_set_real_maximum_length (pp);
...@@ -693,7 +693,7 @@ pp_base_set_prefix (pretty_printer *pp, const char *prefix) ...@@ -693,7 +693,7 @@ pp_base_set_prefix (pretty_printer *pp, const char *prefix)
/* Free PRETTY-PRINTER's prefix, a previously malloc()'d string. */ /* Free PRETTY-PRINTER's prefix, a previously malloc()'d string. */
void void
pp_base_destroy_prefix (pretty_printer *pp) pp_destroy_prefix (pretty_printer *pp)
{ {
if (pp->prefix != NULL) if (pp->prefix != NULL)
{ {
...@@ -704,7 +704,7 @@ pp_base_destroy_prefix (pretty_printer *pp) ...@@ -704,7 +704,7 @@ pp_base_destroy_prefix (pretty_printer *pp)
/* Write out PRETTY-PRINTER's prefix. */ /* Write out PRETTY-PRINTER's prefix. */
void void
pp_base_emit_prefix (pretty_printer *pp) pp_emit_prefix (pretty_printer *pp)
{ {
if (pp->prefix != NULL) if (pp->prefix != NULL)
{ {
...@@ -717,7 +717,7 @@ pp_base_emit_prefix (pretty_printer *pp) ...@@ -717,7 +717,7 @@ pp_base_emit_prefix (pretty_printer *pp)
case DIAGNOSTICS_SHOW_PREFIX_ONCE: case DIAGNOSTICS_SHOW_PREFIX_ONCE:
if (pp->emitted_prefix) if (pp->emitted_prefix)
{ {
pp_base_indent (pp); pp_indent (pp);
break; break;
} }
pp_indentation (pp) += 3; pp_indentation (pp) += 3;
...@@ -757,7 +757,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length) ...@@ -757,7 +757,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
whitespace if appropriate. The caller must ensure that it is whitespace if appropriate. The caller must ensure that it is
safe to do so. */ safe to do so. */
void void
pp_base_append_text (pretty_printer *pp, const char *start, const char *end) pp_append_text (pretty_printer *pp, const char *start, const char *end)
{ {
/* Emit prefix and skip whitespace if we're starting a new line. */ /* Emit prefix and skip whitespace if we're starting a new line. */
if (pp->buffer->line_length == 0) if (pp->buffer->line_length == 0)
...@@ -773,7 +773,7 @@ pp_base_append_text (pretty_printer *pp, const char *start, const char *end) ...@@ -773,7 +773,7 @@ pp_base_append_text (pretty_printer *pp, const char *start, const char *end)
/* Finishes constructing a NULL-terminated character string representing /* Finishes constructing a NULL-terminated character string representing
the PRETTY-PRINTED text. */ the PRETTY-PRINTED text. */
const char * const char *
pp_base_formatted_text (pretty_printer *pp) pp_formatted_text (pretty_printer *pp)
{ {
obstack_1grow (pp->buffer->obstack, '\0'); obstack_1grow (pp->buffer->obstack, '\0');
return pp_formatted_text_data (pp); return pp_formatted_text_data (pp);
...@@ -782,7 +782,7 @@ pp_base_formatted_text (pretty_printer *pp) ...@@ -782,7 +782,7 @@ pp_base_formatted_text (pretty_printer *pp)
/* Return a pointer to the last character emitted in PRETTY-PRINTER's /* Return a pointer to the last character emitted in PRETTY-PRINTER's
output area. A NULL pointer means no character available. */ output area. A NULL pointer means no character available. */
const char * const char *
pp_base_last_position_in_text (const pretty_printer *pp) pp_last_position_in_text (const pretty_printer *pp)
{ {
const char *p = NULL; const char *p = NULL;
struct obstack *text = pp->buffer->obstack; struct obstack *text = pp->buffer->obstack;
...@@ -795,7 +795,7 @@ pp_base_last_position_in_text (const pretty_printer *pp) ...@@ -795,7 +795,7 @@ pp_base_last_position_in_text (const pretty_printer *pp)
/* Return the amount of characters PRETTY-PRINTER can accept to /* Return the amount of characters PRETTY-PRINTER can accept to
make a full line. Meaningful only in line-wrapping mode. */ make a full line. Meaningful only in line-wrapping mode. */
int int
pp_base_remaining_character_count_for_line (pretty_printer *pp) pp_remaining_character_count_for_line (pretty_printer *pp)
{ {
return pp->maximum_length - pp->buffer->line_length; return pp->maximum_length - pp->buffer->line_length;
} }
...@@ -839,7 +839,7 @@ pp_verbatim (pretty_printer *pp, const char *msg, ...) ...@@ -839,7 +839,7 @@ pp_verbatim (pretty_printer *pp, const char *msg, ...)
/* Have PRETTY-PRINTER start a new line. */ /* Have PRETTY-PRINTER start a new line. */
void void
pp_base_newline (pretty_printer *pp) pp_newline (pretty_printer *pp)
{ {
obstack_1grow (pp->buffer->obstack, '\n'); obstack_1grow (pp->buffer->obstack, '\n');
pp_needs_newline (pp) = false; pp_needs_newline (pp) = false;
...@@ -848,7 +848,7 @@ pp_base_newline (pretty_printer *pp) ...@@ -848,7 +848,7 @@ pp_base_newline (pretty_printer *pp)
/* Have PRETTY-PRINTER add a CHARACTER. */ /* Have PRETTY-PRINTER add a CHARACTER. */
void void
pp_base_character (pretty_printer *pp, int c) pp_character (pretty_printer *pp, int c)
{ {
if (pp_is_wrapping_line (pp) if (pp_is_wrapping_line (pp)
&& pp_remaining_character_count_for_line (pp) <= 0) && pp_remaining_character_count_for_line (pp) <= 0)
...@@ -864,7 +864,7 @@ pp_base_character (pretty_printer *pp, int c) ...@@ -864,7 +864,7 @@ pp_base_character (pretty_printer *pp, int c)
/* Append a STRING to the output area of PRETTY-PRINTER; the STRING may /* Append a STRING to the output area of PRETTY-PRINTER; the STRING may
be line-wrapped if in appropriate mode. */ be line-wrapped if in appropriate mode. */
void void
pp_base_string (pretty_printer *pp, const char *str) pp_string (pretty_printer *pp, const char *str)
{ {
pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0)); pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0));
} }
...@@ -872,12 +872,12 @@ pp_base_string (pretty_printer *pp, const char *str) ...@@ -872,12 +872,12 @@ pp_base_string (pretty_printer *pp, const char *str)
/* Maybe print out a whitespace if needed. */ /* Maybe print out a whitespace if needed. */
void void
pp_base_maybe_space (pretty_printer *pp) pp_maybe_space (pretty_printer *pp)
{ {
if (pp_base (pp)->padding != pp_none) if (pp->padding != pp_none)
{ {
pp_space (pp); pp_space (pp);
pp_base (pp)->padding = pp_none; pp->padding = pp_none;
} }
} }
......
...@@ -29,30 +29,30 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,30 +29,30 @@ along with GCC; see the file COPYING3. If not see
/* The type of a text to be formatted according a format specification /* The type of a text to be formatted according a format specification
along with a list of things. */ along with a list of things. */
typedef struct struct text_info
{ {
const char *format_spec; const char *format_spec;
va_list *args_ptr; va_list *args_ptr;
int err_no; /* for %m */ int err_no; /* for %m */
location_t *locus; location_t *locus;
void **x_data; void **x_data;
} text_info; };
/* How often diagnostics are prefixed by their locations: /* How often diagnostics are prefixed by their locations:
o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported; o DIAGNOSTICS_SHOW_PREFIX_NEVER: never - not yet supported;
o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once; o DIAGNOSTICS_SHOW_PREFIX_ONCE: emit only once;
o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical o DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE: emit each time a physical
line is started. */ line is started. */
typedef enum enum diagnostic_prefixing_rule_t
{ {
DIAGNOSTICS_SHOW_PREFIX_ONCE = 0x0, DIAGNOSTICS_SHOW_PREFIX_ONCE = 0x0,
DIAGNOSTICS_SHOW_PREFIX_NEVER = 0x1, DIAGNOSTICS_SHOW_PREFIX_NEVER = 0x1,
DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2 DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE = 0x2
} diagnostic_prefixing_rule_t; };
/* The chunk_info data structure forms a stack of the results from the /* The chunk_info data structure forms a stack of the results from the
first phase of formatting (pp_base_format) which have not yet been first phase of formatting (pp_format) which have not yet been
output (pp_base_output_formatted_text). A stack is necessary because output (pp_output_formatted_text). A stack is necessary because
the diagnostic starter may decide to generate its own output by way the diagnostic starter may decide to generate its own output by way
of the formatter. */ of the formatter. */
struct chunk_info struct chunk_info
...@@ -71,7 +71,7 @@ struct chunk_info ...@@ -71,7 +71,7 @@ struct chunk_info
/* The output buffer datatype. This is best seen as an abstract datatype /* The output buffer datatype. This is best seen as an abstract datatype
whose fields should not be accessed directly by clients. */ whose fields should not be accessed directly by clients. */
typedef struct struct output_buffer
{ {
/* Obstack where the text is built up. */ /* Obstack where the text is built up. */
struct obstack formatted_obstack; struct obstack formatted_obstack;
...@@ -96,19 +96,19 @@ typedef struct ...@@ -96,19 +96,19 @@ typedef struct
/* This must be large enough to hold any printed integer or /* This must be large enough to hold any printed integer or
floating-point value. */ floating-point value. */
char digit_buffer[128]; char digit_buffer[128];
} output_buffer; };
/* The type of pretty-printer flags passed to clients. */ /* The type of pretty-printer flags passed to clients. */
typedef unsigned int pp_flags; typedef unsigned int pp_flags;
typedef enum enum pp_padding
{ {
pp_none, pp_before, pp_after pp_none, pp_before, pp_after
} pp_padding; };
/* Structure for switching in and out of verbatim mode in a convenient /* Structure for switching in and out of verbatim mode in a convenient
manner. */ manner. */
typedef struct struct pp_wrapping_mode_t
{ {
/* Current prefixing rule. */ /* Current prefixing rule. */
diagnostic_prefixing_rule_t rule; diagnostic_prefixing_rule_t rule;
...@@ -116,17 +116,17 @@ typedef struct ...@@ -116,17 +116,17 @@ typedef struct
/* The ideal upper bound of number of characters per line, as suggested /* The ideal upper bound of number of characters per line, as suggested
by front-end. */ by front-end. */
int line_cutoff; int line_cutoff;
} pp_wrapping_mode_t; };
/* Maximum characters per line in automatic line wrapping mode. /* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */ Zero means don't wrap lines. */
#define pp_line_cutoff(PP) pp_base (PP)->wrapping.line_cutoff #define pp_line_cutoff(PP) (PP)->wrapping.line_cutoff
/* Prefixing rule used in formatting a diagnostic message. */ /* Prefixing rule used in formatting a diagnostic message. */
#define pp_prefixing_rule(PP) pp_base (PP)->wrapping.rule #define pp_prefixing_rule(PP) (PP)->wrapping.rule
/* Get or set the wrapping mode as a single entity. */ /* Get or set the wrapping mode as a single entity. */
#define pp_wrapping_mode(PP) pp_base (PP)->wrapping #define pp_wrapping_mode(PP) (PP)->wrapping
/* The type of a hook that formats client-specific data onto a pretty_pinter. /* The type of a hook that formats client-specific data onto a pretty_pinter.
A client-supplied formatter returns true if everything goes well, A client-supplied formatter returns true if everything goes well,
...@@ -135,24 +135,24 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, ...@@ -135,24 +135,24 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
int, bool, bool, bool); int, bool, bool, bool);
/* Client supplied function used to decode formats. */ /* Client supplied function used to decode formats. */
#define pp_format_decoder(PP) pp_base (PP)->format_decoder #define pp_format_decoder(PP) (PP)->format_decoder
/* TRUE if a newline character needs to be added before further /* TRUE if a newline character needs to be added before further
formatting. */ formatting. */
#define pp_needs_newline(PP) pp_base (PP)->need_newline #define pp_needs_newline(PP) (PP)->need_newline
/* True if PRETTY-PRINTER is in line-wrapping mode. */ /* True if PRETTY-PRINTER is in line-wrapping mode. */
#define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0) #define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0)
/* The amount of whitespace to be emitted when starting a new line. */ /* The amount of whitespace to be emitted when starting a new line. */
#define pp_indentation(PP) pp_base (PP)->indent_skip #define pp_indentation(PP) (PP)->indent_skip
/* True if identifiers are translated to the locale character set on /* True if identifiers are translated to the locale character set on
output. */ output. */
#define pp_translate_identifiers(PP) pp_base (PP)->translate_identifiers #define pp_translate_identifiers(PP) (PP)->translate_identifiers
/* True if colors should be shown. */ /* True if colors should be shown. */
#define pp_show_color(PP) pp_base (PP)->show_color #define pp_show_color(PP) (PP)->show_color
/* 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
...@@ -202,33 +202,8 @@ struct pretty_print_info ...@@ -202,33 +202,8 @@ struct pretty_print_info
bool show_color; bool show_color;
}; };
#define pp_set_line_maximum_length(PP, L) \
pp_base_set_line_maximum_length (pp_base (PP), L)
#define pp_set_prefix(PP, P) pp_base_set_prefix (pp_base (PP), P)
#define pp_get_prefix(PP) pp_base_get_prefix (pp_base (PP))
static inline const char * static inline const char *
pp_base_get_prefix (const pretty_printer *pp) { return pp->prefix; } pp_get_prefix (const pretty_printer *pp) { return pp->prefix; }
#define pp_destroy_prefix(PP) pp_base_destroy_prefix (pp_base (PP))
#define pp_remaining_character_count_for_line(PP) \
pp_base_remaining_character_count_for_line (pp_base (PP))
#define pp_clear_output_area(PP) \
pp_base_clear_output_area (pp_base (PP))
#define pp_formatted_text(PP) pp_base_formatted_text (pp_base (PP))
#define pp_last_position_in_text(PP) \
pp_base_last_position_in_text (pp_base (PP))
#define pp_emit_prefix(PP) pp_base_emit_prefix (pp_base (PP))
#define pp_append_text(PP, B, E) \
pp_base_append_text (pp_base (PP), B, E)
#define pp_flush(PP) pp_base_flush (pp_base (PP))
#define pp_format(PP, TI) pp_base_format (pp_base (PP), TI)
#define pp_output_formatted_text(PP) \
pp_base_output_formatted_text (pp_base (PP))
#define pp_format_verbatim(PP, TI) \
pp_base_format_verbatim (pp_base (PP), TI)
#define pp_character(PP, C) pp_base_character (pp_base (PP), C)
#define pp_string(PP, S) pp_base_string (pp_base (PP), S)
#define pp_newline(PP) pp_base_newline (pp_base (PP))
#define pp_space(PP) pp_character (PP, ' ') #define pp_space(PP) pp_character (PP, ' ')
#define pp_left_paren(PP) pp_character (PP, '(') #define pp_left_paren(PP) pp_character (PP, '(')
...@@ -275,12 +250,11 @@ pp_base_get_prefix (const pretty_printer *pp) { return pp->prefix; } ...@@ -275,12 +250,11 @@ pp_base_get_prefix (const pretty_printer *pp) { return pp->prefix; }
do { \ do { \
pp_indentation (PP) += N; \ pp_indentation (PP) += N; \
pp_newline (PP); \ pp_newline (PP); \
pp_base_indent (pp_base (PP)); \ pp_indent (PP); \
pp_needs_newline (PP) = false; \ pp_needs_newline (PP) = false; \
} while (0) } while (0)
#define pp_maybe_newline_and_indent(PP, N) \ #define pp_maybe_newline_and_indent(PP, N) \
if (pp_needs_newline (PP)) pp_newline_and_indent (PP, N) if (pp_needs_newline (PP)) pp_newline_and_indent (PP, N)
#define pp_maybe_space(PP) pp_base_maybe_space (pp_base (PP))
#define pp_separate_with(PP, C) \ #define pp_separate_with(PP, C) \
do { \ do { \
pp_character (PP, C); \ pp_character (PP, C); \
...@@ -307,21 +281,18 @@ pp_base_get_prefix (const pretty_printer *pp) { return pp->prefix; } ...@@ -307,21 +281,18 @@ pp_base_get_prefix (const pretty_printer *pp) { return pp->prefix; }
: (ID))) : (ID)))
#define pp_buffer(PP) pp_base (PP)->buffer #define pp_buffer(PP) (PP)->buffer
/* Clients that directly derive from pretty_printer need to override
this macro to return a pointer to the base pretty_printer structure. */
#define pp_base(PP) (PP)
extern void pp_construct (pretty_printer *, const char *, int); extern void pp_construct (pretty_printer *, const char *, int);
extern void pp_base_set_line_maximum_length (pretty_printer *, int); extern void pp_set_line_maximum_length (pretty_printer *, int);
extern void pp_base_set_prefix (pretty_printer *, const char *); extern void pp_set_prefix (pretty_printer *, const char *);
extern void pp_base_destroy_prefix (pretty_printer *); extern void pp_destroy_prefix (pretty_printer *);
extern int pp_base_remaining_character_count_for_line (pretty_printer *); extern int pp_remaining_character_count_for_line (pretty_printer *);
extern void pp_base_clear_output_area (pretty_printer *); extern void pp_clear_output_area (pretty_printer *);
extern const char *pp_base_formatted_text (pretty_printer *); extern const char *pp_formatted_text (pretty_printer *);
extern const char *pp_base_last_position_in_text (const pretty_printer *); extern const char *pp_last_position_in_text (const pretty_printer *);
extern void pp_base_emit_prefix (pretty_printer *); extern void pp_emit_prefix (pretty_printer *);
extern void pp_base_append_text (pretty_printer *, const char *, const char *); extern void pp_append_text (pretty_printer *, const char *, const char *);
/* If we haven't already defined a front-end-specific diagnostics /* If we haven't already defined a front-end-specific diagnostics
style, use the generic one. */ style, use the generic one. */
...@@ -343,18 +314,18 @@ extern void pp_printf (pretty_printer *, const char *, ...) ...@@ -343,18 +314,18 @@ extern void pp_printf (pretty_printer *, const char *, ...)
extern void pp_verbatim (pretty_printer *, const char *, ...) extern void pp_verbatim (pretty_printer *, const char *, ...)
ATTRIBUTE_GCC_PPDIAG(2,3); ATTRIBUTE_GCC_PPDIAG(2,3);
extern void pp_base_flush (pretty_printer *); extern void pp_flush (pretty_printer *);
extern void pp_base_format (pretty_printer *, text_info *); extern void pp_format (pretty_printer *, text_info *);
extern void pp_base_output_formatted_text (pretty_printer *); extern void pp_output_formatted_text (pretty_printer *);
extern void pp_base_format_verbatim (pretty_printer *, text_info *); extern void pp_format_verbatim (pretty_printer *, text_info *);
extern void pp_base_indent (pretty_printer *); extern void pp_indent (pretty_printer *);
extern void pp_base_newline (pretty_printer *); extern void pp_newline (pretty_printer *);
extern void pp_base_character (pretty_printer *, int); extern void pp_character (pretty_printer *, int);
extern void pp_base_string (pretty_printer *, const char *); extern void pp_string (pretty_printer *, const char *);
extern void pp_write_text_to_stream (pretty_printer *); extern void pp_write_text_to_stream (pretty_printer *);
extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool); extern void pp_write_text_as_dot_label_to_stream (pretty_printer *, bool);
extern void pp_base_maybe_space (pretty_printer *); extern void pp_maybe_space (pretty_printer *);
/* Switch into verbatim mode and return the old mode. */ /* Switch into verbatim mode and return the old mode. */
static inline pp_wrapping_mode_t static inline pp_wrapping_mode_t
...@@ -365,7 +336,7 @@ pp_set_verbatim_wrapping_ (pretty_printer *pp) ...@@ -365,7 +336,7 @@ pp_set_verbatim_wrapping_ (pretty_printer *pp)
pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_NEVER; pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
return oldmode; return oldmode;
} }
#define pp_set_verbatim_wrapping(PP) pp_set_verbatim_wrapping_ (pp_base (PP)) #define pp_set_verbatim_wrapping(PP) pp_set_verbatim_wrapping_ (PP)
extern const char *identifier_to_locale (const char *); extern const char *identifier_to_locale (const char *);
extern void *(*identifier_to_locale_alloc) (size_t); extern void *(*identifier_to_locale_alloc) (size_t);
......
...@@ -859,7 +859,7 @@ str_pattern_slim (const_rtx x) ...@@ -859,7 +859,7 @@ str_pattern_slim (const_rtx x)
{ {
pretty_printer *pp = init_rtl_slim_pretty_print (NULL); pretty_printer *pp = init_rtl_slim_pretty_print (NULL);
print_pattern (pp, x, 0); print_pattern (pp, x, 0);
return pp_base_formatted_text (pp); return pp_formatted_text (pp);
} }
/* Emit a slim dump of X (an insn) to stderr. */ /* Emit a slim dump of X (an insn) to stderr. */
......
...@@ -190,7 +190,7 @@ mf_varname_tree (tree decl) ...@@ -190,7 +190,7 @@ mf_varname_tree (tree decl)
} }
/* Return the lot as a new STRING_CST. */ /* Return the lot as a new STRING_CST. */
buf_contents = pp_base_formatted_text (buf); buf_contents = pp_formatted_text (buf);
result = mf_build_string (buf_contents); result = mf_build_string (buf_contents);
pp_clear_output_area (buf); pp_clear_output_area (buf);
......
...@@ -3112,7 +3112,7 @@ percent_K_format (text_info *text) ...@@ -3112,7 +3112,7 @@ percent_K_format (text_info *text)
/* Print the identifier ID to PRETTY-PRINTER. */ /* Print the identifier ID to PRETTY-PRINTER. */
void void
pp_base_tree_identifier (pretty_printer *pp, tree id) pp_tree_identifier (pretty_printer *pp, tree id)
{ {
if (pp_translate_identifiers (pp)) if (pp_translate_identifiers (pp))
{ {
......
...@@ -24,16 +24,13 @@ along with GCC; see the file COPYING3. If not see ...@@ -24,16 +24,13 @@ along with GCC; see the file COPYING3. If not see
#include "pretty-print.h" #include "pretty-print.h"
#define pp_tree_identifier(PP, T) \
pp_base_tree_identifier (pp_base (PP), T)
#define pp_unsupported_tree(PP, T) \ #define pp_unsupported_tree(PP, T) \
pp_verbatim (pp_base (PP), "#%qs not supported by %s#", \ pp_verbatim (PP, "#%qs not supported by %s#", \
tree_code_name[(int) TREE_CODE (T)], __FUNCTION__) tree_code_name[(int) TREE_CODE (T)], __FUNCTION__)
#define pp_ti_abstract_origin(TI) ((tree *) (TI)->x_data) #define pp_ti_abstract_origin(TI) ((tree *) (TI)->x_data)
extern void pp_base_tree_identifier (pretty_printer *, tree); extern void pp_tree_identifier (pretty_printer *, tree);
/* In tree-pretty-print.c */ /* In tree-pretty-print.c */
extern void print_declaration (pretty_printer *, tree, int, int); extern void print_declaration (pretty_printer *, tree, int, int);
......
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