diff mbox series

[pushed,2/3] pretty_printer: make all fields private

Message ID 20240612133752.558463-2-dmalcolm@redhat.com
State New
Headers show
Series [pushed,1/3] pretty_printer: rename instances named "buffer" to "pp" | expand

Commit Message

David Malcolm June 12, 2024, 1:37 p.m. UTC
No functional change intended.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Successful run of analyzer integration tests on x86_64-pc-linux-gnu.
Pushed to trunk as r15-1209-gc5e3be456888aa.

gcc/analyzer/ChangeLog:
	* access-diagram.cc (access_range::dump): Update for fields of
	pretty_printer becoming private.
	* call-details.cc (call_details::dump): Likewise.
	* call-summary.cc (call_summary::dump): Likewise.
	(call_summary_replay::dump): Likewise.
	* checker-event.cc (checker_event::debug): Likewise.
	* constraint-manager.cc (range::dump): Likewise.
	(bounded_range::dump): Likewise.
	(constraint_manager::dump): Likewise.
	* engine.cc (exploded_node::dump): Likewise.
	(exploded_path::dump): Likewise.
	(exploded_path::dump_to_file): Likewise.
	* feasible-graph.cc (feasible_graph::dump_feasible_path): Likewise.
	* program-point.cc (program_point::dump): Likewise.
	* program-state.cc (extrinsic_state::dump_to_file): Likewise.
	(sm_state_map::dump): Likewise.
	(program_state::dump_to_file): Likewise.
	* ranges.cc (symbolic_byte_offset::dump): Likewise.
	(symbolic_byte_range::dump): Likewise.
	* record-layout.cc (record_layout::dump): Likewise.
	* region-model-reachability.cc (reachable_regions::dump): Likewise.
	* region-model.cc (region_to_value_map::dump): Likewise.
	(region_model::dump): Likewise.
	(model_merger::dump): Likewise.
	* region-model.h (one_way_id_map<T>::dump): Likewise.
	* region.cc (region_offset::dump): Likewise.
	(region::dump): Likewise.
	* sm-malloc.cc (deallocator_set::dump): Likewise.
	* store.cc (uncertainty_t::dump): Likewise.
	(binding_key::dump): Likewise.
	(bit_range::dump): Likewise.
	(byte_range::dump): Likewise.
	(binding_map::dump): Likewise.
	(binding_cluster::dump): Likewise.
	(store::dump): Likewise.
	* supergraph.cc (supergraph::dump_dot_to_file): Likewise.
	(superedge::dump): Likewise.
	* svalue.cc (svalue::dump): Likewise.

gcc/c-family/ChangeLog:
	* c-ada-spec.cc (dump_ads): Update for fields of pretty_printer
	becoming private.
	* c-pretty-print.cc: Likewise throughout.

gcc/c/ChangeLog:
	* c-objc-common.cc (print_type): Update for fields of
	pretty_printer becoming private.
	(c_tree_printer): Likewise.

gcc/cp/ChangeLog:
	* cxx-pretty-print.cc: Update throughout for fields of
	pretty_printer becoming private.
	* error.cc: Likewise.

gcc/ChangeLog:
	* diagnostic.cc (diagnostic_context::urls_init): Update for fields
	of pretty_printer becoming private.
	(diagnostic_context::print_any_cwe): Likewise.
	(diagnostic_context::print_any_rules): Likewise.
	(diagnostic_context::print_option_information): Likewise.
	* diagnostic.h (diagnostic_format_decoder): Likewise.
	(diagnostic_prefixing_rule): Likewise, fixing typo.
	* digraph.cc (test_dump_to_dot): Likewise.
	* digraph.h (digraph<GraphTraits>::dump_dot_to_file): Likewise.
	* dumpfile.cc
	(dump_pretty_printer::emit_any_pending_textual_chunks): Likewise.
	* gimple-pretty-print.cc (print_gimple_stmt): Likewise.
	(print_gimple_expr): Likewise.
	(print_gimple_seq): Likewise.
	(dump_ssaname_info_to_file): Likewise.
	(gimple_dump_bb): Likewise.
	* graph.cc (print_graph_cfg): Likewise.
	(start_graph_dump): Likewise.
	* langhooks.cc (lhd_print_error_function): Likewise.
	* lto-wrapper.cc (print_lto_docs_link): Likewise.
	* pretty-print.cc (pp_set_real_maximum_length): Convert to...
	(pretty_printer::set_real_maximum_length): ...this.
	(pp_clear_state): Convert to...
	(pretty_printer::clear_state): ...this.
	(pp_wrap_text): Update for pp_remaining_character_count_for_line
	becoming a member function.
	(urlify_quoted_string): Update for fields of pretty_printer becoming
	private.
	(pp_format): Convert to...
	(pretty_printer::format): ...this.  Reduce the scope of local
	variables "old_line_length" and "old_wrapping_mode" and make
	const.  Reduce the scope of locals "args", "new_chunk_array",
	"curarg", "any_unnumbered", and "any_numbered".
	(pp_output_formatted_text): Update for fields of pretty_printer
	becoming private.
	(pp_flush): Likewise.
	(pp_really_flush): Likewise.
	(pp_set_line_maximum_length): Likewise.
	(pp_set_prefix): Convert to...
	(pretty_printer::set_prefix): ...this.
	(pp_take_prefix): Update for fields of pretty_printer gaining
	"m_" prefixes.
	(pp_destroy_prefix): Likewise.
	(pp_emit_prefix): Convert to...
	(pretty_printer::emit_prefix): ...this.
	(pretty_printer::pretty_printer): Update both ctors for fields
	gaining "m_"  prefixes.
	(pretty_printer::~pretty_printer): Likewise for dtor.
	(pp_append_text): Update for pp_emit_prefix becoming
	pretty_printer::emit_prefix.
	(pp_remaining_character_count_for_line): Convert to...
	(pretty_printer::remaining_character_count_for_line): ...this.
	(pp_character): Update for above change.
	(pp_maybe_space): Convert to...
	(pretty_printer::maybe_space): ...this.
	(pp_begin_url): Convert to...
	(pretty_printer::begin_url): ...this.
	(get_end_url_string): Update for fields of pretty_printer
	becoming private.
	(pp_end_url): Convert to...
	(pretty_printer::end_url): ...this.
	(selftest::test_pretty_printer::test_pretty_printer): Update for
	fields of pretty_printer becoming private.
	(selftest::test_urls): Likewise.
	(selftest::test_null_urls): Likewise.
	(selftest::test_urlification): Likewise.
	* pretty-print.h (pp_line_cutoff): Convert from macro to inline
	function.
	(pp_prefixing_rule): Likewise.
	(pp_wrapping_mode): Likewise.
	(pp_format_decoder): Likewise.
	(pp_needs_newline): Likewise.
	(pp_indentation): Likewise.
	(pp_translate_identifiers): Likewise.
	(pp_show_color): Likewise.
	(pp_buffer): Likewise.
	(pp_get_prefix): Add forward decl to allow friend decl.
	(pp_take_prefix): Likewise.
	(pp_destroy_prefix): Likewise.
	(class pretty_printer): Fix typo in leading comment.  Add
	"friend" decls for the various new accessor functions that were
	formerly macros and for pp_get_prefix, pp_take_prefix, and
	pp_destroy_prefix.  Make all fields private.
	(pretty_printer::set_output_stream): New.
	(pretty_printer::set_prefix): New decl.
	(pretty_printer::emit_prefix): New decl.
	(pretty_printer::format): New decl.
	(pretty_printer::maybe_space): New decl.
	(pretty_printer::supports_urls_p): New.
	(pretty_printer::get_url_format): New.
	(pretty_printer::set_url_format): New.
	(pretty_printer::begin_url): New decl.
	(pretty_printer::end_url): New decl.
	(pretty_printer::set_verbatim_wrapping): New.
	(pretty_printer::set_padding): New.
	(pretty_printer::get_padding): New.
	(pretty_printer::clear_state): New decl.
	(pretty_printer::set_real_maximum_length): New decl.
	(pretty_printer::remaining_character_count_for_line): New decl.
	(pretty_printer::buffer): Rename to...
	(pretty_printer::m_buffer): ...this.
	(pretty_printer::prefix): Rename to...
	(pretty_printer::m_prefix): ...this;
	(pretty_printer::padding): Rename to...
	(pretty_printer::m_padding): ...this;
	(pretty_printer::maximum_length): Rename to...
	(pretty_printer::m_maximum_length): ...this;
	(pretty_printer::indent_skip): Rename to...
	(pretty_printer::m_indent_skip): ...this;
	(pretty_printer::wrapping): Rename to...
	(pretty_printer::m_wrapping): ...this;
	(pretty_printer::format_decoder): Rename to...
	(pretty_printer::m_format_decoder): ...this;
	(pretty_printer::emitted_prefix): Rename to...
	(pretty_printer::m_emitted_prefix): ...this;
	(pretty_printer::need_newline): Rename to...
	(pretty_printer::m_need_newline): ...this;
	(pretty_printer::translate_identifiers): Rename to...
	(pretty_printer::m_translate_identifiers): ...this;
	(pretty_printer::show_color): Rename to...
	(pretty_printer::m_show_color): ...this;
	(pretty_printer::url_format): Rename to...
	(pretty_printer::m_url_format): ...this;
	(pp_get_prefix): Reformat.
	(pp_format_postprocessor): New inline function.
	(pp_take_prefix): Move decl to before class pretty_printer.
	(pp_destroy_prefix): Likewise.
	(pp_set_prefix): Convert to inline function.
	(pp_emit_prefix): Convert to inline function.
	(pp_format): Convert to inline function.
	(pp_maybe_space): Convert to inline function.
	(pp_begin_url): Convert to inline function.
	(pp_end_url): Convert to inline function.
	(pp_set_verbatim_wrapping): Convert from macro to inline
	function, renaming...
	(pp_set_verbatim_wrapping_): ...this.
	* print-rtl.cc (dump_value_slim): Update for fields of
	pretty_printer becoming private.
	(dump_insn_slim): Likewise.
	(dump_rtl_slim): Likewise.
	* print-tree.cc (print_node): Likewise.
	* sched-rgn.cc (dump_rgn_dependencies_dot): Likewise.
	* text-art/canvas.cc (canvas::print_to_pp): Likewise.
	(canvas::debug): Likewise.
	(selftest::test_canvas_urls): Likewise.
	* text-art/dump.h (dump_to_file): Likewise.
	* text-art/selftests.cc (selftest::assert_canvas_streq): Likewise.
	* text-art/style.cc (style::print_changes): Likewise.
	* text-art/styled-string.cc (styled_string::from_fmt_va):
	Likewise.
	* tree-diagnostic-path.cc (control_flow_tests): Update for
	pp_show_color becoming an inline function.
	* tree-loop-distribution.cc (dot_rdg_1): Update for fields of
	pretty_printer becoming private.
	* tree-pretty-print.cc (maybe_init_pretty_print): Likewise.
	* value-range.cc (vrange::dump): Likewise.
	(irange_bitmask::dump): Likewise.

gcc/fortran/ChangeLog:
	* error.cc (gfc_clear_pp_buffer): Likewise.
	(gfc_warning): Likewise.
	(gfc_warning_check): Likewise.
	(gfc_error_opt): Likewise.
	(gfc_error_check): Likewise.

