summaryrefslogtreecommitdiff
path: root/gcc/pretty-print.c
diff options
context:
space:
mode:
authorgdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-22 10:14:46 +0000
committergdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-22 10:14:46 +0000
commiteed6bc214df1f3b9b1b68c871d4d8ff106ca19f4 (patch)
tree022ef428c3c313c44d9026f48348fe881e59ba87 /gcc/pretty-print.c
parent07c6dcc3ec27545add1c459ff73e19e687b2512c (diff)
downloadgcc-eed6bc214df1f3b9b1b68c871d4d8ff106ca19f4.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201918 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/pretty-print.c')
-rw-r--r--gcc/pretty-print.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index 27fd0d18b1d..2d2541048f8 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -25,10 +25,27 @@ along with GCC; see the file COPYING3. If not see
#include "pretty-print.h"
#include "diagnostic-color.h"
+#include <new> // For placement-new.
+
#if HAVE_ICONV
#include <iconv.h>
#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. */
#define pp_formatted_text_data(PP) \
((const char *) obstack_base ((PP)->buffer->obstack))
@@ -736,19 +753,24 @@ pp_emit_prefix (pretty_printer *pp)
/* Construct a PRETTY-PRINTER with PREFIX and of MAXIMUM_LENGTH
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->buffer = XCNEW (output_buffer);
- obstack_init (&pp->buffer->chunk_obstack);
- obstack_init (&pp->buffer->formatted_obstack);
- 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;
+ pp_line_cutoff (this) = l;
+ /* By default, we emit prefixes once per message. */
+ pp_prefixing_rule (this) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
+ pp_set_prefix (this, p);
}
/* Append a string delimited by START and END to the output area of