gcc/jit/ChangeLog:
	* jit-recording.cc (recording::function::dump_to_dot): Update for
	fields of pretty_printer becoming private.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info):
	Update for fields of pretty_printer becoming private.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/analyzer/access-diagram.cc                |   2 +-
 gcc/analyzer/call-details.cc                  |   2 +-
 gcc/analyzer/call-summary.cc                  |   4 +-
 gcc/analyzer/checker-event.cc                 |   2 +-
 gcc/analyzer/constraint-manager.cc            |   8 +-
 gcc/analyzer/engine.cc                        |   6 +-
 gcc/analyzer/feasible-graph.cc                |   2 +-
 gcc/analyzer/program-point.cc                 |   2 +-
 gcc/analyzer/program-state.cc                 |   6 +-
 gcc/analyzer/ranges.cc                        |   4 +-
 gcc/analyzer/record-layout.cc                 |   2 +-
 gcc/analyzer/region-model-reachability.cc     |   2 +-
 gcc/analyzer/region-model.cc                  |   6 +-
 gcc/analyzer/region-model.h                   |   2 +-
 gcc/analyzer/region.cc                        |   4 +-
 gcc/analyzer/sm-malloc.cc                     |   2 +-
 gcc/analyzer/store.cc                         |  14 +-
 gcc/analyzer/supergraph.cc                    |   4 +-
 gcc/analyzer/svalue.cc                        |   2 +-
 gcc/c-family/c-ada-spec.cc                    |   2 +-
 gcc/c-family/c-pretty-print.cc                |  36 +-
 gcc/c/c-objc-common.cc                        |   4 +-
 gcc/cp/cxx-pretty-print.cc                    |  12 +-
 gcc/cp/error.cc                               |  37 +-
 gcc/diagnostic.cc                             |  14 +-
 gcc/diagnostic.h                              |   6 +-
 gcc/digraph.cc                                |   2 +-
 gcc/digraph.h                                 |   2 +-
 gcc/dumpfile.cc                               |   1 +
 gcc/fortran/error.cc                          |  30 +-
 gcc/gimple-pretty-print.cc                    |  10 +-
 gcc/graph.cc                                  |   4 +-
 gcc/jit/jit-recording.cc                      |   2 +-
 gcc/langhooks.cc                              |   3 +-
 gcc/lto-wrapper.cc                            |   4 +-
 gcc/pretty-print.cc                           | 339 +++++++++---------
 gcc/pretty-print.h                            | 263 +++++++++++---
 gcc/print-rtl.cc                              |   6 +-
 gcc/print-tree.cc                             |   2 +-
 gcc/sched-rgn.cc                              |   2 +-
 .../gcc.dg/plugin/analyzer_cpython_plugin.c   |   2 +-
 gcc/text-art/canvas.cc                        |  10 +-
 gcc/text-art/dump.h                           |   2 +-
 gcc/text-art/selftests.cc                     |   2 +-
 gcc/text-art/style.cc                         |   4 +-
 gcc/text-art/styled-string.cc                 |   2 +-
 gcc/tree-diagnostic-path.cc                   |   2 +-
 gcc/tree-loop-distribution.cc                 |   2 +-
 gcc/tree-pretty-print.cc                      |   2 +-
 gcc/value-range.cc                            |   4 +-
 50 files changed, 516 insertions(+), 373 deletions(-)
diff mbox series

Patch

diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc
index 8d7461fe381d..cb5b656c164a 100644
--- a/gcc/analyzer/access-diagram.cc
+++ b/gcc/analyzer/access-diagram.cc
@@ -547,7 +547,7 @@  access_range::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/call-details.cc b/gcc/analyzer/call-details.cc
index fda925edb968..116ab40afaf5 100644
--- a/gcc/analyzer/call-details.cc
+++ b/gcc/analyzer/call-details.cc
@@ -366,7 +366,7 @@  call_details::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/call-summary.cc b/gcc/analyzer/call-summary.cc
index 46b4e2a3bbd7..ec36fdfd9f1a 100644
--- a/gcc/analyzer/call-summary.cc
+++ b/gcc/analyzer/call-summary.cc
@@ -149,7 +149,7 @@  call_summary::dump (const extrinsic_state &ext_state,
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (ext_state, &pp, simple);
   pp_flush (&pp);
 }
@@ -890,7 +890,7 @@  call_summary_replay::dump (FILE *fp, bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, simple);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/checker-event.cc b/gcc/analyzer/checker-event.cc
index ee3ceb407ea1..593f364e1d66 100644
--- a/gcc/analyzer/checker-event.cc
+++ b/gcc/analyzer/checker-event.cc
@@ -199,7 +199,7 @@  checker_event::debug () const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index 883f33b2cdd7..a9d58c9cdcf5 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -185,7 +185,7 @@  range::dump () const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -448,7 +448,7 @@  bounded_range::dump (bool show_types) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, show_types);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -721,7 +721,7 @@  bounded_ranges::dump (bool show_types) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, show_types);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -1772,7 +1772,7 @@  constraint_manager::dump (FILE *fp) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, true);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 30c0913c861d..f5fad5b2e470 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -1422,7 +1422,7 @@  exploded_node::dump (FILE *fp,
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, ext_state);
   pp_flush (&pp);
 }
@@ -4832,7 +4832,7 @@  exploded_path::dump (FILE *fp, const extrinsic_state *ext_state) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, ext_state);
   pp_flush (&pp);
 }
@@ -4856,7 +4856,7 @@  exploded_path::dump_to_file (const char *filename,
     return;
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, &ext_state);
   pp_flush (&pp);
   fclose (fp);
diff --git a/gcc/analyzer/feasible-graph.cc b/gcc/analyzer/feasible-graph.cc
index a1812231572c..35b489fde357 100644
--- a/gcc/analyzer/feasible-graph.cc
+++ b/gcc/analyzer/feasible-graph.cc
@@ -301,7 +301,7 @@  feasible_graph::dump_feasible_path (const feasible_node &dst_fnode,
   FILE *fp = fopen (filename, "w");
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_feasible_path (dst_fnode, &pp);
   pp_flush (&pp);
   fclose (fp);
diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc
index 14ce5be4bcf9..ea15ccc91d27 100644
--- a/gcc/analyzer/program-point.cc
+++ b/gcc/analyzer/program-point.cc
@@ -302,7 +302,7 @@  program_point::dump () const
 {
   pretty_printer pp;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   print (&pp, format (true));
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc
index efaf569a4906..cb9c38880029 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -86,7 +86,7 @@  extrinsic_state::dump_to_file (FILE *outf) const
   pretty_printer pp;
   if (outf == stderr)
     pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = outf;
+  pp.set_output_stream (outf);
   dump_to_pp (&pp);
   pp_flush (&pp);
 }
@@ -274,7 +274,7 @@  sm_state_map::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   print (NULL, simple, true, &pp);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -1169,7 +1169,7 @@  program_state::dump_to_file (const extrinsic_state &ext_state,
   pp_format_decoder (&pp) = default_tree_printer;
   if (outf == stderr)
     pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = outf;
+  pp.set_output_stream (outf);
   dump_to_pp (ext_state, summarize, multiline, &pp);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/ranges.cc b/gcc/analyzer/ranges.cc
index f591efae43af..17d6e6b2212d 100644
--- a/gcc/analyzer/ranges.cc
+++ b/gcc/analyzer/ranges.cc
@@ -98,7 +98,7 @@  symbolic_byte_offset::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -157,7 +157,7 @@  symbolic_byte_range::dump (bool simple, region_model_manager &mgr) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple, mgr);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/record-layout.cc b/gcc/analyzer/record-layout.cc
index af3115518489..59690a43b76e 100644
--- a/gcc/analyzer/record-layout.cc
+++ b/gcc/analyzer/record-layout.cc
@@ -85,7 +85,7 @@  record_layout::dump () const
 {
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/region-model-reachability.cc b/gcc/analyzer/region-model-reachability.cc
index b9887902980f..828e3fcbadac 100644
--- a/gcc/analyzer/region-model-reachability.cc
+++ b/gcc/analyzer/region-model-reachability.cc
@@ -350,7 +350,7 @@  reachable_regions::dump () const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 1a44ff073bd3..7969055a59cd 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -226,7 +226,7 @@  region_to_value_map::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple, true);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -486,7 +486,7 @@  region_model::dump (FILE *fp, bool simple, bool multiline) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, simple, multiline);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -7400,7 +7400,7 @@  model_merger::dump (FILE *fp, bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_to_pp (&pp, simple);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index 912b558a18dd..f57d2069b3b1 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -123,7 +123,7 @@  DEBUG_FUNCTION inline void
 one_way_id_map<T>::dump () const
 {
   pretty_printer pp;
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_flush (&pp);
 }
diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index d5cfd476fd8a..2eabda41941d 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -141,7 +141,7 @@  region_offset::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -1018,7 +1018,7 @@  region::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index 8bdcb4bc33cd..f1ec04d117d0 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -586,7 +586,7 @@  deallocator_set::dump () const
 {
   pretty_printer pp;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc
index 5a33d740ce2b..f58b84ef9461 100644
--- a/gcc/analyzer/store.cc
+++ b/gcc/analyzer/store.cc
@@ -110,7 +110,7 @@  uncertainty_t::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -147,7 +147,7 @@  binding_key::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -231,7 +231,7 @@  DEBUG_FUNCTION void
 bit_range::dump () const
 {
   pretty_printer pp;
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -507,7 +507,7 @@  DEBUG_FUNCTION void
 byte_range::dump () const
 {
   pretty_printer pp;
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -776,7 +776,7 @@  binding_map::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple, true);
   pp_newline (&pp);
   pp_flush (&pp);
@@ -1403,7 +1403,7 @@  binding_cluster::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   pp_string (&pp, "  cluster for: ");
   m_base_region->dump_to_pp (&pp, simple);
   pp_string (&pp, ": ");
@@ -2639,7 +2639,7 @@  store::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple, true, NULL);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc
index adbf90f17ede..4dc7942b26aa 100644
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -443,7 +443,7 @@  supergraph::dump_dot_to_file (FILE *fp, const dump_args_t &dump_args) const
      trying to prettify things by showing the underlying var.  */
   pp_format_decoder (pp) = default_tree_printer;
 
-  pp->buffer->stream = fp;
+  pp->set_output_stream (fp);
   dump_dot_to_pp (pp, dump_args);
   pp_flush (pp);
   delete pp;
@@ -902,7 +902,7 @@  superedge::dump () const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump (&pp);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index b67780a5ef12..cad6b7dd3cd8 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -89,7 +89,7 @@  svalue::dump (bool simple) const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
   dump_to_pp (&pp, simple);
   pp_newline (&pp);
   pp_flush (&pp);
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index e0e72493151b..a41e93aeafb8 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -3556,7 +3556,7 @@  dump_ads (const char *source_file,
       pretty_printer pp;
 
       pp_needs_newline (&pp) = true;
-      pp.buffer->stream = f;
+      pp.set_output_stream (f);
 
       /* Dump all relevant macros.  */
       dump_ada_macros (&pp, source_file);
diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index da7934d783a5..dd7eba123943 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -47,7 +47,7 @@  along with GCC; see the file COPYING3.  If not see
 
 #define pp_c_maybe_whitespace(PP)            \
    do {                                      \
-     if ((PP)->padding == pp_before) \
+     if ((PP)->get_padding () == pp_before)  \
        pp_c_whitespace (PP);                 \
    } while (0)
 
@@ -76,98 +76,98 @@  void
 pp_c_whitespace (c_pretty_printer *pp)
 {
   pp_space (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_left_paren (c_pretty_printer *pp)
 {
   pp_left_paren (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_right_paren (c_pretty_printer *pp)
 {
   pp_right_paren (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_left_brace (c_pretty_printer *pp)
 {
   pp_left_brace (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_right_brace (c_pretty_printer *pp)
 {
   pp_right_brace (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_left_bracket (c_pretty_printer *pp)
 {
   pp_left_bracket (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_right_bracket (c_pretty_printer *pp)
 {
   pp_right_bracket (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_dot (c_pretty_printer *pp)
 {
   pp_dot (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_ampersand (c_pretty_printer *pp)
 {
   pp_ampersand (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_star (c_pretty_printer *pp)
 {
   pp_star (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_arrow (c_pretty_printer *pp)
 {
   pp_arrow (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_semicolon (c_pretty_printer *pp)
 {
   pp_semicolon (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_complement (c_pretty_printer *pp)
 {
   pp_complement (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
 pp_c_exclamation (c_pretty_printer *pp)
 {
   pp_exclamation (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 /* Print out the external representation of QUALIFIERS.  */
@@ -1307,7 +1307,7 @@  pp_c_ws_string (c_pretty_printer *pp, const char *str)
 {
   pp_c_maybe_whitespace (pp);
   pp_string (pp, str);
-  pp->padding = pp_before;
+  pp->set_padding (pp_before);
 }
 
 void
@@ -1328,7 +1328,7 @@  pp_c_identifier (c_pretty_printer *pp, const char *id)
 {
   pp_c_maybe_whitespace (pp);
   pp_identifier (pp, id);
-  pp->padding = pp_before;
+  pp->set_padding (pp_before);
 }
 
 /* Pretty-print a C primary-expression.
@@ -2985,7 +2985,7 @@  print_c_tree (FILE *file, tree t)
   c_pretty_printer pp;
 
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   pp.statement (t);
   pp_newline_and_flush (&pp);
 }
diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc
index 738e899a2a93..1025e0e1c7b9 100644
--- a/gcc/c/c-objc-common.cc
+++ b/gcc/c/c-objc-common.cc
@@ -252,7 +252,7 @@  print_type (c_pretty_printer *cpp, tree t, bool *quoted)
       c_pretty_printer cpp2;
       /* Print the stripped version into a temporary printer.  */
       cpp2.type_id (aka_type);
-      struct obstack *ob2 = cpp2.buffer->obstack;
+      struct obstack *ob2 = pp_buffer (&cpp2)->obstack;
       /* Get the stripped version from the temporary printer.  */
       const char *aka = (char *) obstack_base (ob2);
       int aka_len = obstack_object_size (ob2);
@@ -301,7 +301,7 @@  c_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
   tree t = NULL_TREE;
   // FIXME: the next cast should be a dynamic_cast, when it is permitted.
   c_pretty_printer *cpp = (c_pretty_printer *) pp;
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 
   if (precision != 0 || wide)
     return false;
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index c6d8cc84132b..806aebff174b 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -49,7 +49,7 @@  pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c)
   if (p != NULL && *p == c)
     pp_cxx_whitespace (pp);
   pp_character (pp, c);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 #define pp_cxx_expression_list(PP, T)    \
@@ -65,7 +65,7 @@  void
 pp_cxx_colon_colon (cxx_pretty_printer *pp)
 {
   pp_colon_colon (pp);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 void
@@ -84,7 +84,7 @@  void
 pp_cxx_separate_with (cxx_pretty_printer *pp, int c)
 {
   pp_separate_with (pp, c);
-  pp->padding = pp_none;
+  pp->set_padding (pp_none);
 }
 
 /* Expressions.  */
@@ -1702,7 +1702,7 @@  cxx_pretty_printer::direct_declarator (tree t)
 
       if (DECL_IOBJ_MEMBER_FUNCTION_P (t))
 	{
-	  padding = pp_before;
+	  set_padding (pp_before);
 	  pp_cxx_cv_qualifier_seq (this, pp_cxx_implicit_parameter_type (t));
 	}
 
@@ -1859,7 +1859,7 @@  cxx_pretty_printer::direct_abstract_declarator (tree t)
       direct_abstract_declarator (TREE_TYPE (t));
       if (TREE_CODE (t) == METHOD_TYPE)
 	{
-	  padding = pp_before;
+	  set_padding (pp_before);
 	  pp_cxx_cv_qualifier_seq (this, class_of_this_parm (t));
 	}
       pp_cxx_exception_specification (this, t);
@@ -2685,7 +2685,7 @@  pp_cxx_requires_clause (cxx_pretty_printer *pp, tree t)
 {
   if (!t)
     return;
-  pp->padding = pp_before;
+  pp->set_padding (pp_before);
   pp_cxx_ws_string (pp, "requires");
   pp_space (pp);
   pp->expression (t);
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 0ff7f9d4c468..01ad794df8e3 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -180,7 +180,7 @@  cxx_initialize_diagnostics (diagnostic_context *context)
   diagnostic_starter (context) = cp_diagnostic_starter;
   /* diagnostic_finalizer is already c_diagnostic_finalizer.  */
   diagnostic_format_decoder (context) = cp_printer;
-  pp->m_format_postprocessor = new cxx_format_postprocessor ();
+  pp_format_postprocessor (pp) = new cxx_format_postprocessor ();
 }
 
 /* Dump an '@module' name suffix for DECL, if any.  */
@@ -210,7 +210,7 @@  dump_module_suffix (cxx_pretty_printer *pp, tree decl)
     if (const char *n = module_name (m, false))
       {
 	pp_character (pp, '@');
-	pp->padding = pp_none;
+	pp->set_padding (pp_none);
 	pp_string (pp, n);
       }
 }
@@ -921,7 +921,7 @@  dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
 	    else
 	      pp_ampersand (pp);
 	  }
-	pp->padding = pp_before;
+	pp->set_padding (pp_before);
 	pp_cxx_cv_qualifier_seq (pp, t);
       }
       break;
@@ -939,7 +939,7 @@  dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
 	}
       pp_cxx_star (pp);
       pp_cxx_cv_qualifier_seq (pp, t);
-      pp->padding = pp_before;
+      pp->set_padding (pp_before);
       break;
 
       /* This can be reached without a pointer when dealing with
@@ -986,7 +986,7 @@  dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
     case FIXED_POINT_TYPE:
     case NULLPTR_TYPE:
       dump_type (pp, t, flags);
-      pp->padding = pp_before;
+      pp->set_padding (pp_before);
       break;
 
     default:
@@ -1035,7 +1035,7 @@  dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
 	   anyway; they may in g++, but we'll just pretend otherwise.  */
 	dump_parameters (pp, arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS);
 
-	pp->padding = pp_before;
+	pp->set_padding (pp_before);
 	pp_cxx_cv_qualifiers (pp, type_memfn_quals (t),
 			      TREE_CODE (t) == FUNCTION_TYPE
 			      && (flags & TFF_POINTER));
@@ -1049,7 +1049,7 @@  dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
 	  {
 	    pp_space (pp);
 	    pp_c_attributes_display (pp, TYPE_ATTRIBUTES (t));
-	    pp->padding = pp_before;
+	    pp->set_padding (pp_before);
 	  }
 	dump_type_suffix (pp, TREE_TYPE (t), flags);
 	break;
@@ -1720,13 +1720,13 @@  dump_lambda_function (cxx_pretty_printer *pp,
     /* Early escape.  */;
   else if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE)
     {
-      pp->padding = pp_before;
+      pp->set_padding (pp_before);
       pp_c_ws_string (pp, "static");
     }
   else if (!(TYPE_QUALS (class_of_this_parm (TREE_TYPE (fn)))
 	     & TYPE_QUAL_CONST))
     {
-      pp->padding = pp_before;
+      pp->set_padding (pp_before);
       pp_c_ws_string (pp, "mutable");
     }
   dump_substitution (pp, fn, template_parms, template_args, flags);
@@ -1845,20 +1845,20 @@  dump_function_decl (cxx_pretty_printer *pp, tree t, int flags)
 
       if (TREE_CODE (fntype) == METHOD_TYPE)
 	{
-	  pp->padding = pp_before;
+	  pp->set_padding (pp_before);
 	  pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype));
 	  dump_ref_qualifier (pp, fntype, flags);
 	}
 
       if (tx_safe_fn_type_p (fntype))
 	{
-	  pp->padding = pp_before;
+	  pp->set_padding (pp_before);
 	  pp_cxx_ws_string (pp, "transaction_safe");
 	}
 
       if (flags & TFF_EXCEPTION_SPECIFICATION)
 	{
-	  pp->padding = pp_before;
+	  pp->set_padding (pp_before);
 	  dump_exception_spec (pp, exceptions, flags);
 	}
 
@@ -1952,7 +1952,7 @@  dump_ref_qualifier (cxx_pretty_printer *pp, tree t, int flags ATTRIBUTE_UNUSED)
 {
   if (FUNCTION_REF_QUALIFIED (t))
     {
-      pp->padding = pp_before;
+      pp->set_padding (pp_before);
       if (FUNCTION_RVALUE_QUALIFIED (t))
         pp_cxx_ws_string (pp, "&&");
       else
@@ -3156,7 +3156,7 @@  static void
 reinit_cxx_pp (void)
 {
   pp_clear_output_area (cxx_pp);
-  cxx_pp->padding = pp_none;
+  cxx_pp->set_padding (pp_none);
   pp_indentation (cxx_pp) = 0;
   pp_needs_newline (cxx_pp) = false;
   pp_show_color (cxx_pp) = false;
@@ -3537,7 +3537,7 @@  static const char *
 cv_to_string (tree p, int v)
 {
   reinit_cxx_pp ();
-  cxx_pp->padding = v ? pp_before : pp_none;
+  cxx_pp->set_padding (v ? pp_before : pp_none);
   pp_cxx_cv_qualifier_seq (cxx_pp, p);
   return pp_ggc_formatted_text (cxx_pp);
 }
@@ -3682,8 +3682,7 @@  cp_print_error_function (diagnostic_context *context,
       pp_newline (context->printer);
 
       diagnostic_set_last_function (context, diagnostic);
-      pp_destroy_prefix (context->printer);
-      context->printer->prefix = old_prefix;
+      context->printer->set_prefix (old_prefix);
     }
 }
 
@@ -4470,9 +4469,9 @@  cp_printer (pretty_printer *pp, text_info *text, const char *spec,
 	    int precision, bool wide, bool set_locus, bool verbose,
 	    bool *quoted, const char **buffer_ptr)
 {
-  gcc_assert (pp->m_format_postprocessor);
+  gcc_assert (pp_format_postprocessor (pp));
   cxx_format_postprocessor *postprocessor
-    = static_cast <cxx_format_postprocessor *> (pp->m_format_postprocessor);
+    = static_cast <cxx_format_postprocessor *> (pp_format_postprocessor (pp));
 
   const char *result;
   tree t = NULL;
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 1b4def06f726..9d0cb8ea051c 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -342,8 +342,8 @@  diagnostic_context::urls_init (int value)
 	value = DIAGNOSTICS_URLS_DEFAULT;
     }
 
-  this->printer->url_format
-    = determine_url_format ((diagnostic_url_rule_t) value);
+  this->printer->set_url_format
+    (determine_url_format ((diagnostic_url_rule_t) value));
 }
 
 /* Create the file_cache, if not already created, and tell it how to
@@ -1354,7 +1354,7 @@  diagnostic_context::print_any_cwe (const diagnostic_info &diagnostic)
       pp_string (pp, " [");
       pp_string (pp, colorize_start (pp_show_color (pp),
 				     diagnostic_kind_color[diagnostic.kind]));
-      if (pp->url_format != URL_FORMAT_NONE)
+      if (pp->supports_urls_p ())
 	{
 	  char *cwe_url = get_cwe_url (cwe);
 	  pp_begin_url (pp, cwe_url);
@@ -1362,7 +1362,7 @@  diagnostic_context::print_any_cwe (const diagnostic_info &diagnostic)
 	}
       pp_printf (pp, "CWE-%i", cwe);
       pp_set_prefix (pp, saved_prefix);
-      if (pp->url_format != URL_FORMAT_NONE)
+      if (pp->supports_urls_p ())
 	pp_end_url (pp);
       pp_string (pp, colorize_stop (pp_show_color (pp)));
       pp_character (pp, ']');
@@ -1394,7 +1394,7 @@  diagnostic_context::print_any_rules (const diagnostic_info &diagnostic)
 		     colorize_start (pp_show_color (pp),
 				     diagnostic_kind_color[diagnostic.kind]));
 	  char *url = NULL;
-	  if (pp->url_format != URL_FORMAT_NONE)
+	  if (pp->supports_urls_p ())
 	    {
 	      url = rule.make_url ();
 	      if (url)
@@ -1402,7 +1402,7 @@  diagnostic_context::print_any_rules (const diagnostic_info &diagnostic)
 	    }
 	  pp_string (pp, desc);
 	  pp_set_prefix (pp, saved_prefix);
-	  if (pp->url_format != URL_FORMAT_NONE)
+	  if (pp->supports_urls_p ())
 	    if (url)
 	      pp_end_url (pp);
 	  free (url);
@@ -1425,7 +1425,7 @@  diagnostic_context::print_option_information (const diagnostic_info &diagnostic,
 					    orig_diag_kind, diagnostic.kind))
     {
       char *option_url = nullptr;
-      if (this->printer->url_format != URL_FORMAT_NONE)
+      if (this->printer->supports_urls_p ())
 	option_url = make_option_url (diagnostic.option_index);
       pretty_printer * const pp = this->printer;
       pp_string (pp, " [");
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 4632aac73c6b..9a9571bb76d4 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -842,10 +842,10 @@  diagnostic_finalizer (diagnostic_context *context)
 #define diagnostic_info_auxiliary_data(DI) (DI)->x_data
 
 /* Same as pp_format_decoder.  Works on 'diagnostic_context *'.  */
-#define diagnostic_format_decoder(DC) ((DC)->printer->format_decoder)
+#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->printer)
 
-/* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
-#define diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule)
+/* Same as pp_prefixing_rule.  Works on 'diagnostic_context *'.  */
+#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->printer)
 
 /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.  */
 inline void
diff --git a/gcc/digraph.cc b/gcc/digraph.cc
index 64497f8d9291..b323764a93cd 100644
--- a/gcc/digraph.cc
+++ b/gcc/digraph.cc
@@ -108,7 +108,7 @@  test_dump_to_dot ()
   g.add_test_edge (a, b);
 
   pretty_printer pp;
-  pp.buffer->stream = NULL;
+  pp.set_output_stream (nullptr);
   test_dump_args_t dump_args;
   g.dump_dot_to_pp (&pp, NULL, dump_args);
 
diff --git a/gcc/digraph.h b/gcc/digraph.h
index 33a5055cd9cd..4894d3987ccf 100644
--- a/gcc/digraph.h
+++ b/gcc/digraph.h
@@ -201,7 +201,7 @@  digraph<GraphTraits>::dump_dot_to_file (FILE *fp,
   pretty_printer pp;
   // TODO:
   pp_format_decoder (&pp) = default_tree_printer;
-  pp.buffer->stream = fp;
+  pp.set_output_stream (fp);
   dump_dot_to_pp (&pp, root_cluster, args);
   pp_flush (&pp);
 }
diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc
index 1ec44cb58fb7..097f9bcfff21 100644
--- a/gcc/dumpfile.cc
+++ b/gcc/dumpfile.cc
@@ -860,6 +860,7 @@  dump_pretty_printer::emit_items (optinfo *dest)
 void
 dump_pretty_printer::emit_any_pending_textual_chunks (optinfo *dest)
 {
+  output_buffer *const buffer = pp_buffer (this);
   gcc_assert (buffer->obstack == &buffer->formatted_obstack);
 
   /* Don't emit an item if the pending text is empty.  */
diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc
index 65e38b0e8667..a0e1a1c36844 100644
--- a/gcc/fortran/error.cc
+++ b/gcc/fortran/error.cc
@@ -924,10 +924,10 @@  static void
 gfc_clear_pp_buffer (output_buffer *this_buffer)
 {
   pretty_printer *pp = global_dc->printer;
-  output_buffer *tmp_buffer = pp->buffer;
-  pp->buffer = this_buffer;
+  output_buffer *tmp_buffer = pp_buffer (pp);
+  pp_buffer (pp) = this_buffer;
   pp_clear_output_area (pp);
-  pp->buffer = tmp_buffer;
+  pp_buffer (pp) = tmp_buffer;
   /* We need to reset last_location, otherwise we may skip caret lines
      when we actually give a diagnostic.  */
   global_dc->m_last_location = UNKNOWN_LOCATION;
@@ -964,13 +964,13 @@  gfc_warning (int opt, const char *gmsgid, va_list ap)
   rich_location rich_loc (line_table, UNKNOWN_LOCATION);
   bool fatal_errors = global_dc->m_fatal_errors;
   pretty_printer *pp = global_dc->printer;
-  output_buffer *tmp_buffer = pp->buffer;
+  output_buffer *tmp_buffer = pp_buffer (pp);
 
   gfc_clear_pp_buffer (pp_warning_buffer);
 
   if (buffered_p)
     {
-      pp->buffer = pp_warning_buffer;
+      pp_buffer (pp) = pp_warning_buffer;
       global_dc->m_fatal_errors = false;
       /* To prevent -fmax-errors= triggering.  */
       --werrorcount;
@@ -983,7 +983,7 @@  gfc_warning (int opt, const char *gmsgid, va_list ap)
 
   if (buffered_p)
     {
-      pp->buffer = tmp_buffer;
+      pp_buffer (pp) = tmp_buffer;
       global_dc->m_fatal_errors = fatal_errors;
 
       warningcount_buffered = 0;
@@ -1461,13 +1461,13 @@  gfc_warning_check (void)
   if (! gfc_output_buffer_empty_p (pp_warning_buffer))
     {
       pretty_printer *pp = global_dc->printer;
-      output_buffer *tmp_buffer = pp->buffer;
-      pp->buffer = pp_warning_buffer;
+      output_buffer *tmp_buffer = pp_buffer (pp);
+      pp_buffer (pp) = pp_warning_buffer;
       pp_really_flush (pp);
       warningcount += warningcount_buffered;
       werrorcount += werrorcount_buffered;
       gcc_assert (warningcount_buffered + werrorcount_buffered == 1);
-      pp->buffer = tmp_buffer;
+      pp_buffer (pp) = tmp_buffer;
       diagnostic_action_after_output (global_dc,
 				      warningcount_buffered
 				      ? DK_WARNING : DK_ERROR);
@@ -1502,7 +1502,7 @@  gfc_error_opt (int opt, const char *gmsgid, va_list ap)
   rich_location richloc (line_table, UNKNOWN_LOCATION);
   bool fatal_errors = global_dc->m_fatal_errors;
   pretty_printer *pp = global_dc->printer;
-  output_buffer *tmp_buffer = pp->buffer;
+  output_buffer *tmp_buffer = pp_buffer (pp);
 
   gfc_clear_pp_buffer (pp_error_buffer);
 
@@ -1512,7 +1512,7 @@  gfc_error_opt (int opt, const char *gmsgid, va_list ap)
 	 save abort_on_error and restore it below.  */
       saved_abort_on_error = global_dc->m_abort_on_error;
       global_dc->m_abort_on_error = false;
-      pp->buffer = pp_error_buffer;
+      pp_buffer (pp) = pp_error_buffer;
       global_dc->m_fatal_errors = false;
       /* To prevent -fmax-errors= triggering, we decrease it before
 	 report_diagnostic increases it.  */
@@ -1524,7 +1524,7 @@  gfc_error_opt (int opt, const char *gmsgid, va_list ap)
 
   if (buffered_p)
     {
-      pp->buffer = tmp_buffer;
+      pp_buffer (pp) = tmp_buffer;
       global_dc->m_fatal_errors = fatal_errors;
       global_dc->m_abort_on_error = saved_abort_on_error;
 
@@ -1609,12 +1609,12 @@  gfc_error_check (void)
     {
       error_buffer.flag = false;
       pretty_printer *pp = global_dc->printer;
-      output_buffer *tmp_buffer = pp->buffer;
-      pp->buffer = pp_error_buffer;
+      output_buffer *tmp_buffer = pp_buffer (pp);
+      pp_buffer (pp) = pp_error_buffer;
       pp_really_flush (pp);
       ++errorcount;
       gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
-      pp->buffer = tmp_buffer;
+      pp_buffer (pp) = tmp_buffer;
       diagnostic_action_after_output (global_dc, DK_ERROR);
       diagnostic_check_max_errors (global_dc, true);
       return true;
diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index 285d76b35406..8294465fd9f7 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -155,7 +155,7 @@  print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
 {
   pretty_printer pp;
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   pp_gimple_stmt_1 (&pp, g, spc, flags);
   pp_newline_and_flush (&pp);
 }
@@ -186,7 +186,7 @@  print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
   flags |= TDF_RHS_ONLY;
   pretty_printer pp;
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   pp_gimple_stmt_1 (&pp, g, spc, flags);
   pp_flush (&pp);
 }
@@ -222,7 +222,7 @@  print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
 {
   pretty_printer pp;
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   dump_gimple_seq (&pp, seq, spc, flags);
   pp_newline_and_flush (&pp);
 }
@@ -2377,7 +2377,7 @@  dump_ssaname_info_to_file (FILE *file, tree node, int spc)
 {
   pretty_printer pp;
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   dump_ssaname_info (&pp, node, spc);
   pp_flush (&pp);
 }
@@ -3095,7 +3095,7 @@  gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
     {
       pretty_printer pp;
       pp_needs_newline (&pp) = true;
-      pp.buffer->stream = file;
+      pp.set_output_stream (file);
       gimple_dump_bb_buff (&pp, bb, indent, flags);
     }
   dump_gimple_bb_footer (file, bb, indent, flags);
diff --git a/gcc/graph.cc b/gcc/graph.cc
index 5689a64b20b4..07da0798f51d 100644
--- a/gcc/graph.cc
+++ b/gcc/graph.cc
@@ -310,7 +310,7 @@  void DEBUG_FUNCTION
 print_graph_cfg (FILE *fp, struct function *fun)
 {
   pretty_printer graph_slim_pp;
-  graph_slim_pp.buffer->stream = fp;
+  graph_slim_pp.set_output_stream (fp);
   pretty_printer *const pp = &graph_slim_pp;
   const char *funcname = function_name (fun);
   pp_printf (pp, "subgraph \"cluster_%s\" {\n"
@@ -354,7 +354,7 @@  static void
 start_graph_dump (FILE *fp, const char *base)
 {
   pretty_printer graph_slim_pp;
-  graph_slim_pp.buffer->stream = fp;
+  graph_slim_pp.set_output_stream (fp);
   pretty_printer *const pp = &graph_slim_pp;
   pp_string (pp, "digraph \"");
   pp_write_text_to_stream (pp);
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index 68a2e860c1fb..24fb1d7ddc9e 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -4410,7 +4410,7 @@  recording::function::dump_to_dot (const char *path)
     return;
 
   pretty_printer the_pp;
-  the_pp.buffer->stream = fp;
+  the_pp.set_output_stream (fp);
 
   pretty_printer *pp = &the_pp;
 
diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc
index 94d1f4e5a2c6..61f2b6762565 100644
--- a/gcc/langhooks.cc
+++ b/gcc/langhooks.cc
@@ -466,8 +466,7 @@  lhd_print_error_function (diagnostic_context *context, const char *file,
 
       diagnostic_set_last_function (context, diagnostic);
       pp_newline_and_flush (context->printer);
-      context->printer->prefix = old_prefix;
-      free ((char*) new_prefix);
+      context->printer->set_prefix (old_prefix);
     }
 }
 
diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 6dcf8b469a3c..84835a888ef1 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -1361,11 +1361,11 @@  init_num_threads (void)
 void
 print_lto_docs_link ()
 {
-  bool print_url = global_dc->printer->url_format != URL_FORMAT_NONE;
+  bool print_url = global_dc->printer->supports_urls_p ();
   const char *url = global_dc->make_option_url (OPT_flto);
 
   pretty_printer pp;
-  pp.url_format = URL_FORMAT_DEFAULT;
+  pp.set_url_format (URL_FORMAT_DEFAULT);
   pp_string (&pp, "see the ");
   if (print_url)
     pp_begin_url (&pp, url);
diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc
index eb59bf424b7c..271cd650c4d1 100644
--- a/gcc/pretty-print.cc
+++ b/gcc/pretty-print.cc
@@ -814,34 +814,35 @@  output_buffer::~output_buffer ()
 
 /* Subroutine of pp_set_maximum_length.  Set up PRETTY-PRINTER's
    internal maximum characters per line.  */
-static void
-pp_set_real_maximum_length (pretty_printer *pp)
+
+void
+pretty_printer::set_real_maximum_length ()
 {
   /* If we're told not to wrap lines then do the obvious thing.  In case
      we'll emit prefix only once per message, it is appropriate
      not to increase unnecessarily the line-length cut-off.  */
-  if (!pp_is_wrapping_line (pp)
-      || pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_ONCE
-      || pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
-    pp->maximum_length = pp_line_cutoff (pp);
+  if (!pp_is_wrapping_line (this)
+      || pp_prefixing_rule (this) == DIAGNOSTICS_SHOW_PREFIX_ONCE
+      || pp_prefixing_rule (this) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
+    m_maximum_length = pp_line_cutoff (this);
   else
     {
-      int prefix_length = pp->prefix ? strlen (pp->prefix) : 0;
+      int prefix_length = m_prefix ? strlen (m_prefix) : 0;
       /* If the prefix is ridiculously too long, output at least
          32 characters.  */
-      if (pp_line_cutoff (pp) - prefix_length < 32)
-	pp->maximum_length = pp_line_cutoff (pp) + 32;
+      if (pp_line_cutoff (this) - prefix_length < 32)
+	m_maximum_length = pp_line_cutoff (this) + 32;
       else
-	pp->maximum_length = pp_line_cutoff (pp);
+	m_maximum_length = pp_line_cutoff (this);
     }
 }
 
-/* Clear PRETTY-PRINTER's output state.  */
-static inline void
-pp_clear_state (pretty_printer *pp)
+/* Clear this pretty_printer's output state.  */
+inline void
+pretty_printer::clear_state ()
 {
-  pp->emitted_prefix = false;
-  pp_indentation (pp) = 0;
+  m_emitted_prefix = false;
+  pp_indentation (this) = 0;
 }
 
 /* Print X to PP in decimal.  */
@@ -1006,7 +1007,7 @@  pp_wrap_text (pretty_printer *pp, const char *start, const char *end)
 	while (p != end && !ISBLANK (*p) && *p != '\n')
 	  ++p;
 	if (wrapping_line
-            && p - start >= pp_remaining_character_count_for_line (pp))
+	    && p - start >= pp->remaining_character_count_for_line ())
 	  pp_newline (pp);
 	pp_append_text (pp, start, p);
 	start = p;
@@ -1101,7 +1102,7 @@  urlify_quoted_string (pretty_printer *pp,
 		      size_t quoted_text_start_idx,
 		      size_t quoted_text_end_idx)
 {
-  if (pp->url_format == URL_FORMAT_NONE)
+  if (!pp->supports_urls_p ())
     return quoted_text_end_idx;
   if (!urlifier)
     return quoted_text_end_idx;
@@ -1125,7 +1126,7 @@  urlify_quoted_string (pretty_printer *pp,
 
   /*  ...with URLified version of the text.  */
   /* Begin URL.  */
-  switch (pp->url_format)
+  switch (pp->get_url_format ())
     {
     default:
     case URL_FORMAT_NONE:
@@ -1305,7 +1306,8 @@  on_end_quote (pretty_printer *pp,
    1 up to highest argument; each argument may only be used once.
    A format string can have at most 30 arguments.  */
 
-/* Formatting phases 1 and 2: render TEXT->format_spec plus
+/* Implementation of pp_format.
+   Formatting phases 1 and 2: render TEXT->format_spec plus
    text->m_args_ptr into a series of chunks in pp_buffer (PP)->args[].
    Phase 3 is in pp_output_formatted_text.
 
@@ -1322,27 +1324,22 @@  on_end_quote (pretty_printer *pp,
    are stashed into the output_buffer's m_quotes for use in phase 3.  */
 
 void
-pp_format (pretty_printer *pp,
-	   text_info *text,
-	   const urlifier *urlifier)
+pretty_printer::format (text_info *text,
+			const urlifier *urlifier)
 {
-  output_buffer * const buffer = pp_buffer (pp);
-  const char *p;
-  const char **args;
-  struct chunk_info *new_chunk_array;
+  output_buffer * const buffer = m_buffer;
 
-  unsigned int curarg = 0, chunk = 0, argno;
-  pp_wrapping_mode_t old_wrapping_mode;
-  bool any_unnumbered = false, any_numbered = false;
+  unsigned int chunk = 0, argno;
   const char **formatters[PP_NL_ARGMAX];
 
   /* Allocate a new chunk structure.  */
-  new_chunk_array = XOBNEW (&buffer->chunk_obstack, struct chunk_info);
+  struct chunk_info *new_chunk_array
+    = XOBNEW (&buffer->chunk_obstack, struct chunk_info);
 
   new_chunk_array->prev = buffer->cur_chunk_array;
   new_chunk_array->m_quotes = nullptr;
   buffer->cur_chunk_array = new_chunk_array;
-  args = new_chunk_array->args;
+  const char **args = new_chunk_array->args;
 
   /* Formatting phase 1: split up TEXT->format_spec into chunks in
      pp_buffer (PP)->args[].  Even-numbered chunks are to be output
@@ -1352,7 +1349,9 @@  pp_format (pretty_printer *pp,
 
   memset (formatters, 0, sizeof formatters);
 
-  for (p = text->m_format_spec; *p; )
+  unsigned int curarg = 0;
+  bool any_unnumbered = false, any_numbered = false;
+  for (const char *p = text->m_format_spec; *p; )
     {
       while (*p != '\0' && *p != '%')
 	{
@@ -1377,8 +1376,7 @@  pp_format (pretty_printer *pp,
 	  {
 	    obstack_grow (&buffer->chunk_obstack,
 			  open_quote, strlen (open_quote));
-	    const char *colorstr
-	      = colorize_start (pp_show_color (pp), "quote");
+	    const char *colorstr = colorize_start (m_show_color, "quote");
 	    obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr));
 	    p++;
 
@@ -1388,9 +1386,9 @@  pp_format (pretty_printer *pp,
 
 	case '>':
 	  {
-	    on_end_quote (pp, *buffer, chunk, urlifier);
+	    on_end_quote (this, *buffer, chunk, urlifier);
 
-	    const char *colorstr = colorize_stop (pp_show_color (pp));
+	    const char *colorstr = colorize_stop (m_show_color);
 	    obstack_grow (&buffer->chunk_obstack, colorstr, strlen (colorstr));
 	  }
 	  /* FALLTHRU */
@@ -1402,7 +1400,7 @@  pp_format (pretty_printer *pp,
 
 	case '}':
 	  {
-	    const char *endurlstr = get_end_url_string (pp);
+	    const char *endurlstr = get_end_url_string (this);
 	    obstack_grow (&buffer->chunk_obstack, endurlstr,
 			  strlen (endurlstr));
 	  }
@@ -1411,7 +1409,7 @@  pp_format (pretty_printer *pp,
 
 	case 'R':
 	  {
-	    const char *colorstr = colorize_stop (pp_show_color (pp));
+	    const char *colorstr = colorize_stop (m_show_color);
 	    obstack_grow (&buffer->chunk_obstack, colorstr,
 			  strlen (colorstr));
 	    p++;
@@ -1520,7 +1518,7 @@  pp_format (pretty_printer *pp,
      prefixing off.  */
   buffer->obstack = &buffer->chunk_obstack;
   const int old_line_length = buffer->line_length;
-  old_wrapping_mode = pp_set_verbatim_wrapping (pp);
+  const pp_wrapping_mode_t old_wrapping_mode = pp_set_verbatim_wrapping (this);
 
   /* Second phase.  Replace each formatter with the formatted text it
      corresponds to.  */
@@ -1533,6 +1531,8 @@  pp_format (pretty_printer *pp,
       bool hash = false;
       bool quote = false;
 
+      const char *p;
+
       /* We do not attempt to enforce any ordering on the modifier
 	 characters.  */
 
@@ -1583,14 +1583,14 @@  pp_format (pretty_printer *pp,
 
       if (quote)
 	{
-	  pp_begin_quote (pp, pp_show_color (pp));
+	  pp_begin_quote (this, m_show_color);
 	  on_begin_quote (*buffer, chunk, urlifier);
 	}
 
       switch (*p)
 	{
 	case 'r':
-	  pp_string (pp, colorize_start (pp_show_color (pp),
+	  pp_string (this, colorize_start (m_show_color,
 					 va_arg (*text->m_args_ptr,
 						 const char *)));
 	  break;
@@ -1602,11 +1602,11 @@  pp_format (pretty_printer *pp,
 	       "\x" prefix.  Otherwise print them all unchanged.  */
 	    int chr = va_arg (*text->m_args_ptr, int);
 	    if (ISPRINT (chr) || !quote)
-	      pp_character (pp, chr);
+	      pp_character (this, chr);
 	    else
 	      {
 		const char str [2] = { chr, '\0' };
-		pp_quoted_string (pp, str, 1);
+		pp_quoted_string (this, str, 1);
 	      }
 	    break;
 	  }
@@ -1614,43 +1614,43 @@  pp_format (pretty_printer *pp,
 	case 'd':
 	case 'i':
 	  if (wide)
-	    pp_wide_integer (pp, va_arg (*text->m_args_ptr, HOST_WIDE_INT));
+	    pp_wide_integer (this, va_arg (*text->m_args_ptr, HOST_WIDE_INT));
 	  else
-	    pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+	    pp_integer_with_precision (this, *text->m_args_ptr, precision,
 				       int, "d");
 	  break;
 
 	case 'o':
 	  if (wide)
-	    pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o",
+	    pp_scalar (this, "%" HOST_WIDE_INT_PRINT "o",
 		       va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
 	  else
-	    pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+	    pp_integer_with_precision (this, *text->m_args_ptr, precision,
 				       unsigned, "o");
 	  break;
 
 	case 's':
 	  if (quote)
-	    pp_quoted_string (pp, va_arg (*text->m_args_ptr, const char *));
+	    pp_quoted_string (this, va_arg (*text->m_args_ptr, const char *));
 	  else
-	    pp_string (pp, va_arg (*text->m_args_ptr, const char *));
+	    pp_string (this, va_arg (*text->m_args_ptr, const char *));
 	  break;
 
 	case 'p':
-	  pp_pointer (pp, va_arg (*text->m_args_ptr, void *));
+	  pp_pointer (this, va_arg (*text->m_args_ptr, void *));
 	  break;
 
 	case 'u':
 	  if (wide)
-	    pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED,
+	    pp_scalar (this, HOST_WIDE_INT_PRINT_UNSIGNED,
 		       va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
 	  else
-	    pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+	    pp_integer_with_precision (this, *text->m_args_ptr, precision,
 				       unsigned, "u");
 	  break;
 
 	case 'f':
-	  pp_double (pp, va_arg (*text->m_args_ptr, double));
+	  pp_double (this, va_arg (*text->m_args_ptr, double));
 	  break;
 
 	case 'Z':
@@ -1660,11 +1660,11 @@  pp_format (pretty_printer *pp,
 
 	    for (unsigned i = 0; i < len; ++i)
 	      {
-		pp_scalar (pp, "%i", v[i]);
+		pp_scalar (this, "%i", v[i]);
 		if (i < len - 1)
 		  {
-		    pp_comma (pp);
-		    pp_space (pp);
+		    pp_comma (this);
+		    pp_space (this);
 		  }
 	      }
 	    break;
@@ -1672,10 +1672,10 @@  pp_format (pretty_printer *pp,
 
 	case 'x':
 	  if (wide)
-	    pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
+	    pp_scalar (this, HOST_WIDE_INT_PRINT_HEX,
 		       va_arg (*text->m_args_ptr, unsigned HOST_WIDE_INT));
 	  else
-	    pp_integer_with_precision (pp, *text->m_args_ptr, precision,
+	    pp_integer_with_precision (this, *text->m_args_ptr, precision,
 				       unsigned, "x");
 	  break;
 
@@ -1714,7 +1714,7 @@  pp_format (pretty_printer *pp,
 	       Negative precision is treated as if it were omitted.  */
 	    size_t len = n < 0 ? strlen (s) : strnlen (s, n);
 
-	    pp_append_text (pp, s, s + len);
+	    pp_append_text (this, s, s + len);
 	  }
 	  break;
 
@@ -1725,16 +1725,16 @@  pp_format (pretty_printer *pp,
 	      = va_arg (*text->m_args_ptr, diagnostic_event_id_ptr);
 	    gcc_assert (event_id->known_p ());
 
-	    pp_string (pp, colorize_start (pp_show_color (pp), "path"));
-	    pp_character (pp, '(');
-	    pp_decimal_int (pp, event_id->one_based ());
-	    pp_character (pp, ')');
-	    pp_string (pp, colorize_stop (pp_show_color (pp)));
+	    pp_string (this, colorize_start (m_show_color, "path"));
+	    pp_character (this, '(');
+	    pp_decimal_int (this, event_id->one_based ());
+	    pp_character (this, ')');
+	    pp_string (this, colorize_stop (m_show_color));
 	  }
 	  break;
 
 	case '{':
-	  pp_begin_url (pp, va_arg (*text->m_args_ptr, const char *));
+	  begin_url (va_arg (*text->m_args_ptr, const char *));
 	  break;
 
 	default:
@@ -1746,18 +1746,18 @@  pp_format (pretty_printer *pp,
 	       potentially disable printing of the closing quote
 	       (e.g. when printing "'TYPEDEF' aka 'TYPE'" in the C family
 	       of frontends).  */
-	    gcc_assert (pp_format_decoder (pp));
-	    ok = pp_format_decoder (pp) (pp, text, p,
-					 precision, wide, plus, hash, &quote,
-					 formatters[argno]);
+	    gcc_assert (pp_format_decoder (this));
+	    ok = m_format_decoder (this, text, p,
+				   precision, wide, plus, hash, &quote,
+				   formatters[argno]);
 	    gcc_assert (ok);
 	  }
 	}
 
       if (quote)
 	{
-	  on_end_quote (pp, *buffer, chunk, urlifier);
-	  pp_end_quote (pp, pp_show_color (pp));
+	  on_end_quote (this, *buffer, chunk, urlifier);
+	  pp_end_quote (this, m_show_color);
 	}
 
       obstack_1grow (&buffer->chunk_obstack, '\0');
@@ -1770,14 +1770,14 @@  pp_format (pretty_printer *pp,
 
   /* If the client supplied a postprocessing object, call its "handle"
      hook here.  */
-  if (pp->m_format_postprocessor)
-    pp->m_format_postprocessor->handle (pp);
+  if (m_format_postprocessor)
+    m_format_postprocessor->handle (this);
 
   /* Revert to normal obstack and wrapping mode.  */
   buffer->obstack = &buffer->formatted_obstack;
   buffer->line_length = old_line_length;
-  pp_wrapping_mode (pp) = old_wrapping_mode;
-  pp_clear_state (pp);
+  pp_wrapping_mode (this) = old_wrapping_mode;
+  clear_state ();
 }
 
 struct auto_obstack
@@ -1923,7 +1923,7 @@  pp_output_formatted_text (pretty_printer *pp,
 
   /* If we have any deferred urlification, handle it now.  */
   if (urlifier
-      && pp->url_format != URL_FORMAT_NONE
+      && pp->supports_urls_p ()
       && buffer->cur_chunk_array->m_quotes
       && buffer->cur_chunk_array->m_quotes->has_phase_3_quotes_p ())
     buffer->cur_chunk_array->m_quotes->handle_phase_3 (pp, *urlifier);
@@ -1959,8 +1959,8 @@  pp_format_verbatim (pretty_printer *pp, text_info *text)
 void
 pp_flush (pretty_printer *pp)
 {
-  pp_clear_state (pp);
-  if (!pp->buffer->flush_p)
+  pp->clear_state ();
+  if (!pp_buffer (pp)->flush_p)
     return;
   pp_write_text_to_stream (pp);
   fflush (pp_buffer (pp)->stream);
@@ -1971,7 +1971,7 @@  pp_flush (pretty_printer *pp)
 void
 pp_really_flush (pretty_printer *pp)
 {
-  pp_clear_state (pp);
+  pp->clear_state ();
   pp_write_text_to_stream (pp);
   fflush (pp_buffer (pp)->stream);
 }
@@ -1983,7 +1983,7 @@  void
 pp_set_line_maximum_length (pretty_printer *pp, int length)
 {
   pp_line_cutoff (pp) = length;
-  pp_set_real_maximum_length (pp);
+  pp->set_real_maximum_length ();
 }
 
 /* Clear PRETTY-PRINTER output area text info.  */
@@ -1999,13 +1999,13 @@  pp_clear_output_area (pretty_printer *pp)
    will eventually be free-ed.  */
 
 void
-pp_set_prefix (pretty_printer *pp, char *prefix)
+pretty_printer::set_prefix (char *prefix)
 {
-  free (pp->prefix);
-  pp->prefix = prefix;
-  pp_set_real_maximum_length (pp);
-  pp->emitted_prefix = false;
-  pp_indentation (pp) = 0;
+  free (m_prefix);
+  m_prefix = prefix;
+  set_real_maximum_length ();
+  m_emitted_prefix = false;
+  pp_indentation (this) = 0;
 }
 
 /* Take ownership of PP's prefix, setting it to NULL.
@@ -2015,8 +2015,8 @@  pp_set_prefix (pretty_printer *pp, char *prefix)
 char *
 pp_take_prefix (pretty_printer *pp)
 {
-  char *result = pp->prefix;
-  pp->prefix = NULL;
+  char *result = pp->m_prefix;
+  pp->m_prefix = nullptr;
   return result;
 }
 
@@ -2024,39 +2024,39 @@  pp_take_prefix (pretty_printer *pp)
 void
 pp_destroy_prefix (pretty_printer *pp)
 {
-  if (pp->prefix != NULL)
+  if (pp->m_prefix)
     {
-      free (pp->prefix);
-      pp->prefix = NULL;
+      free (pp->m_prefix);
+      pp->m_prefix = nullptr;
     }
 }
 
-/* Write out PRETTY-PRINTER's prefix.  */
+/* Write out this pretty_printer's prefix.  */
 void
-pp_emit_prefix (pretty_printer *pp)
+pretty_printer::emit_prefix ()
 {
-  if (pp->prefix != NULL)
+  if (m_prefix)
     {
-      switch (pp_prefixing_rule (pp))
+      switch (pp_prefixing_rule (this))
 	{
 	default:
 	case DIAGNOSTICS_SHOW_PREFIX_NEVER:
 	  break;
 
 	case DIAGNOSTICS_SHOW_PREFIX_ONCE:
-	  if (pp->emitted_prefix)
+	  if (m_emitted_prefix)
 	    {
-	      pp_indent (pp);
+	      pp_indent (this);
 	      break;
 	    }
-	  pp_indentation (pp) += 3;
+	  pp_indentation (this) += 3;
 	  /* Fall through.  */
 
 	case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
 	  {
-	    int prefix_length = strlen (pp->prefix);
-	    pp_append_r (pp, pp->prefix, prefix_length);
-	    pp->emitted_prefix = true;
+	    int prefix_length = strlen (m_prefix);
+	    pp_append_r (this, m_prefix, prefix_length);
+	    m_emitted_prefix = true;
 	  }
 	  break;
 	}
@@ -2066,19 +2066,19 @@  pp_emit_prefix (pretty_printer *pp)
 /* Construct a PRETTY-PRINTER of MAXIMUM_LENGTH characters per line.  */
 
 pretty_printer::pretty_printer (int maximum_length)
-  : buffer (new (XCNEW (output_buffer)) output_buffer ()),
-    prefix (),
-    padding (pp_none),
-    maximum_length (),
-    indent_skip (),
-    wrapping (),
-    format_decoder (),
+  : m_buffer (new (XCNEW (output_buffer)) output_buffer ()),
+    m_prefix (nullptr),
+    m_padding (pp_none),
+    m_maximum_length (0),
+    m_indent_skip (0),
+    m_wrapping (),
+    m_format_decoder (nullptr),
     m_format_postprocessor (NULL),
-    emitted_prefix (),
-    need_newline (),
-    translate_identifiers (true),
-    show_color (),
-    url_format (URL_FORMAT_NONE),
+    m_emitted_prefix (false),
+    m_need_newline (false),
+    m_translate_identifiers (true),
+    m_show_color (false),
+    m_url_format (URL_FORMAT_NONE),
     m_skipping_null_url (false)
 {
   pp_line_cutoff (this) = maximum_length;
@@ -2090,22 +2090,22 @@  pretty_printer::pretty_printer (int maximum_length)
 /* Copy constructor for pretty_printer.  */
 
 pretty_printer::pretty_printer (const pretty_printer &other)
-: buffer (new (XCNEW (output_buffer)) output_buffer ()),
-  prefix (),
-  padding (other.padding),
-  maximum_length (other.maximum_length),
-  indent_skip (other.indent_skip),
-  wrapping (other.wrapping),
-  format_decoder (other.format_decoder),
+: m_buffer (new (XCNEW (output_buffer)) output_buffer ()),
+  m_prefix (nullptr),
+  m_padding (other.m_padding),
+  m_maximum_length (other.m_maximum_length),
+  m_indent_skip (other.m_indent_skip),
+  m_wrapping (other.m_wrapping),
+  m_format_decoder (other.m_format_decoder),
   m_format_postprocessor (NULL),
-  emitted_prefix (other.emitted_prefix),
-  need_newline (other.need_newline),
-  translate_identifiers (other.translate_identifiers),
-  show_color (other.show_color),
-  url_format (other.url_format),
+  m_emitted_prefix (other.m_emitted_prefix),
+  m_need_newline (other.m_need_newline),
+  m_translate_identifiers (other.m_translate_identifiers),
+  m_show_color (other.m_show_color),
+  m_url_format (other.m_url_format),
   m_skipping_null_url (false)
 {
-  pp_line_cutoff (this) = maximum_length;
+  pp_line_cutoff (this) = m_maximum_length;
   /* By default, we emit prefixes once per message.  */
   pp_prefixing_rule (this) = pp_prefixing_rule (&other);
   pp_set_prefix (this, NULL);
@@ -2118,9 +2118,9 @@  pretty_printer::~pretty_printer ()
 {
   if (m_format_postprocessor)
     delete m_format_postprocessor;
-  buffer->~output_buffer ();
-  XDELETE (buffer);
-  free (prefix);
+  m_buffer->~output_buffer ();
+  XDELETE (m_buffer);
+  free (m_prefix);
 }
 
 /* Base class implementation of pretty_printer::clone vfunc.  */
@@ -2142,7 +2142,7 @@  pp_append_text (pretty_printer *pp, const char *start, const char *end)
   /* Emit prefix and skip whitespace if we're starting a new line.  */
   if (pp_buffer (pp)->line_length == 0)
     {
-      pp_emit_prefix (pp);
+      pp->emit_prefix ();
       if (pp_is_wrapping_line (pp))
 	while (start != end && *start == ' ')
 	  ++start;
@@ -2169,12 +2169,11 @@  pp_last_position_in_text (const pretty_printer *pp)
 /* Return the amount of characters PRETTY-PRINTER can accept to
    make a full line.  Meaningful only in line-wrapping mode.  */
 int
-pp_remaining_character_count_for_line (pretty_printer *pp)
+pretty_printer::remaining_character_count_for_line ()
 {
-  return pp->maximum_length - pp_buffer (pp)->line_length;
+  return m_maximum_length - pp_buffer (this)->line_length;
 }
 
-
 /* Format a message into BUFFER a la printf.  */
 void
 pp_printf (pretty_printer *pp, const char *msg, ...)
@@ -2219,7 +2218,7 @@  pp_character (pretty_printer *pp, int c)
   if (pp_is_wrapping_line (pp)
       /* If printing UTF-8, don't wrap in the middle of a sequence.  */
       && (((unsigned int) c) & 0xC0) != 0x80
-      && pp_remaining_character_count_for_line (pp) <= 0)
+      && pp->remaining_character_count_for_line () <= 0)
     {
       pp_newline (pp);
       if (ISSPACE (c))
@@ -2319,12 +2318,12 @@  pp_quoted_string (pretty_printer *pp, const char *str, size_t n /* = -1 */)
 /* Maybe print out a whitespace if needed.  */
 
 void
-pp_maybe_space (pretty_printer *pp)
+pretty_printer::maybe_space ()
 {
-  if (pp->padding != pp_none)
+  if (m_padding != pp_none)
     {
-      pp_space (pp);
-      pp->padding = pp_none;
+      pp_space (this);
+      m_padding = pp_none;
     }
 }
 
@@ -2625,28 +2624,28 @@  identifier_to_locale (const char *ident)
    for the given URL.  */
 
 void
-pp_begin_url (pretty_printer *pp, const char *url)
+pretty_printer::begin_url (const char *url)
 {
   if (!url)
     {
       /* Handle null URL by skipping all output here,
 	 and in the next pp_end_url.  */
-      pp->m_skipping_null_url = true;
+      m_skipping_null_url = true;
       return;
     }
-  switch (pp->url_format)
+  switch (m_url_format)
     {
     case URL_FORMAT_NONE:
       break;
     case URL_FORMAT_ST:
-      pp_string (pp, "\33]8;;");
-      pp_string (pp, url);
-      pp_string (pp, "\33\\");
+      pp_string (this, "\33]8;;");
+      pp_string (this, url);
+      pp_string (this, "\33\\");
       break;
     case URL_FORMAT_BEL:
-      pp_string (pp, "\33]8;;");
-      pp_string (pp, url);
-      pp_string (pp, "\a");
+      pp_string (this, "\33]8;;");
+      pp_string (this, url);
+      pp_string (this, "\a");
       break;
     default:
       gcc_unreachable ();
@@ -2659,7 +2658,7 @@  pp_begin_url (pretty_printer *pp, const char *url)
 static const char *
 get_end_url_string (pretty_printer *pp)
 {
-  switch (pp->url_format)
+  switch (pp->get_url_format ())
     {
     case URL_FORMAT_NONE:
       return "";
@@ -2675,17 +2674,17 @@  get_end_url_string (pretty_printer *pp)
 /* If URL-printing is enabled, write a "close URL" escape sequence to PP.  */
 
 void
-pp_end_url (pretty_printer *pp)
+pretty_printer::end_url ()
 {
-  if (pp->m_skipping_null_url)
+  if (m_skipping_null_url)
     {
       /* We gracefully handle pp_begin_url (NULL) by omitting output for
 	 both begin and end.  Here we handle the latter.  */
-      pp->m_skipping_null_url = false;
+      m_skipping_null_url = false;
       return;
     }
-  if (pp->url_format != URL_FORMAT_NONE)
-    pp_string (pp, get_end_url_string (pp));
+  if (m_url_format != URL_FORMAT_NONE)
+    pp_string (this, get_end_url_string (this));
 }
 
 #if CHECKING_P
@@ -2925,7 +2924,7 @@  class test_pretty_printer : public pretty_printer
 		       int max_line_length)
   {
     pp_set_prefix (this, xstrdup ("PREFIX: "));
-    wrapping.rule = rule;
+    pp_prefixing_rule (this) = rule;
     pp_set_line_maximum_length (this, max_line_length);
   }
 };
@@ -3018,7 +3017,7 @@  test_urls ()
 {
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_NONE;
+    pp.set_url_format (URL_FORMAT_NONE);
     pp_begin_url (&pp, "http://example.com");
     pp_string (&pp, "This is a link");
     pp_end_url (&pp);
@@ -3028,7 +3027,7 @@  test_urls ()
 
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_begin_url (&pp, "http://example.com");
     pp_string (&pp, "This is a link");
     pp_end_url (&pp);
@@ -3038,7 +3037,7 @@  test_urls ()
 
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_BEL;
+    pp.set_url_format (URL_FORMAT_BEL);
     pp_begin_url (&pp, "http://example.com");
     pp_string (&pp, "This is a link");
     pp_end_url (&pp);
@@ -3054,7 +3053,7 @@  test_null_urls ()
 {
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_NONE;
+    pp.set_url_format (URL_FORMAT_NONE);
     pp_begin_url (&pp, nullptr);
     pp_string (&pp, "This isn't a link");
     pp_end_url (&pp);
@@ -3064,7 +3063,7 @@  test_null_urls ()
 
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_begin_url (&pp, nullptr);
     pp_string (&pp, "This isn't a link");
     pp_end_url (&pp);
@@ -3074,7 +3073,7 @@  test_null_urls ()
 
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_BEL;
+    pp.set_url_format (URL_FORMAT_BEL);
     pp_begin_url (&pp, nullptr);
     pp_string (&pp, "This isn't a link");
     pp_end_url (&pp);
@@ -3122,7 +3121,7 @@  test_urlification ()
   {
     {
       pretty_printer pp;
-      pp.url_format = URL_FORMAT_NONE;
+      pp.set_url_format (URL_FORMAT_NONE);
       pp_printf_with_urlifier (&pp, &urlifier,
 			       "foo %<-foption%> %<unrecognized%> bar");
       ASSERT_STREQ ("foo `-foption' `unrecognized' bar",
@@ -3130,7 +3129,7 @@  test_urlification ()
     }
     {
       pretty_printer pp;
-      pp.url_format = URL_FORMAT_ST;
+      pp.set_url_format (URL_FORMAT_ST);
       pp_printf_with_urlifier (&pp, &urlifier,
 			       "foo %<-foption%> %<unrecognized%> bar");
       ASSERT_STREQ
@@ -3140,7 +3139,7 @@  test_urlification ()
     }
     {
       pretty_printer pp;
-      pp.url_format = URL_FORMAT_BEL;
+      pp.set_url_format (URL_FORMAT_BEL);
       pp_printf_with_urlifier (&pp, &urlifier,
 			       "foo %<-foption%> %<unrecognized%> bar");
       ASSERT_STREQ
@@ -3153,7 +3152,7 @@  test_urlification ()
   /* Use of "%qs".  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %qs %qs bar",
 			     "-foption", "unrecognized");
@@ -3167,7 +3166,7 @@  test_urlification ()
      a mixture of phase 1 and phase 2.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<-f%s%> bar",
 			     "option");
@@ -3180,7 +3179,7 @@  test_urlification ()
      quoted region.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<-f%sion%> bar %<-f%sion%> baz",
 			     "opt", "opt");
@@ -3192,7 +3191,7 @@  test_urlification ()
   /* Likewise.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<%sption%> bar %<-f%sion%> baz",
 			     "-fo", "opt");
@@ -3205,7 +3204,7 @@  test_urlification ()
      between a mixture of phase 1 and multiple phase 2.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<-f%s%s%> bar",
 			     "opt", "ion");
@@ -3217,7 +3216,7 @@  test_urlification ()
   /* Mixed usage of %< and %s with a prefix.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_set_prefix (&pp, xstrdup ("PREFIX"));
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<-f%s%> bar",
@@ -3230,7 +3229,7 @@  test_urlification ()
   /* Example of mixed %< and %s with numbered args.  */
   {
     pretty_printer pp;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     pp_printf_with_urlifier (&pp, &urlifier,
 			     "foo %<-f%2$st%1$sn%> bar",
 			     "io", "op");
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h
index 14a225eefe06..99e55dc6a3c0 100644
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -189,25 +189,12 @@  struct pp_wrapping_mode_t
   int line_cutoff;
 };
 
-/* Maximum characters per line in automatic line wrapping mode.
-   Zero means don't wrap lines.  */
-#define pp_line_cutoff(PP)  (PP)->wrapping.line_cutoff
-
-/* Prefixing rule used in formatting a diagnostic message.  */
-#define pp_prefixing_rule(PP)  (PP)->wrapping.rule
-
-/* Get or set the wrapping mode as a single entity.  */
-#define pp_wrapping_mode(PP) (PP)->wrapping
-
 /* The type of a hook that formats client-specific data onto a pretty_printer.
    A client-supplied formatter returns true if everything goes well,
    otherwise it returns false.  */
 typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
 			    int, bool, bool, bool, bool *, const char **);
 
-/* Client supplied function used to decode formats.  */
-#define pp_format_decoder(PP) (PP)->format_decoder
-
 /* Base class for an optional client-supplied object for doing additional
    processing between stages 2 and 3 of formatted printing.  */
 class format_postprocessor
@@ -218,31 +205,51 @@  class format_postprocessor
   virtual void handle (pretty_printer *) = 0;
 };
 
-/* TRUE if a newline character needs to be added before further
-   formatting.  */
-#define pp_needs_newline(PP)  (PP)->need_newline
+inline bool & pp_needs_newline (pretty_printer *pp);
 
 /* True if PRETTY-PRINTER is in line-wrapping mode.  */
 #define pp_is_wrapping_line(PP) (pp_line_cutoff (PP) > 0)
 
-/* The amount of whitespace to be emitted when starting a new line.  */
-#define pp_indentation(PP) (PP)->indent_skip
-
-/* True if identifiers are translated to the locale character set on
-   output.  */
-#define pp_translate_identifiers(PP) (PP)->translate_identifiers
-
-/* True if colors should be shown.  */
-#define pp_show_color(PP) (PP)->show_color
+inline output_buffer *&pp_buffer (pretty_printer *pp);
+inline output_buffer *pp_buffer (const pretty_printer *pp);
+inline const char *pp_get_prefix (const pretty_printer *pp);
+extern char *pp_take_prefix (pretty_printer *);
+extern void pp_destroy_prefix (pretty_printer *);
+inline int &pp_line_cutoff (pretty_printer *pp);
+inline diagnostic_prefixing_rule_t &pp_prefixing_rule (pretty_printer *pp);
+inline pp_wrapping_mode_t &pp_wrapping_mode (pretty_printer *pp);
+inline int & pp_indentation (pretty_printer *pp);
+inline bool & pp_translate_identifiers (pretty_printer *pp);
+inline bool & pp_show_color (pretty_printer *pp);
+inline printer_fn &pp_format_decoder (pretty_printer *pp);
+inline format_postprocessor *& pp_format_postprocessor (pretty_printer *pp);
 
 class urlifier;
 
 /* 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 derive from this structure
    and add additional fields they need.  */
 class pretty_printer
 {
 public:
+  friend inline output_buffer *&pp_buffer (pretty_printer *pp);
+  friend inline output_buffer *pp_buffer (const pretty_printer *pp);
+  friend inline const char *pp_get_prefix (const pretty_printer *pp);
+  friend char *pp_take_prefix (pretty_printer *);
+  friend void pp_destroy_prefix (pretty_printer *);
+  friend inline int &pp_line_cutoff (pretty_printer *pp);
+  friend inline diagnostic_prefixing_rule_t &
+  pp_prefixing_rule (pretty_printer *pp);
+  friend inline const diagnostic_prefixing_rule_t &
+  pp_prefixing_rule (const pretty_printer *pp);
+  friend inline pp_wrapping_mode_t &pp_wrapping_mode (pretty_printer *pp);
+  friend bool & pp_needs_newline (pretty_printer *pp);
+  friend int & pp_indentation (pretty_printer *pp);
+  friend bool & pp_translate_identifiers (pretty_printer *pp);
+  friend bool & pp_show_color (pretty_printer *pp);
+  friend printer_fn &pp_format_decoder (pretty_printer *pp);
+  friend format_postprocessor *& pp_format_postprocessor (pretty_printer *pp);
+
   /* Default construct a pretty printer with specified
      maximum line length cut off limit.  */
   explicit pretty_printer (int = 0);
@@ -252,25 +259,67 @@  public:
 
   virtual pretty_printer *clone () const;
 
+  void set_output_stream (FILE *outfile)
+  {
+    m_buffer->stream = outfile;
+  }
+
+  void set_prefix (char *prefix);
+
+  void emit_prefix ();
+
+  void format (text_info *text,
+	       const urlifier *urlifier);
+
+  void maybe_space ();
+
+  bool supports_urls_p () const { return m_url_format != URL_FORMAT_NONE; }
+  diagnostic_url_format get_url_format () const { return m_url_format; }
+  void set_url_format (diagnostic_url_format url_format)
+  {
+    m_url_format = url_format;
+  }
+
+  void begin_url (const char *url);
+  void end_url ();
+
+  /* Switch into verbatim mode and return the old mode.  */
+  pp_wrapping_mode_t
+  set_verbatim_wrapping ()
+  {
+    const pp_wrapping_mode_t oldmode = pp_wrapping_mode (this);
+    pp_line_cutoff (this) = 0;
+    pp_prefixing_rule (this) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
+    return oldmode;
+  }
+
+  void set_padding (pp_padding padding) { m_padding = padding; }
+  pp_padding get_padding () const { return m_padding; }
+
+  void clear_state ();
+  void set_real_maximum_length ();
+  int remaining_character_count_for_line ();
+
+private:
   /* Where we print external representation of ENTITY.  */
-  output_buffer *buffer;
+  output_buffer *m_buffer;
 
   /* The prefix for each new line.  If non-NULL, this is "owned" by the
      pretty_printer, and will eventually be free-ed.  */
-  char *prefix;
+  char *m_prefix;
 
   /* Where to put whitespace around the entity being formatted.  */
-  pp_padding padding;
+  pp_padding m_padding;
 
   /* The real upper bound of number of characters per line, taking into
      account the case of a very very looong prefix.  */
-  int maximum_length;
+  int m_maximum_length;
 
   /* Indentation count.  */
-  int indent_skip;
+  int m_indent_skip;
 
   /* Current wrapping mode.  */
-  pp_wrapping_mode_t wrapping;
+  pp_wrapping_mode_t m_wrapping;
 
   /* If non-NULL, this function formats a TEXT into the BUFFER.  When called,
      TEXT->format_spec points to a format code.  FORMAT_DECODER should call
@@ -281,7 +330,7 @@  public:
      returns, TEXT->format_spec should point to the last character processed.
      The QUOTE and BUFFER_PTR are passed in, to allow for deferring-handling
      of format codes (e.g. %H and %I in the C++ frontend).  */
-  printer_fn format_decoder;
+  printer_fn m_format_decoder;
 
   /* If non-NULL, this is called by pp_format once after all format codes
      have been processed, to allow for client-specific postprocessing.
@@ -290,28 +339,112 @@  public:
   format_postprocessor *m_format_postprocessor;
 
   /* Nonzero if current PREFIX was emitted at least once.  */
-  bool emitted_prefix;
+  bool m_emitted_prefix;
 
   /* Nonzero means one should emit a newline before outputting anything.  */
-  bool need_newline;
+  bool m_need_newline;
 
   /* Nonzero means identifiers are translated to the locale character
      set on output.  */
-  bool translate_identifiers;
+  bool m_translate_identifiers;
 
   /* Nonzero means that text should be colorized.  */
-  bool show_color;
+  bool m_show_color;
 
   /* Whether URLs should be emitted, and which terminator to use.  */
-  diagnostic_url_format url_format;
+  diagnostic_url_format m_url_format;
 
-  /* If true, then we've had a pp_begin_url (nullptr), and so the
-     next pp_end_url should be a no-op.  */
+  /* If true, then we've had a begin_url (nullptr), and so the
+     next end_url should be a no-op.  */
   bool m_skipping_null_url;
 };
 
+inline output_buffer *&
+pp_buffer (pretty_printer *pp)
+{
+  return pp->m_buffer;
+}
+
+inline output_buffer *
+pp_buffer (const pretty_printer *pp)
+{
+  return pp->m_buffer;
+}
+
 inline const char *
-pp_get_prefix (const pretty_printer *pp) { return pp->prefix; }
+pp_get_prefix (const pretty_printer *pp)
+{
+  return pp->m_prefix;
+}
+
+/* TRUE if a newline character needs to be added before further
+   formatting.  */
+inline bool &
+pp_needs_newline (pretty_printer *pp)
+{
+  return pp->m_need_newline;
+}
+
+/* The amount of whitespace to be emitted when starting a new line.  */
+inline int &
+pp_indentation (pretty_printer *pp)
+{
+  return pp->m_indent_skip;
+}
+
+/* True if identifiers are translated to the locale character set on
+   output.  */
+inline bool &
+pp_translate_identifiers (pretty_printer *pp)
+{
+  return pp->m_translate_identifiers;
+}
+
+/* True if colors should be shown.  */
+inline bool &
+pp_show_color (pretty_printer *pp)
+{
+  return pp->m_show_color;
+}
+
+inline printer_fn &
+pp_format_decoder (pretty_printer *pp)
+{
+  return pp->m_format_decoder;
+}
+
+inline format_postprocessor *&
+pp_format_postprocessor (pretty_printer *pp)
+{
+  return pp->m_format_postprocessor;
+}
+
+/* Maximum characters per line in automatic line wrapping mode.
+   Zero means don't wrap lines.  */
+inline int &
+pp_line_cutoff (pretty_printer *pp)
+{
+  return pp->m_wrapping.line_cutoff;
+}
+
+/* Prefixing rule used in formatting a diagnostic message.  */
+inline diagnostic_prefixing_rule_t &
+pp_prefixing_rule (pretty_printer *pp)
+{
+  return pp->m_wrapping.rule;
+}
+inline const diagnostic_prefixing_rule_t &
+pp_prefixing_rule (const pretty_printer *pp)
+{
+  return pp->m_wrapping.rule;
+}
+
+/* Get or set the wrapping mode as a single entity.  */
+inline pp_wrapping_mode_t &
+pp_wrapping_mode (pretty_printer *pp)
+{
+  return pp->m_wrapping;
+}
 
 #define pp_space(PP)            pp_character (PP, ' ')
 #define pp_left_paren(PP)       pp_character (PP, '(')
@@ -375,17 +508,18 @@  pp_get_prefix (const pretty_printer *pp) { return pp->prefix; }
 					  : (ID)))
 
 
-#define pp_buffer(PP) (PP)->buffer
-
 extern void pp_set_line_maximum_length (pretty_printer *, int);
-extern void pp_set_prefix (pretty_printer *, char *);
-extern char *pp_take_prefix (pretty_printer *);
-extern void pp_destroy_prefix (pretty_printer *);
-extern int pp_remaining_character_count_for_line (pretty_printer *);
+inline void pp_set_prefix (pretty_printer *pp, char *prefix)
+{
+  pp->set_prefix (prefix);
+}
 extern void pp_clear_output_area (pretty_printer *);
 extern const char *pp_formatted_text (pretty_printer *);
 extern const char *pp_last_position_in_text (const pretty_printer *);
-extern void pp_emit_prefix (pretty_printer *);
+inline void pp_emit_prefix (pretty_printer *pp)
+{
+  pp->emit_prefix ();
+}
 extern void pp_append_text (pretty_printer *, const char *, const char *);
 extern void pp_newline_and_flush (pretty_printer *);
 extern void pp_newline_and_indent (pretty_printer *, int);
@@ -413,8 +547,11 @@  extern void pp_verbatim (pretty_printer *, const char *, ...)
      ATTRIBUTE_GCC_PPDIAG(2,3);
 extern void pp_flush (pretty_printer *);
 extern void pp_really_flush (pretty_printer *);
-extern void pp_format (pretty_printer *, text_info *,
-		       const urlifier * = nullptr);
+inline void pp_format (pretty_printer *pp, text_info *text,
+		       const urlifier *urlifier = nullptr)
+{
+  pp->format (text, urlifier);
+}
 extern void pp_output_formatted_text (pretty_printer *,
 				      const urlifier * = nullptr);
 extern void pp_format_verbatim (pretty_printer *, text_info *);
@@ -429,24 +566,32 @@  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_html_like_dot_to_stream (pretty_printer *pp);
 
-extern void pp_maybe_space (pretty_printer *);
+inline void pp_maybe_space (pretty_printer *pp)
+{
+  pp->maybe_space ();
+}
 
 extern void pp_begin_quote (pretty_printer *, bool);
 extern void pp_end_quote (pretty_printer *, bool);
 
-extern void pp_begin_url (pretty_printer *pp, const char *url);
-extern void pp_end_url (pretty_printer *pp);
+inline void
+pp_begin_url (pretty_printer *pp, const char *url)
+{
+  pp->begin_url (url);
+}
+
+inline void
+pp_end_url (pretty_printer *pp)
+{
+  pp->end_url ();
+}
 
 /* Switch into verbatim mode and return the old mode.  */
 inline pp_wrapping_mode_t
-pp_set_verbatim_wrapping_ (pretty_printer *pp)
+pp_set_verbatim_wrapping (pretty_printer *pp)
 {
-  pp_wrapping_mode_t oldmode = pp_wrapping_mode (pp);
-  pp_line_cutoff (pp) = 0;
-  pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
-  return oldmode;
+  return pp->set_verbatim_wrapping ();
 }
-#define pp_set_verbatim_wrapping(PP) pp_set_verbatim_wrapping_ (PP)
 
 extern const char *identifier_to_locale (const char *);
 extern void *(*identifier_to_locale_alloc) (size_t);
diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc
index ecb689f56a94..69c2e196e041 100644
--- a/gcc/print-rtl.cc
+++ b/gcc/print-rtl.cc
@@ -2070,7 +2070,7 @@  void
 dump_value_slim (FILE *f, const_rtx x, int verbose)
 {
   pretty_printer rtl_slim_pp;
-  rtl_slim_pp.buffer->stream = f;
+  rtl_slim_pp.set_output_stream (f);
   print_value (&rtl_slim_pp, x, verbose);
   pp_flush (&rtl_slim_pp);
 }
@@ -2081,7 +2081,7 @@  void
 dump_insn_slim (FILE *f, const rtx_insn *x)
 {
   pretty_printer rtl_slim_pp;
-  rtl_slim_pp.buffer->stream = f;
+  rtl_slim_pp.set_output_stream (f);
   print_insn_with_notes (&rtl_slim_pp, x);
   pp_flush (&rtl_slim_pp);
 }
@@ -2095,7 +2095,7 @@  dump_rtl_slim (FILE *f, const rtx_insn *first, const rtx_insn *last,
 {
   const rtx_insn *insn, *tail;
   pretty_printer rtl_slim_pp;
-  rtl_slim_pp.buffer->stream = f;
+  rtl_slim_pp.set_output_stream (f);
 
   tail = last ? NEXT_INSN (last) : NULL;
   for (insn = first;
diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc
index 4e1acf04d442..0dda09a99e3f 100644
--- a/gcc/print-tree.cc
+++ b/gcc/print-tree.cc
@@ -955,7 +955,7 @@  print_node (FILE *file, const char *prefix, tree node, int indent,
 	  fprintf (file, "def_stmt ");
 	  {
 	    pretty_printer pp;
-	    pp.buffer->stream = file;
+	    pp.set_output_stream (file);
 	    pp_gimple_stmt_1 (&pp, SSA_NAME_DEF_STMT (node), indent + 4,
 			      TDF_NONE);
 	    pp_flush (&pp);
diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc
index eb75d1bdb260..3d8cff76aaf9 100644
--- a/gcc/sched-rgn.cc
+++ b/gcc/sched-rgn.cc
@@ -2882,7 +2882,7 @@  dump_rgn_dependencies_dot (FILE *file)
   int bb;
   pretty_printer pp;
 
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   pp_printf (&pp, "digraph SchedDG {\n");
 
   for (bb = 0; bb < current_nr_blocks; ++bb)
diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c
index b53b347bb4fa..d71b75f44cca 100644
--- a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c
+++ b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c
@@ -530,7 +530,7 @@  dump_refcnt_info (const hash_map<const region *, int> &region_to_refcnt,
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = stderr;
+  pp.set_output_stream (stderr);
 
   for (const auto &region_refcnt : region_to_refcnt)
     {
diff --git a/gcc/text-art/canvas.cc b/gcc/text-art/canvas.cc
index 5bb33b2c6fac..8e5d96808d8c 100644
--- a/gcc/text-art/canvas.cc
+++ b/gcc/text-art/canvas.cc
@@ -80,8 +80,8 @@  canvas::print_to_pp (pretty_printer *pp,
 	pp_string (pp, per_line_prefix);
 
       pretty_printer line_pp;
-      line_pp.show_color = pp->show_color;
-      line_pp.url_format = pp->url_format;
+      pp_show_color (&line_pp) = pp_show_color (pp);
+      line_pp.set_url_format (pp->get_url_format ());
       const int final_x_in_row = get_final_x_in_row (y);
       for (int x = 0; x <= final_x_in_row; x++)
 	{
@@ -133,7 +133,7 @@  canvas::debug (bool styled) const
   if (styled)
     {
       pp_show_color (&pp) = true;
-      pp.url_format = determine_url_format (DIAGNOSTICS_URL_AUTO);
+      pp.set_url_format (determine_url_format (DIAGNOSTICS_URL_AUTO));
     }
   print_to_pp (&pp);
   fprintf (stderr, "%s\n", pp_formatted_text (&pp));
@@ -383,7 +383,7 @@  test_canvas_urls ()
   {
     pretty_printer pp;
     pp_show_color (&pp) = true;
-    pp.url_format = URL_FORMAT_ST;
+    pp.set_url_format (URL_FORMAT_ST);
     assert_canvas_streq (SELFTEST_LOCATION, canvas, &pp,
 			 (/* Line 1.  */
 			  "\n"
@@ -400,7 +400,7 @@  test_canvas_urls ()
   {
     pretty_printer pp;
     pp_show_color (&pp) = true;
-    pp.url_format = URL_FORMAT_BEL;
+    pp.set_url_format (URL_FORMAT_BEL);
     assert_canvas_streq (SELFTEST_LOCATION, canvas, &pp,
 			 (/* Line 1.  */
 			  "\n"
diff --git a/gcc/text-art/dump.h b/gcc/text-art/dump.h
index e94f308f8cee..4659d1424b50 100644
--- a/gcc/text-art/dump.h
+++ b/gcc/text-art/dump.h
@@ -63,7 +63,7 @@  void dump_to_file (const T &obj, FILE *outf)
   pp_format_decoder (&pp) = default_tree_printer;
   if (outf == stderr)
     pp_show_color (&pp) = pp_show_color (global_dc->printer);
-  pp.buffer->stream = outf;
+  pp.set_output_stream (outf);
 
   text_art::theme *theme = global_dc->get_diagram_theme ();
   dump_to_pp (obj, theme, &pp);
diff --git a/gcc/text-art/selftests.cc b/gcc/text-art/selftests.cc
index 5b4679b0cda1..2b113b6b0177 100644
--- a/gcc/text-art/selftests.cc
+++ b/gcc/text-art/selftests.cc
@@ -71,7 +71,7 @@  selftest::assert_canvas_streq (const location &loc,
   if (styled)
     {
       pp_show_color (&pp) = true;
-      pp.url_format = URL_FORMAT_DEFAULT;
+      pp.set_url_format (URL_FORMAT_DEFAULT);
     }
   assert_canvas_streq (loc, canvas, &pp, expected_str);
 }
diff --git a/gcc/text-art/style.cc b/gcc/text-art/style.cc
index 5c58d432cf48..e5e9bdfdf7b7 100644
--- a/gcc/text-art/style.cc
+++ b/gcc/text-art/style.cc
@@ -232,7 +232,7 @@  style::print_changes (pretty_printer *pp,
     {
       if (!old_style.m_url.empty ())
 	pp_end_url (pp);
-      if (pp->url_format != URL_FORMAT_NONE
+      if (pp->supports_urls_p ()
 	  && !new_style.m_url.empty ())
 	{
 	  /* Adapted from pp_begin_url, but encoding the
@@ -241,7 +241,7 @@  style::print_changes (pretty_printer *pp,
 	  pp_string (pp, "\33]8;;");
 	  for (auto ch : new_style.m_url)
 	    pp_unicode_character (pp, ch);
-	  switch (pp->url_format)
+	  switch (pp->get_url_format ())
 	    {
 	    default:
 	    case URL_FORMAT_NONE:
diff --git a/gcc/text-art/styled-string.cc b/gcc/text-art/styled-string.cc
index 78c65498921a..988fe8a742aa 100644
--- a/gcc/text-art/styled-string.cc
+++ b/gcc/text-art/styled-string.cc
@@ -566,7 +566,7 @@  styled_string::from_fmt_va (style_manager &sm,
   text_info text (fmt, args, errno);
   pretty_printer pp;
   pp_show_color (&pp) = true;
-  pp.url_format = URL_FORMAT_DEFAULT;
+  pp.set_url_format (URL_FORMAT_DEFAULT);
   pp_format_decoder (&pp) = format_decoder;
   pp_format (&pp, &text);
   pp_output_formatted_text (&pp);
diff --git a/gcc/tree-diagnostic-path.cc b/gcc/tree-diagnostic-path.cc
index 0ad6c5beb81c..f82ef305c06c 100644
--- a/gcc/tree-diagnostic-path.cc
+++ b/gcc/tree-diagnostic-path.cc
@@ -2284,7 +2284,7 @@  control_flow_tests (const line_table_case &case_)
 {
   std::unique_ptr<pretty_printer> event_pp
     = std::unique_ptr<pretty_printer> (global_dc->printer->clone ());
-  pp_show_color (event_pp) = 0;
+  pp_show_color (event_pp.get ()) = false;
 
   test_control_flow_1 (case_, event_pp.get ());
   test_control_flow_2 (case_, event_pp.get ());
diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc
index 83324086c85b..f87393ee94d6 100644
--- a/gcc/tree-loop-distribution.cc
+++ b/gcc/tree-loop-distribution.cc
@@ -347,7 +347,7 @@  dot_rdg_1 (FILE *file, struct graph *rdg)
   int i;
   pretty_printer pp;
   pp_needs_newline (&pp) = false;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
 
   fprintf (file, "digraph RDG {\n");
 
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index 601cf215ca84..4bb946bb0e83 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -4814,7 +4814,7 @@  maybe_init_pretty_print (FILE *file)
       pp_translate_identifiers (tree_pp) = false;
     }
 
-  tree_pp->buffer->stream = file;
+  tree_pp->set_output_stream (file);
 }
 
 static void
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 45400306d647..05cb308e6821 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -284,7 +284,7 @@  vrange::dump (FILE *file) const
 {
   pretty_printer pp;
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   vrange_printer vrange_pp (&pp);
   this->accept (vrange_pp);
   pp_flush (&pp);
@@ -297,7 +297,7 @@  irange_bitmask::dump (FILE *file) const
   pretty_printer pp;
 
   pp_needs_newline (&pp) = true;
-  pp.buffer->stream = file;
+  pp.set_output_stream (file);
   pp_string (&pp, "MASK ");
   unsigned len_mask, len_val;
   if (print_hex_buf_size (m_mask, &len_mask)