diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-09-09 19:38:12 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-09-09 19:38:12 -0400 |
commit | 19363bf5564ffbe992265a1e69a0d99a0d29f016 (patch) | |
tree | 8de443b213e90e6992bdcf1ca9d2d76fe4fab004 | |
parent | 38dc2c64710aa0e6a03c0c1201477e3e75b1a0b0 (diff) | |
download | gcc-19363bf5564ffbe992265a1e69a0d99a0d29f016.zip gcc-19363bf5564ffbe992265a1e69a0d99a0d29f016.tar.gz gcc-19363bf5564ffbe992265a1e69a0d99a0d29f016.tar.bz2 |
diagnostics: rename dc.printer to m_printer [PR116613]
Rename diagnostic_context's "printer" field to "m_printer",
for consistency with other fields, and to highlight places
where we currently use this, to help assess feasibility
of supporting multiple output sinks (PR other/116613).
No functional change intended.
gcc/ChangeLog:
PR other/116613
* attribs.cc (decls_mismatched_attributes): Rename
diagnostic_context's "printer" field to "m_printer".
(attr_access::array_as_string): Likewise.
* diagnostic-format-json.cc
(json_output_format::on_report_diagnostic): Likewise.
(diagnostic_output_format_init_json): Likewise.
* diagnostic-format-sarif.cc
(sarif_result::on_nested_diagnostic): Likewise.
(sarif_ice_notification): Likewise.
(sarif_builder::on_report_diagnostic): Likewise.
(sarif_builder::make_result_object): Likewise.
(sarif_builder::make_location_object): Likewise.
(sarif_builder::make_message_object_for_diagram): Likewise.
(diagnostic_output_format_init_sarif): Likewise.
* diagnostic-format-text.cc
(diagnostic_text_output_format::~diagnostic_text_output_format):
Likewise.
(diagnostic_text_output_format::on_report_diagnostic): Likewise.
(diagnostic_text_output_format::on_diagram): Likewise.
(diagnostic_text_output_format::print_any_cwe): Likewise.
(diagnostic_text_output_format::print_any_rules): Likewise.
(diagnostic_text_output_format::print_option_information):
Likewise.
* diagnostic-format.h (diagnostic_output_format::get_printer):
New.
* diagnostic-global-context.cc (verbatim): Rename
diagnostic_context's "printer" field to "m_printer".
* diagnostic-path.cc (path_label::get_text): Likewise.
(print_path_summary_as_text): Likewise.
(diagnostic_context::print_path): Likewise.
(selftest::test_empty_path): Likewise.
(selftest::test_intraprocedural_path): Likewise.
(selftest::test_interprocedural_path_1): Likewise.
(selftest::test_interprocedural_path_2): Likewise.
(selftest::test_recursion): Likewise.
(selftest::test_control_flow_1): Likewise.
(selftest::test_control_flow_2): Likewise.
(selftest::test_control_flow_3): Likewise.
(assert_cfg_edge_path_streq): Likewise.
(selftest::test_control_flow_5): Likewise.
(selftest::test_control_flow_6): Likewise.
* diagnostic-show-locus.cc (layout::layout): Likewise.
(selftest::test_layout_x_offset_display_utf8): Likewise.
(selftest::test_layout_x_offset_display_tab): Likewise.
(selftest::test_diagnostic_show_locus_unknown_location): Likewise.
(selftest::test_one_liner_simple_caret): Likewise.
(selftest::test_one_liner_no_column): Likewise.
(selftest::test_one_liner_caret_and_range): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
(selftest::test_one_liner_fixit_insert_before): Likewise.
(selftest::test_one_liner_fixit_insert_after): Likewise.
(selftest::test_one_liner_fixit_remove): Likewise.
(selftest::test_one_liner_fixit_replace): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations):
Likewise.
(selftest::test_one_liner_many_fixits_1): Likewise.
(selftest::test_one_liner_many_fixits_2): Likewise.
(selftest::test_one_liner_labels): Likewise.
(selftest::test_one_liner_simple_caret_utf8): Likewise.
(selftest::test_one_liner_caret_and_range_utf8): Likewise.
(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
Likewise.
(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
(selftest::test_one_liner_fixit_remove_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_utf8): Likewise.
(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
Likewise.
(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
Likewise.
(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
(selftest::test_one_liner_labels_utf8): Likewise.
(selftest::test_one_liner_colorized_utf8): Likewise.
(selftest::test_add_location_if_nearby): Likewise.
(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
(selftest::test_overlapped_fixit_printing): Likewise.
(selftest::test_overlapped_fixit_printing_utf8): Likewise.
(selftest::test_overlapped_fixit_printing_2): Likewise.
(selftest::test_fixit_insert_containing_newline): Likewise.
(selftest::test_fixit_insert_containing_newline_2): Likewise.
(selftest::test_fixit_replace_containing_newline): Likewise.
(selftest::test_fixit_deletion_affecting_newline): Likewise.
(selftest::test_tab_expansion): Likewise.
(selftest::test_escaping_bytes_1): Likewise.
(selftest::test_escaping_bytes_2): Likewise.
(selftest::test_line_numbers_multiline_range): Likewise.
* diagnostic.cc (file_name_as_prefix): Likewise.
(diagnostic_set_caret_max_width): Likewise.
(diagnostic_context::initialize): Likewise.
(diagnostic_context::color_init): Likewise.
(diagnostic_context::urls_init): Likewise.
(diagnostic_context::finish): Likewise.
(diagnostic_context::get_location_text): Likewise.
(diagnostic_build_prefix): Likewise.
(diagnostic_context::report_current_module): Likewise.
(default_diagnostic_starter): Likewise.
(default_diagnostic_start_span_fn): Likewise.
(default_diagnostic_finalizer): Likewise.
(diagnostic_context::report_diagnostic): Likewise.
(diagnostic_append_note): Likewise.
(diagnostic_context::error_recursion): Likewise.
(fancy_abort): Likewise.
* diagnostic.h (diagnostic_context::set_show_highlight_colors):
Likewise.
(diagnostic_context::printer): Rename to...
(diagnostic_context::m_printer): ...this.
(diagnostic_format_decoder): Rename diagnostic_context's "printer"
field to "m_printer".
(diagnostic_prefixing_rule): Likewise.
(diagnostic_ready_p): Likewise.
* gimple-ssa-warn-access.cc (pass_waccess::maybe_warn_memmodel):
Likewise.
* langhooks.cc (lhd_print_error_function): Likewise.
* lto-wrapper.cc (print_lto_docs_link): Likewise.
* opts-global.cc (init_options_once): Likewise.
* opts.cc (common_handle_option): Likewise.
* simple-diagnostic-path.cc (simple_diagnostic_path_cc_tests):
Likewise.
* text-art/dump.h (dump_to_file<T>): Likewise.
* toplev.cc (announce_function): Likewise.
(toplev::main): Likewise.
* tree-diagnostic.cc (default_tree_diagnostic_starter): Likewise.
* tree.cc (escaped_string::escape): Likewise.
(selftest::test_escaped_strings): Likewise.
gcc/ada/ChangeLog:
PR other/116613
* gcc-interface/misc.cc (internal_error_function): Rename
diagnostic_context's "printer" field to "m_printer".
gcc/analyzer/ChangeLog:
PR other/116613
* access-diagram.cc (access_range::dump): Rename
diagnostic_context's "printer" field to "m_printer".
* analyzer-language.cc (on_finish_translation_unit): Likewise.
* analyzer.cc (make_label_text): Likewise.
(make_label_text_n): Likewise.
* 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.
(bounded_ranges::dump): Likewise.
(constraint_manager::dump): Likewise.
* diagnostic-manager.cc
(diagnostic_manager::emit_saved_diagnostic): Likewise.
* engine.cc (exploded_node::dump): Likewise.
(exploded_path::dump): Likewise.
(run_checkers): Likewise.
* kf-analyzer.cc (kf_analyzer_dump_escaped::impl_call_pre):
Likewise.
* pending-diagnostic.cc (evdesc::event_desc::formatted_print):
Likewise.
* program-point.cc (function_point::print_source_line): Likewise.
(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.
* 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.cc (region_offset::dump): Likewise.
(region::dump): Likewise.
* sm-malloc.cc (deallocator_set::dump): Likewise.
(sufficiently_similar_p): Likewise.
* store.cc (uncertainty_t::dump): Likewise.
(binding_key::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:
PR other/116613
* c-format.cc (selftest::test_type_mismatch_range_labels): Rename
diagnostic_context's "printer" field to "m_printer".
(selftest::test_type_mismatch_range_labels): Likewise.
* c-opts.cc (c_diagnostic_finalizer): Likewise.
gcc/c/ChangeLog:
PR other/116613
* c-objc-common.cc (c_initialize_diagnostics): Rename
diagnostic_context's "printer" field to "m_printer".
gcc/cp/ChangeLog:
PR other/116613
* error.cc (cxx_initialize_diagnostics): Rename
diagnostic_context's "printer" field to "m_printer".
(cxx_print_error_function): Likewise.
(cp_diagnostic_starter): Likewise.
(cp_print_error_function): Likewise.
(print_instantiation_full_context): Likewise.
(print_instantiation_partial_context_line): Likewise.
(maybe_print_constexpr_context): Likewise.
(print_location): Likewise.
(print_constrained_decl_info): Likewise.
(print_concept_check_info): Likewise.
(print_constraint_context_head): Likewise.
(print_requires_expression_info): Likewise.
* module.cc (noisy_p): Likewise.
gcc/d/ChangeLog:
PR other/116613
* d-diagnostic.cc (d_diagnostic_report_diagnostic): Rename
diagnostic_context's "printer" field to "m_printer".
gcc/fortran/ChangeLog:
PR other/116613
* error.cc (gfc_clear_pp_buffer): Rename diagnostic_context's
"printer" field to "m_printer".
(gfc_warning): Likewise.
(gfc_diagnostic_build_kind_prefix): Likewise.
(gfc_diagnostic_build_locus_prefix): Likewise.
(gfc_diagnostic_starter): Likewise.
(gfc_diagnostic_starter): Likewise.
(gfc_diagnostic_start_span): Likewise.
(gfc_diagnostic_finalizer): Likewise.
(gfc_warning_check): Likewise.
(gfc_error_opt): Likewise.
(gfc_error_check): Likewise.
gcc/jit/ChangeLog:
PR other/116613
* jit-playback.cc (add_diagnostic): Rename diagnostic_context's
"printer" field to "m_printer".
gcc/testsuite/ChangeLog:
PR other/116613
* gcc.dg/plugin/analyzer_cpython_plugin.c (dump_refcnt_info):
Update for renaming of field "printer" to "m_printer".
* gcc.dg/plugin/diagnostic_group_plugin.c
(test_diagnostic_starter): Likewise.
(test_diagnostic_start_span_fn): Likewise.
(test_output_format::on_begin_group): Likewise.
(test_output_format::on_end_group): Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_paths.c: Likewise.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c
(custom_diagnostic_finalizer): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
54 files changed, 419 insertions, 384 deletions
diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc index ef5de7f..645937f 100644 --- a/gcc/ada/gcc-interface/misc.cc +++ b/gcc/ada/gcc-interface/misc.cc @@ -306,14 +306,14 @@ internal_error_function (diagnostic_context *context, const char *msgid, emergency_dump_function (); /* Reset the pretty-printer. */ - pp_clear_output_area (context->printer); + pp_clear_output_area (context->m_printer); /* Format the message into the pretty-printer. */ text_info tinfo (msgid, ap, errno); - pp_format_verbatim (context->printer, &tinfo); + pp_format_verbatim (context->m_printer, &tinfo); /* Extract a (writable) pointer to the formatted text. */ - buffer = xstrdup (pp_formatted_text (context->printer)); + buffer = xstrdup (pp_formatted_text (context->m_printer)); /* Go up to the first newline. */ for (p = buffer; *p; p++) diff --git a/gcc/analyzer/access-diagram.cc b/gcc/analyzer/access-diagram.cc index cb5b656..ddeb45a 100644 --- a/gcc/analyzer/access-diagram.cc +++ b/gcc/analyzer/access-diagram.cc @@ -546,7 +546,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); diff --git a/gcc/analyzer/analyzer-language.cc b/gcc/analyzer/analyzer-language.cc index 0647f4e..b4eea6b 100644 --- a/gcc/analyzer/analyzer-language.cc +++ b/gcc/analyzer/analyzer-language.cc @@ -120,7 +120,7 @@ on_finish_translation_unit (const translation_unit &tu) log_user the_logger (NULL); if (logfile) the_logger.set_logger (new logger (logfile, 0, 0, - *global_dc->printer)); + *global_dc->m_printer)); stash_named_constants (the_logger.get_logger (), tu); run_callbacks (the_logger.get_logger (), tu); diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc index 2a15a3a..4a1a361 100644 --- a/gcc/analyzer/analyzer.cc +++ b/gcc/analyzer/analyzer.cc @@ -494,7 +494,7 @@ get_user_facing_name (const gcall *call) label_text make_label_text (bool can_colorize, const char *fmt, ...) { - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); pp_clear_output_area (pp); if (!can_colorize) @@ -524,7 +524,7 @@ make_label_text_n (bool can_colorize, unsigned HOST_WIDE_INT n, const char *singular_fmt, const char *plural_fmt, ...) { - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); pp_clear_output_area (pp); if (!can_colorize) diff --git a/gcc/analyzer/call-details.cc b/gcc/analyzer/call-details.cc index 116ab40..e543eda 100644 --- a/gcc/analyzer/call-details.cc +++ b/gcc/analyzer/call-details.cc @@ -365,7 +365,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_show_color (&pp) = pp_show_color (global_dc->m_printer); 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 663a895..ad86a5c 100644 --- a/gcc/analyzer/call-summary.cc +++ b/gcc/analyzer/call-summary.cc @@ -148,7 +148,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (ext_state, &pp, simple); pp_flush (&pp); @@ -887,7 +887,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_show_color (&pp) = pp_show_color (global_dc->m_printer); 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 2f1438c..90a2381 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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump (&pp); pp_newline (&pp); diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 62d3b84..e198696 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -184,7 +184,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); @@ -447,7 +447,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, show_types); pp_newline (&pp); @@ -720,7 +720,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, show_types); pp_newline (&pp); @@ -1771,7 +1771,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (&pp, true); pp_flush (&pp); diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index 92e30bd..4a5a951 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -1561,7 +1561,7 @@ diagnostic_manager::emit_saved_diagnostic (const exploded_graph &eg, sd.get_index (), sd.m_d->get_kind (), sd.m_snode->m_index); log ("num dupes: %i", sd.get_num_dupes ()); - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); const exploded_path *epath = sd.get_best_epath (); gcc_assert (epath); diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index f423975..74a408f 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -1421,7 +1421,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (&pp, ext_state); pp_flush (&pp); @@ -4830,7 +4830,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (&pp, ext_state); pp_flush (&pp); @@ -6330,7 +6330,7 @@ run_checkers () get_or_create_any_logfile (); if (dump_fout) the_logger.set_logger (new logger (dump_fout, 0, 0, - *global_dc->printer)); + *global_dc->m_printer)); LOG_SCOPE (the_logger.get_logger ()); impl_run_checkers (the_logger.get_logger ()); diff --git a/gcc/analyzer/kf-analyzer.cc b/gcc/analyzer/kf-analyzer.cc index 4c7302b..26c2e41 100644 --- a/gcc/analyzer/kf-analyzer.cc +++ b/gcc/analyzer/kf-analyzer.cc @@ -178,7 +178,7 @@ public: pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); bool first = true; for (auto iter : escaped_decls) { diff --git a/gcc/analyzer/pending-diagnostic.cc b/gcc/analyzer/pending-diagnostic.cc index b0637be..ec6f5ac 100644 --- a/gcc/analyzer/pending-diagnostic.cc +++ b/gcc/analyzer/pending-diagnostic.cc @@ -93,7 +93,7 @@ interesting_t::dump_to_pp (pretty_printer *pp, bool simple) const label_text evdesc::event_desc::formatted_print (const char *fmt, ...) const { - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); pp_show_color (pp) = m_colorize; diff --git a/gcc/analyzer/program-point.cc b/gcc/analyzer/program-point.cc index 8e0a3a0..37a6c45 100644 --- a/gcc/analyzer/program-point.cc +++ b/gcc/analyzer/program-point.cc @@ -278,7 +278,7 @@ function_point::print_source_line (pretty_printer *pp) const debug_diagnostic_context tmp_dc; gcc_rich_location richloc (stmt->location); diagnostic_show_locus (&tmp_dc, &richloc, DK_ERROR); - pp_string (pp, pp_formatted_text (tmp_dc.printer)); + pp_string (pp, pp_formatted_text (tmp_dc.m_printer)); } /* class program_point. */ @@ -301,7 +301,7 @@ DEBUG_FUNCTION void program_point::dump () const { pretty_printer pp; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); 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 b975184..1d86013 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -85,7 +85,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (outf); dump_to_pp (&pp); pp_flush (&pp); @@ -273,7 +273,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); print (NULL, simple, true, &pp); pp_newline (&pp); @@ -1168,7 +1168,7 @@ program_state::dump_to_file (const extrinsic_state &ext_state, pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; if (outf == stderr) - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); 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 17d6e6b..59dac22 100644 --- a/gcc/analyzer/ranges.cc +++ b/gcc/analyzer/ranges.cc @@ -97,7 +97,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); @@ -156,7 +156,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple, mgr); pp_newline (&pp); diff --git a/gcc/analyzer/region-model-reachability.cc b/gcc/analyzer/region-model-reachability.cc index 828e3fc..8905461 100644 --- a/gcc/analyzer/region-model-reachability.cc +++ b/gcc/analyzer/region-model-reachability.cc @@ -349,7 +349,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_show_color (&pp) = pp_show_color (global_dc->m_printer); 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 4d6e16c..3cefd9c 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -225,7 +225,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true); pp_newline (&pp); @@ -485,7 +485,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (&pp, simple, multiline); pp_newline (&pp); @@ -7399,7 +7399,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (fp); dump_to_pp (&pp, simple); pp_flush (&pp); diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index d110b0e..c1b1ff6 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -140,7 +140,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); @@ -1017,7 +1017,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index f319cc3..bdbbbf3 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -585,7 +585,7 @@ DEBUG_FUNCTION void deallocator_set::dump () const { pretty_printer pp; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp); pp_newline (&pp); @@ -1651,8 +1651,8 @@ private: static bool sufficiently_similar_p (tree expr_a, tree expr_b) { - pretty_printer *pp_a = global_dc->printer->clone (); - pretty_printer *pp_b = global_dc->printer->clone (); + pretty_printer *pp_a = global_dc->m_printer->clone (); + pretty_printer *pp_b = global_dc->m_printer->clone (); pp_printf (pp_a, "%qE", expr_a); pp_printf (pp_b, "%qE", expr_b); bool result = (strcmp (pp_formatted_text (pp_a), pp_formatted_text (pp_b)) diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index c6c17b5..2707120 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -109,7 +109,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); @@ -146,7 +146,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); @@ -775,7 +775,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true); pp_newline (&pp); @@ -1402,7 +1402,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); pp_string (&pp, " cluster for: "); m_base_region->dump_to_pp (&pp, simple); @@ -2638,7 +2638,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple, true, NULL); pp_newline (&pp); diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index 68d83bb..6e0a4f7 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -437,7 +437,7 @@ supergraph::dump_dot_to_pp (pretty_printer *pp, void supergraph::dump_dot_to_file (FILE *fp, const dump_args_t &dump_args) const { - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); pp_show_color (pp) = 0; /* %qE in logs for SSA_NAMEs should show the ssa names, rather than trying to prettify things by showing the underlying var. */ @@ -900,7 +900,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump (&pp); pp_newline (&pp); diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index c82aa10..617d6a8 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -88,7 +88,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_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); dump_to_pp (&pp, simple); pp_newline (&pp); diff --git a/gcc/attribs.cc b/gcc/attribs.cc index 3ab0b0f..d025183 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -2280,9 +2280,9 @@ decls_mismatched_attributes (tree tmpl, tree decl, tree attrlist, { if (nattrs) pp_string (attrstr, ", "); - pp_begin_quote (attrstr, pp_show_color (global_dc->printer)); + pp_begin_quote (attrstr, pp_show_color (global_dc->m_printer)); pp_string (attrstr, blacklist[i]); - pp_end_quote (attrstr, pp_show_color (global_dc->printer)); + pp_end_quote (attrstr, pp_show_color (global_dc->m_printer)); ++nattrs; } @@ -2674,7 +2674,7 @@ attr_access::array_as_string (tree type) const /* Format the type using the current pretty printer. The generic tree printer does a terrible job. */ - pretty_printer *pp = global_dc->printer->clone (); + pretty_printer *pp = global_dc->m_printer->clone (); pp_printf (pp, "%qT", type); typstr = pp_formatted_text (pp); delete pp; diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc index 7614f1e..614b432 100644 --- a/gcc/c-family/c-format.cc +++ b/gcc/c-family/c-format.cc @@ -5585,7 +5585,7 @@ test_type_mismatch_range_labels () " ~^ ~~~\n" " | |\n" " char* int\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); else /* "char *", with a space. */ ASSERT_STREQ (" printf (\"msg: %i\\n\", msg);\n" @@ -5593,7 +5593,7 @@ test_type_mismatch_range_labels () " | |\n" " | int\n" " char *\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Run all of the selftests within this file. */ diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 7d21033..2ccbdc8 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -172,15 +172,16 @@ c_diagnostic_finalizer (diagnostic_context *context, const diagnostic_info *diagnostic, diagnostic_t) { - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, NULL); - pp_newline (context->printer); - diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind); + pretty_printer *const pp = context->m_printer; + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, NULL); + pp_newline (pp); + diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind, pp); /* By default print macro expansion contexts in the diagnostic finalizer -- for tokens resulting from macro expansion. */ virt_loc_aware_diagnostic_finalizer (context, diagnostic); - pp_set_prefix (context->printer, saved_prefix); - pp_flush (context->printer); + pp_set_prefix (pp, saved_prefix); + pp_flush (pp); } /* Common default settings for diagnostics. */ diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc index afd3e72..eb0c4b8 100644 --- a/gcc/c/c-objc-common.cc +++ b/gcc/c/c-objc-common.cc @@ -411,9 +411,9 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED) void c_initialize_diagnostics (diagnostic_context *context) { - pretty_printer *base = context->printer; + pretty_printer *base = context->m_printer; c_pretty_printer *pp = XNEW (c_pretty_printer); - context->printer = new (pp) c_pretty_printer (); + context->m_printer = new (pp) c_pretty_printer (); /* It is safe to free this object because it was previously XNEW()'d. */ base->~pretty_printer (); diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 67a669b..7b6867f 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -275,9 +275,9 @@ cp_seen_error () void cxx_initialize_diagnostics (diagnostic_context *context) { - pretty_printer *base = context->printer; + pretty_printer *base = context->m_printer; cxx_pretty_printer *pp = XNEW (cxx_pretty_printer); - context->printer = new (pp) cxx_pretty_printer (); + context->m_printer = new (pp) cxx_pretty_printer (); /* It is safe to free this object because it was previously XNEW()'d. */ base->~pretty_printer (); @@ -3674,7 +3674,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file, else prefix = NULL; lhd_print_error_function (context, file, diagnostic); - pp_set_prefix (context->printer, prefix); + pp_set_prefix (context->m_printer, prefix); maybe_print_instantiation_context (context); } @@ -3687,8 +3687,8 @@ cp_diagnostic_starter (diagnostic_context *context, maybe_print_instantiation_context (context); maybe_print_constexpr_context (context); maybe_print_constraint_context (context); - pp_set_prefix (context->printer, diagnostic_build_prefix (context, - diagnostic)); + pp_set_prefix (context->m_printer, diagnostic_build_prefix (context, + diagnostic)); } /* Print current function onto BUFFER, in the process of reporting @@ -3706,16 +3706,17 @@ cp_print_error_function (diagnostic_context *context, return; if (diagnostic_last_function_changed (context, diagnostic)) { - char *old_prefix = pp_take_prefix (context->printer); + pretty_printer *const pp = context->m_printer; + char *old_prefix = pp_take_prefix (pp); const char *file = LOCATION_FILE (diagnostic_location (diagnostic)); tree abstract_origin = diagnostic_abstract_origin (diagnostic); char *new_prefix = (file && abstract_origin == NULL) ? file_name_as_prefix (context, file) : NULL; - pp_set_prefix (context->printer, new_prefix); + pp_set_prefix (pp, new_prefix); if (current_function_decl == NULL) - pp_string (context->printer, _("At global scope:")); + pp_string (pp, _("At global scope:")); else { tree fndecl, ao; @@ -3729,7 +3730,7 @@ cp_print_error_function (diagnostic_context *context, else fndecl = current_function_decl; - pp_printf (context->printer, function_category (fndecl), + pp_printf (pp, function_category (fndecl), fndecl); while (abstract_origin) @@ -3768,33 +3769,33 @@ cp_print_error_function (diagnostic_context *context, if (fndecl) { expanded_location s = expand_location (*locus); - pp_character (context->printer, ','); - pp_newline (context->printer); + pp_character (pp, ','); + pp_newline (pp); if (s.file != NULL) { if (context->m_show_column && s.column != 0) - pp_printf (context->printer, + pp_printf (pp, _(" inlined from %qD at %r%s:%d:%d%R"), fndecl, "locus", s.file, s.line, s.column); else - pp_printf (context->printer, + pp_printf (pp, _(" inlined from %qD at %r%s:%d%R"), fndecl, "locus", s.file, s.line); } else - pp_printf (context->printer, _(" inlined from %qD"), + pp_printf (pp, _(" inlined from %qD"), fndecl); } } - pp_character (context->printer, ':'); + pp_character (pp, ':'); } - pp_newline (context->printer); + pp_newline (pp); diagnostic_set_last_function (context, diagnostic); - context->printer->set_prefix (old_prefix); + pp->set_prefix (old_prefix); } } @@ -3847,7 +3848,7 @@ print_instantiation_full_context (diagnostic_context *context) if (p) { - pp_verbatim (context->printer, + pp_verbatim (context->m_printer, p->list_p () ? _("%s: In substitution of %qS:\n") : _("%s: In instantiation of %q#D:\n"), @@ -3874,23 +3875,25 @@ print_instantiation_partial_context_line (diagnostic_context *context, expanded_location xloc = expand_location (loc); + pretty_printer *const pp = context->m_printer; + if (context->m_show_column) - pp_verbatim (context->printer, _("%r%s:%d:%d:%R "), + pp_verbatim (pp, _("%r%s:%d:%d:%R "), "locus", xloc.file, xloc.line, xloc.column); else - pp_verbatim (context->printer, _("%r%s:%d:%R "), + pp_verbatim (pp, _("%r%s:%d:%R "), "locus", xloc.file, xloc.line); if (t != NULL) { if (t->list_p ()) - pp_verbatim (context->printer, + pp_verbatim (pp, recursive_p ? _("recursively required by substitution of %qS\n") : _("required by substitution of %qS\n"), t->get_node ()); else - pp_verbatim (context->printer, + pp_verbatim (pp, recursive_p ? _("recursively required from %q#D\n") : _("required from %q#D\n"), @@ -3898,15 +3901,15 @@ print_instantiation_partial_context_line (diagnostic_context *context, } else { - pp_verbatim (context->printer, + pp_verbatim (pp, recursive_p ? _("recursively required from here\n") : _("required from here\n")); } gcc_rich_location rich_loc (loc); - char *saved_prefix = pp_take_prefix (context->printer); + char *saved_prefix = pp_take_prefix (pp); diagnostic_show_locus (context, &rich_loc, DK_NOTE); - pp_set_prefix (context->printer, saved_prefix); + pp_set_prefix (pp, saved_prefix); } /* Same as print_instantiation_full_context but less verbose. */ @@ -3955,14 +3958,15 @@ print_instantiation_partial_context (diagnostic_context *context, { expanded_location xloc; xloc = expand_location (loc); + pretty_printer *const pp = context->m_printer; if (context->m_show_column) - pp_verbatim (context->printer, + pp_verbatim (pp, _("%r%s:%d:%d:%R [ skipping %d instantiation " "contexts, use -ftemplate-backtrace-limit=0 to " "disable ]\n"), "locus", xloc.file, xloc.line, xloc.column, skip); else - pp_verbatim (context->printer, + pp_verbatim (pp, _("%r%s:%d:%R [ skipping %d instantiation " "contexts, use -ftemplate-backtrace-limit=0 to " "disable ]\n"), @@ -4015,15 +4019,16 @@ maybe_print_constexpr_context (diagnostic_context *context) { expanded_location xloc = expand_location (EXPR_LOCATION (t)); const char *s = expr_as_string (t, 0); + pretty_printer *const pp = context->m_printer; if (context->m_show_column) - pp_verbatim (context->printer, + pp_verbatim (pp, _("%r%s:%d:%d:%R in %<constexpr%> expansion of %qs"), "locus", xloc.file, xloc.line, xloc.column, s); else - pp_verbatim (context->printer, + pp_verbatim (pp, _("%r%s:%d:%R in %<constexpr%> expansion of %qs"), "locus", xloc.file, xloc.line, s); - pp_newline (context->printer); + pp_newline (pp); } } @@ -4032,11 +4037,12 @@ static void print_location (diagnostic_context *context, location_t loc) { expanded_location xloc = expand_location (loc); + pretty_printer *const pp = context->m_printer; if (context->m_show_column) - pp_verbatim (context->printer, _("%r%s:%d:%d:%R "), + pp_verbatim (pp, _("%r%s:%d:%d:%R "), "locus", xloc.file, xloc.line, xloc.column); else - pp_verbatim (context->printer, _("%r%s:%d:%R "), + pp_verbatim (pp, _("%r%s:%d:%R "), "locus", xloc.file, xloc.line); } @@ -4044,7 +4050,8 @@ static void print_constrained_decl_info (diagnostic_context *context, tree decl) { print_location (context, DECL_SOURCE_LOCATION (decl)); - pp_verbatim (context->printer, "required by the constraints of %q#D\n", decl); + pretty_printer *const pp = context->m_printer; + pp_verbatim (pp, "required by the constraints of %q#D\n", decl); } static void @@ -4056,7 +4063,7 @@ print_concept_check_info (diagnostic_context *context, tree expr, tree map, tree print_location (context, DECL_SOURCE_LOCATION (tmpl)); - cxx_pretty_printer *pp = (cxx_pretty_printer *)context->printer; + cxx_pretty_printer *const pp = (cxx_pretty_printer *)context->m_printer; pp_verbatim (pp, "required for the satisfaction of %qE", expr); if (map && map != error_mark_node) { @@ -4077,7 +4084,8 @@ print_constraint_context_head (diagnostic_context *context, tree cxt, tree args) if (!src) { print_location (context, input_location); - pp_verbatim (context->printer, "required for constraint satisfaction\n"); + pretty_printer *const pp = context->m_printer; + pp_verbatim (pp, "required for constraint satisfaction\n"); return NULL_TREE; } if (DECL_P (src)) @@ -4103,21 +4111,23 @@ print_requires_expression_info (diagnostic_context *context, tree constr, tree a return; print_location (context, cp_expr_loc_or_input_loc (expr)); - pp_verbatim (context->printer, "in requirements "); + cxx_pretty_printer *const pp + = static_cast <cxx_pretty_printer *> (context->m_printer); + pp_verbatim (pp, "in requirements "); tree parms = TREE_OPERAND (expr, 0); if (parms) - pp_verbatim (context->printer, "with "); + pp_verbatim (pp, "with "); while (parms) { - pp_verbatim (context->printer, "%q#D", parms); + pp_verbatim (pp, "%q#D", parms); if (TREE_CHAIN (parms)) - pp_separate_with_comma ((cxx_pretty_printer *)context->printer); + pp_separate_with_comma (pp); parms = TREE_CHAIN (parms); } - pp_cxx_parameter_mapping ((cxx_pretty_printer *)context->printer, map); + pp_cxx_parameter_mapping (pp, map); - pp_verbatim (context->printer, "\n"); + pp_verbatim (pp, "\n"); } void diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 6472089..dc0e9e5 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -4695,7 +4695,7 @@ noisy_p () if (quiet_flag) return false; - pp_needs_newline (global_dc->printer) = true; + pp_needs_newline (global_dc->m_printer) = true; diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL); return true; diff --git a/gcc/d/d-diagnostic.cc b/gcc/d/d-diagnostic.cc index b2accf9..5cf74ef 100644 --- a/gcc/d/d-diagnostic.cc +++ b/gcc/d/d-diagnostic.cc @@ -207,8 +207,9 @@ d_diagnostic_report_diagnostic (const Loc &loc, int opt, const char *format, /* Write verbatim messages with no location direct to stream. */ text_info text (expand_d_format (format), &argp, errno, nullptr); - pp_format_verbatim (global_dc->printer, &text); - pp_newline_and_flush (global_dc->printer); + pretty_printer *const pp = global_dc->m_printer; + pp_format_verbatim (pp, &text); + pp_newline_and_flush (pp); } va_end (argp); diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc index c94f5f7..3a7b07d 100644 --- a/gcc/diagnostic-format-json.cc +++ b/gcc/diagnostic-format-json.cc @@ -229,7 +229,8 @@ void json_output_format::on_report_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { - pp_output_formatted_text (m_context.printer, m_context.get_urlifier ()); + pretty_printer *const pp = get_printer (); + pp_output_formatted_text (pp, m_context.get_urlifier ()); json::object *diag_obj = new json::object (); @@ -248,8 +249,8 @@ json_output_format::on_report_diagnostic (const diagnostic_info &diagnostic, } // FIXME: encoding of the message (json::string requires UTF-8) - diag_obj->set_string ("message", pp_formatted_text (m_context.printer)); - pp_clear_output_area (m_context.printer); + diag_obj->set_string ("message", pp_formatted_text (pp)); + pp_clear_output_area (pp); if (char *option_text = m_context.make_option_name (diagnostic.option_index, orig_diag_kind, @@ -394,7 +395,7 @@ diagnostic_output_format_init_json (diagnostic_context &context) context.set_path_format (DPF_NONE); /* Don't colorize the text. */ - pp_show_color (context.printer) = false; + pp_show_color (context.m_printer) = false; context.set_show_highlight_colors (false); } diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index e95f18f..1fa19ed 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -1136,8 +1136,8 @@ sarif_result::on_nested_diagnostic (diagnostic_context &context, = builder.make_location_object (*this, *diagnostic.richloc, nullptr, diagnostic_artifact_role::result_file); auto message_obj - = builder.make_message_object (pp_formatted_text (context.printer)); - pp_clear_output_area (context.printer); + = builder.make_message_object (pp_formatted_text (context.m_printer)); + pp_clear_output_area (context.m_printer); location_obj->set<sarif_message> ("message", std::move (message_obj)); add_related_location (std::move (location_obj)); @@ -1321,8 +1321,8 @@ sarif_ice_notification (diagnostic_context &context, /* "message" property (SARIF v2.1.0 section 3.85.5). */ auto message_obj - = builder.make_message_object (pp_formatted_text (context.printer)); - pp_clear_output_area (context.printer); + = builder.make_message_object (pp_formatted_text (context.m_printer)); + pp_clear_output_area (context.m_printer); set<sarif_message> ("message", std::move (message_obj)); /* "level" property (SARIF v2.1.0 section 3.58.6). */ @@ -1515,7 +1515,7 @@ sarif_builder::on_report_diagnostic (diagnostic_context &context, const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { - pp_output_formatted_text (context.printer, context.get_urlifier ()); + pp_output_formatted_text (context.m_printer, context.get_urlifier ()); if (diagnostic.kind == DK_ICE || diagnostic.kind == DK_ICE_NOBT) { @@ -1696,8 +1696,8 @@ sarif_builder::make_result_object (diagnostic_context &context, /* "message" property (SARIF v2.1.0 section 3.27.11). */ auto message_obj - = make_message_object (pp_formatted_text (context.printer)); - pp_clear_output_area (context.printer); + = make_message_object (pp_formatted_text (context.m_printer)); + pp_clear_output_area (context.m_printer); result_obj->set<sarif_message> ("message", std::move (message_obj)); /* "locations" property (SARIF v2.1.0 section 3.27.12). */ @@ -1910,7 +1910,7 @@ sarif_builder::make_location_object (sarif_location_manager &loc_mgr, std::unique_ptr<sarif_multiformat_message_string> result = builder.make_multiformat_message_string - (pp_formatted_text (dc.printer)); + (pp_formatted_text (dc.m_printer)); diagnostic_finish (&dc); @@ -2609,19 +2609,20 @@ sarif_builder::make_message_object_for_diagram (diagnostic_context &context, /* "text" property (SARIF v2.1.0 section 3.11.8). */ message_obj->set_string ("text", diagram.get_alt_text ()); - char *saved_prefix = pp_take_prefix (context.printer); - pp_set_prefix (context.printer, nullptr); + pretty_printer *const pp = context.m_printer; + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, nullptr); /* "To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab." Here we use 4 spaces. */ - diagram.get_canvas ().print_to_pp (context.printer, " "); - pp_set_prefix (context.printer, saved_prefix); + diagram.get_canvas ().print_to_pp (pp, " "); + pp_set_prefix (pp, saved_prefix); /* "markdown" property (SARIF v2.1.0 section 3.11.9). */ - message_obj->set_string ("markdown", pp_formatted_text (context.printer)); + message_obj->set_string ("markdown", pp_formatted_text (pp)); - pp_clear_output_area (context.printer); + pp_clear_output_area (pp); return message_obj; } @@ -3346,10 +3347,10 @@ diagnostic_output_format_init_sarif (diagnostic_context &context, context.set_ice_handler_callback (sarif_ice_handler); /* Don't colorize the text. */ - pp_show_color (context.printer) = false; + pp_show_color (context.m_printer) = false; context.set_show_highlight_colors (false); - context.printer->set_token_printer + context.m_printer->set_token_printer (&fmt->get_builder ().get_token_printer ()); context.set_output_format (fmt.release ()); } diff --git a/gcc/diagnostic-format-text.cc b/gcc/diagnostic-format-text.cc index b984803..fcca72a 100644 --- a/gcc/diagnostic-format-text.cc +++ b/gcc/diagnostic-format-text.cc @@ -41,17 +41,18 @@ diagnostic_text_output_format::~diagnostic_text_output_format () /* Some of the errors may actually have been warnings. */ if (m_context.diagnostic_count (DK_WERROR)) { + pretty_printer *pp = m_context.m_printer; /* -Werror was given. */ if (m_context.warning_as_error_requested_p ()) - pp_verbatim (m_context.printer, + pp_verbatim (pp, _("%s: all warnings being treated as errors"), progname); /* At least one -Werror= was given. */ else - pp_verbatim (m_context.printer, + pp_verbatim (pp, _("%s: some warnings being treated as errors"), progname); - pp_newline_and_flush (m_context.printer); + pp_newline_and_flush (pp); } } @@ -63,9 +64,11 @@ diagnostic_text_output_format:: on_report_diagnostic (const diagnostic_info &diagnostic, diagnostic_t orig_diag_kind) { + pretty_printer *pp = m_context.m_printer; + (*diagnostic_starter (&m_context)) (&m_context, &diagnostic); - pp_output_formatted_text (m_context.printer, m_context.get_urlifier ()); + pp_output_formatted_text (pp, m_context.get_urlifier ()); if (m_context.m_show_cwe) print_any_cwe (diagnostic); @@ -76,22 +79,25 @@ on_report_diagnostic (const diagnostic_info &diagnostic, if (m_context.m_show_option_requested) print_option_information (diagnostic, orig_diag_kind); - (*diagnostic_finalizer (&m_context)) (&m_context, &diagnostic, + (*diagnostic_finalizer (&m_context)) (&m_context, + &diagnostic, orig_diag_kind); } void diagnostic_text_output_format::on_diagram (const diagnostic_diagram &diagram) { - char *saved_prefix = pp_take_prefix (m_context.printer); - pp_set_prefix (m_context.printer, NULL); + pretty_printer *const pp = get_printer (); + + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, NULL); /* Use a newline before and after and a two-space indent to make the diagram stand out a little from the wall of text. */ - pp_newline (m_context.printer); - diagram.get_canvas ().print_to_pp (m_context.printer, " "); - pp_newline (m_context.printer); - pp_set_prefix (m_context.printer, saved_prefix); - pp_flush (m_context.printer); + pp_newline (pp); + diagram.get_canvas ().print_to_pp (pp, " "); + pp_newline (pp); + pp_set_prefix (pp, saved_prefix); + pp_flush (pp); } /* If DIAGNOSTIC has a CWE identifier, print it. @@ -109,7 +115,7 @@ diagnostic_text_output_format::print_any_cwe (const diagnostic_info &diagnostic) int cwe = diagnostic.metadata->get_cwe (); if (cwe) { - pretty_printer * const pp = m_context.printer; + pretty_printer * const pp = get_printer (); char *saved_prefix = pp_take_prefix (pp); pp_string (pp, " ["); const char *kind_color = diagnostic_get_color_for_kind (diagnostic.kind); @@ -148,7 +154,7 @@ print_any_rules (const diagnostic_info &diagnostic) = diagnostic.metadata->get_rule (idx); if (char *desc = rule.make_description ()) { - pretty_printer * const pp = m_context.printer; + pretty_printer * const pp = get_printer (); char *saved_prefix = pp_take_prefix (pp); pp_string (pp, " ["); const char *kind_color @@ -188,7 +194,7 @@ print_option_information (const diagnostic_info &diagnostic, orig_diag_kind, diagnostic.kind)) { char *option_url = nullptr; - pretty_printer * const pp = m_context.printer; + pretty_printer * const pp = get_printer (); if (pp->supports_urls_p ()) option_url = m_context.make_option_url (diagnostic.option_index); pp_string (pp, " ["); diff --git a/gcc/diagnostic-format.h b/gcc/diagnostic-format.h index 4a53949..688ddca 100644 --- a/gcc/diagnostic-format.h +++ b/gcc/diagnostic-format.h @@ -41,6 +41,8 @@ public: virtual void on_diagram (const diagnostic_diagram &diagram) = 0; virtual bool machine_readable_stderr_p () const = 0; + pretty_printer *get_printer () const { return m_context.m_printer; } + protected: diagnostic_output_format (diagnostic_context &context) : m_context (context) diff --git a/gcc/diagnostic-global-context.cc b/gcc/diagnostic-global-context.cc index dc0741e..a329b2a 100644 --- a/gcc/diagnostic-global-context.cc +++ b/gcc/diagnostic-global-context.cc @@ -44,8 +44,8 @@ verbatim (const char *gmsgid, ...) va_start (ap, gmsgid); text_info text (_(gmsgid), &ap, errno); - pp_format_verbatim (global_dc->printer, &text); - pp_newline_and_flush (global_dc->printer); + pp_format_verbatim (global_dc->m_printer, &text); + pp_newline_and_flush (global_dc->m_printer); va_end (ap); } diff --git a/gcc/diagnostic-path.cc b/gcc/diagnostic-path.cc index 3775184..abe427d 100644 --- a/gcc/diagnostic-path.cc +++ b/gcc/diagnostic-path.cc @@ -238,7 +238,7 @@ class path_label : public range_label /* Get the description of the event, perhaps with colorization: normally, we don't colorize within a range_label, but this is special-cased for diagnostic paths. */ - const bool colorize = pp_show_color (m_ctxt.printer); + const bool colorize = pp_show_color (m_ctxt.m_printer); label_text event_text (event.get_desc (colorize)); gcc_assert (event_text.get ()); @@ -1027,7 +1027,7 @@ print_path_summary_as_text (const path_summary &ps, diagnostic_context &dc, bool show_depths) { - pretty_printer *pp = dc.printer; + pretty_printer *const pp = dc.m_printer; std::vector<thread_event_printer> thread_event_printers; for (auto t : ps.m_per_thread_summary) @@ -1116,12 +1116,12 @@ diagnostic_context::print_path (const diagnostic_path &path) /* Consolidate related events. */ path_summary summary (*this, path, true, m_source_printing.show_event_links_p); - char *saved_prefix = pp_take_prefix (this->printer); - pp_set_prefix (this->printer, NULL); + char *saved_prefix = pp_take_prefix (m_printer); + pp_set_prefix (m_printer, NULL); print_path_summary_as_text (summary, *this, show_path_depths_p ()); - pp_flush (this->printer); - pp_set_prefix (this->printer, saved_prefix); + pp_flush (m_printer); + pp_set_prefix (m_printer, saved_prefix); } break; } @@ -1166,7 +1166,7 @@ test_empty_path (pretty_printer *event_pp) print_path_summary_as_text (summary, dc, true); ASSERT_STREQ ("", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that print_path_summary works on a purely intraprocedural path. */ @@ -1189,7 +1189,7 @@ test_intraprocedural_path (pretty_printer *event_pp) ASSERT_STREQ (" `foo': events 1-2 (depth 0)\n" " (1): first `free'\n" " (2): double `free'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that print_path_summary works on an interprocedural path. */ @@ -1272,7 +1272,7 @@ test_interprocedural_path_1 (pretty_printer *event_pp) " | (17): entering `wrapped_free'\n" " | (18): calling free\n" " |\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1329,7 +1329,7 @@ test_interprocedural_path_1 (pretty_printer *event_pp) " │ (17): entering `wrapped_free'\n" " │ (18): calling free\n" " │\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1382,7 +1382,7 @@ test_interprocedural_path_2 (pretty_printer *event_pp) " |\n" " | (8): entering `baz'\n" " |\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1415,7 +1415,7 @@ test_interprocedural_path_2 (pretty_printer *event_pp) " │\n" " │ (8): entering `baz'\n" " │\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1461,7 +1461,7 @@ test_recursion (pretty_printer *event_pp) " |\n" " | (7): entering `factorial'\n" " |\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1489,7 +1489,7 @@ test_recursion (pretty_printer *event_pp) " │\n" " │ (7): entering `factorial'\n" " │\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1605,7 +1605,7 @@ test_control_flow_1 (const line_table_case &case_, "| |\n" "+-------->(2) ...to here\n" " (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1626,7 +1626,7 @@ test_control_flow_1 (const line_table_case &case_, " |\n" " (2) ...to here\n" " (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1651,7 +1651,7 @@ test_control_flow_1 (const line_table_case &case_, " || |\n" " |+-------->(2) ...to here\n" " | (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1673,7 +1673,7 @@ test_control_flow_1 (const line_table_case &case_, " | |\n" " | (2) ...to here\n" " | (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1697,7 +1697,7 @@ test_control_flow_1 (const line_table_case &case_, "│ |\n" "└────────>(2) ...to here\n" " (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -1722,7 +1722,7 @@ test_control_flow_1 (const line_table_case &case_, " |│ |\n" " |└────────>(2) ...to here\n" " | (3) dereference of NULL `p'\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1808,7 +1808,7 @@ test_control_flow_2 (const line_table_case &case_, " || ^~~~\n" " || |\n" " |+----------------------------->(5) ...to here\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1888,7 +1888,7 @@ test_control_flow_3 (const line_table_case &case_, " || ^\n" " || |\n" " |+----------------->(5) ...to here\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -1917,7 +1917,7 @@ assert_cfg_edge_path_streq (const location &loc, path_summary summary (dc, path, true); print_path_summary_as_text (summary, dc, false); ASSERT_STREQ_AT (loc, expected_str, - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Assert that if we make a path with an event with "from here..." at SRC_LOC @@ -2261,7 +2261,7 @@ test_control_flow_5 (const line_table_case &case_, " || ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" " || | |\n" " |+----------->(4) ...to here (5) allocated here\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -2356,7 +2356,7 @@ test_control_flow_6 (const line_table_case &case_, " || ~~~~~~~~~~~~~\n" " || |\n" " |+------------->(5) ...to here\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc index 8079809..c746005 100644 --- a/gcc/diagnostic-show-locus.cc +++ b/gcc/diagnostic-show-locus.cc @@ -1327,7 +1327,7 @@ layout::layout (const diagnostic_context &context, : m_options (context.m_source_printing), m_line_table (richloc.get_line_table ()), m_file_cache (context.get_file_cache ()), - m_pp (pp ? pp : context.printer), + m_pp (pp ? pp : context.m_printer), /* Ensure we have a non-null m_theme. */ m_theme (context.get_diagram_theme () ? *context.get_diagram_theme () @@ -3504,7 +3504,7 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_) "that occupies 8 bytes and 4 display columns, starting at " "column #102.\n" " | ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Similar to the previous example, but now the offset called for would split @@ -3529,7 +3529,7 @@ test_layout_x_offset_display_utf8 (const line_table_case &case_) "that occupies 8 bytes and 4 display columns, starting at " "column #102.\n" " | ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -3601,7 +3601,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_) dc.m_tabstop = tabstop; layout test_layout (dc, richloc, DK_ERROR, nullptr); test_layout.print_line (1); - const char *out = pp_formatted_text (dc.printer); + const char *out = pp_formatted_text (dc.m_printer); ASSERT_EQ (NULL, strchr (out, '\t')); const char *left_quote = strchr (out, '`'); const char *right_quote = strchr (out, '\''); @@ -3638,7 +3638,7 @@ test_layout_x_offset_display_tab (const line_table_case &case_) "display columns, starting at column #103.\n" " | ^\n"; const char *expected_output = (extra_width[tabstop] ? output1 : output2); - ASSERT_STREQ (expected_output, pp_formatted_text (dc.printer)); + ASSERT_STREQ (expected_output, pp_formatted_text (dc.m_printer)); } } @@ -3651,7 +3651,7 @@ test_diagnostic_show_locus_unknown_location () test_diagnostic_context dc; rich_location richloc (line_table, UNKNOWN_LOCATION); diagnostic_show_locus (&dc, &richloc, DK_ERROR); - ASSERT_STREQ ("", pp_formatted_text (dc.printer)); + ASSERT_STREQ ("", pp_formatted_text (dc.m_printer)); } /* Verify that diagnostic_show_locus works sanely for various @@ -3675,7 +3675,7 @@ test_one_liner_simple_caret () diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* No column information (column == 0). @@ -3689,7 +3689,7 @@ test_one_liner_no_column () rich_location richloc (line_table, caret); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Caret and range. */ @@ -3706,7 +3706,7 @@ test_one_liner_caret_and_range () diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n" " ~~~^~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Multiple ranges and carets. */ @@ -3739,7 +3739,7 @@ test_one_liner_multiple_carets_and_ranges () diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n" " ~A~ ~B~ ~~C~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Insertion fix-it hint: adding an "&" to the front of "bar.field". */ @@ -3755,7 +3755,7 @@ test_one_liner_fixit_insert_before () ASSERT_STREQ (" foo = bar.field;\n" " ^\n" " &\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Insertion fix-it hint: adding a "[0]" after "foo". */ @@ -3773,7 +3773,7 @@ test_one_liner_fixit_insert_after () ASSERT_STREQ (" foo = bar.field;\n" " ^~~\n" " [0]\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Removal fix-it hint: removal of the ".field". @@ -3796,19 +3796,19 @@ test_one_liner_fixit_remove () ASSERT_STREQ (" foo = bar.field;\n" " ^~~~~~\n" " ------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of adding a prefix. */ { test_diagnostic_context dc; - pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; - pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:")); + pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; + pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:")); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("TEST PREFIX: foo = bar.field;\n" "TEST PREFIX: ^~~~~~\n" "TEST PREFIX: ------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Normal, with ruler. */ @@ -3823,7 +3823,7 @@ test_one_liner_fixit_remove () " foo = bar.field;\n" " ^~~~~~\n" " ------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of adding a prefix, with ruler. */ @@ -3831,15 +3831,15 @@ test_one_liner_fixit_remove () test_diagnostic_context dc; dc.m_source_printing.show_ruler_p = true; dc.m_source_printing.max_width = 50; - pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; - pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:")); + pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; + pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:")); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("TEST PREFIX: 1 2 3 4 5\n" "TEST PREFIX: 12345678901234567890123456789012345678901234567890\n" "TEST PREFIX: foo = bar.field;\n" "TEST PREFIX: ^~~~~~\n" "TEST PREFIX: ------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of adding a prefix, with ruler and line numbers. */ @@ -3848,15 +3848,15 @@ test_one_liner_fixit_remove () dc.m_source_printing.show_ruler_p = true; dc.m_source_printing.max_width = 50; dc.m_source_printing.show_line_numbers_p = true; - pp_prefixing_rule (dc.printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; - pp_set_prefix (dc.printer, xstrdup ("TEST PREFIX:")); + pp_prefixing_rule (dc.m_printer) = DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE; + pp_set_prefix (dc.m_printer, xstrdup ("TEST PREFIX:")); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("TEST PREFIX: | 1 2 3 4 5\n" "TEST PREFIX: | 12345678901234567890123456789012345678901234567890\n" "TEST PREFIX: 1 | foo = bar.field;\n" "TEST PREFIX: | ^~~~~~\n" "TEST PREFIX: | ------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -3875,7 +3875,7 @@ test_one_liner_fixit_replace () ASSERT_STREQ (" foo = bar.field;\n" " ^~~~~\n" " m_field\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace fix-it hint: replacing "field" with "m_field", @@ -3900,7 +3900,7 @@ test_one_liner_fixit_replace_non_equal_range () " ^\n" " -----\n" " m_field\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace fix-it hint: replacing "field" with "m_field", @@ -3924,7 +3924,7 @@ test_one_liner_fixit_replace_equal_secondary_range () ASSERT_STREQ (" foo = bar.field;\n" " ^ ~~~~~\n" " m_field\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that we can use ad-hoc locations when adding fixits to a @@ -3957,7 +3957,7 @@ test_one_liner_fixit_validation_adhoc_locations () ASSERT_STREQ (" foo = bar.field;\n" " ^~~~~~~~~~ \n" " test\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Remove. */ @@ -3973,7 +3973,7 @@ test_one_liner_fixit_validation_adhoc_locations () ASSERT_STREQ (" foo = bar.field;\n" " ^~~~~~~~~~ \n" " -----------------------------------------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace. */ @@ -3989,7 +3989,7 @@ test_one_liner_fixit_validation_adhoc_locations () ASSERT_STREQ (" foo = bar.field;\n" " ^~~~~~~~~~ \n" " test\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -4008,7 +4008,7 @@ test_one_liner_many_fixits_1 () ASSERT_STREQ (" foo = bar.field;\n" " ^\n" " aaaaaaaaaaaaaaaaaaa\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Ensure that we can add an arbitrary number of fix-it hints to a @@ -4030,7 +4030,7 @@ test_one_liner_many_fixits_2 () ASSERT_STREQ (" foo = bar.field;\n" " ^\n" " a a a a a a a a a a a a a a a a a a a\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of labeling the ranges within a rich_location. */ @@ -4067,7 +4067,7 @@ test_one_liner_labels () " ^~~ ~~~ ~~~~~\n" " | | |\n" " 0 1 2\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that we can disable label-printing. */ @@ -4077,7 +4077,7 @@ test_one_liner_labels () diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n" " ^~~ ~~~ ~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -4098,7 +4098,7 @@ test_one_liner_labels () " | | label 2\n" " | label 1\n" " label 0\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of boundary conditions: label 0 and 1 have just enough clearance, @@ -4118,7 +4118,7 @@ test_one_liner_labels () " | | |\n" " | | c\n" " aaaaa bbbb\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of out-of-order ranges (thus requiring a sort). */ @@ -4136,7 +4136,7 @@ test_one_liner_labels () " ~~~ ~~~ ^~~~~\n" " | | |\n" " 2 1 0\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Ensure we don't ICE if multiple ranges with labels are on @@ -4157,7 +4157,7 @@ test_one_liner_labels () " label 0\n" " label 1\n" " label 2\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of out-of-order ranges (thus requiring a sort), where @@ -4198,7 +4198,7 @@ test_one_liner_labels () " label 2a\n" " label 2b\n" " label 2c\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that a NULL result from range_label::get_text is @@ -4211,7 +4211,7 @@ test_one_liner_labels () diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar.field;\n" " ^~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* TODO: example of formatted printing (needs to be in @@ -4283,7 +4283,7 @@ test_one_liner_simple_caret_utf8 () "_field\xcf\x80" ";\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Caret and range. */ @@ -4303,7 +4303,7 @@ test_one_liner_caret_and_range_utf8 () "_field\xcf\x80" ";\n" " ~~~~~^~~~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Multiple ranges and carets. */ @@ -4339,7 +4339,7 @@ test_one_liner_multiple_carets_and_ranges_utf8 () "_field\xcf\x80" ";\n" " ~~~~A~ ~~~B~ ~~~~~C~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Insertion fix-it hint: adding an "&" to the front of "P_bar.field". */ @@ -4359,7 +4359,7 @@ test_one_liner_fixit_insert_before_utf8 () ";\n" " ^\n" " &\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Insertion fix-it hint: adding a "[0]" after "SS_foo". */ @@ -4381,7 +4381,7 @@ test_one_liner_fixit_insert_after_utf8 () ";\n" " ^~~~~~\n" " [0]\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Removal fix-it hint: removal of the ".SS_fieldP". */ @@ -4403,7 +4403,7 @@ test_one_liner_fixit_remove_utf8 () ";\n" " ^~~~~~~~~~\n" " ----------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP". */ @@ -4426,7 +4426,7 @@ test_one_liner_fixit_replace_utf8 () " ^~~~~~~~~\n" " m_\xf0\x9f\x98\x82" "_field\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP", @@ -4456,7 +4456,7 @@ test_one_liner_fixit_replace_non_equal_range_utf8 () " ---------\n" " m_\xf0\x9f\x98\x82" "_field\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace fix-it hint: replacing "SS_fieldP" with "m_SSfieldP", @@ -4485,7 +4485,7 @@ test_one_liner_fixit_replace_equal_secondary_range_utf8 () " ^ ~~~~~~~~~\n" " m_\xf0\x9f\x98\x82" "_field\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Verify that we can use ad-hoc locations when adding fixits to a @@ -4522,7 +4522,7 @@ test_one_liner_fixit_validation_adhoc_locations_utf8 () ";\n" " ^~~~~~~~~~~~~~~~ \n" " test\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Remove. */ @@ -4542,7 +4542,7 @@ test_one_liner_fixit_validation_adhoc_locations_utf8 () ";\n" " ^~~~~~~~~~~~~~~~ \n" " -------------------------------------\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Replace. */ @@ -4562,7 +4562,7 @@ test_one_liner_fixit_validation_adhoc_locations_utf8 () ";\n" " ^~~~~~~~~~~~~~~~ \n" " test\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -4586,7 +4586,7 @@ test_one_liner_many_fixits_1_utf8 () " ^\n" " \xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@" "\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80@\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Ensure that we can add an arbitrary number of fix-it hints to a @@ -4617,7 +4617,7 @@ test_one_liner_many_fixits_2_utf8 () " ^\n" " \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @" " \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80 @ \xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of labeling the ranges within a rich_location. */ @@ -4670,7 +4670,7 @@ test_one_liner_labels_utf8 () " \xf0\x9f\x98\x82\xf0\x9f\x98\x82\xcf\x80" " \xf0\x9f\x98\x82\xcf\x80\xf0\x9f\x98\x82" "\xf0\x9f\x98\x82\xcf\x80\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -4697,7 +4697,7 @@ test_one_liner_labels_utf8 () " | | label 2\xcf\x80\n" " | label 1\xcf\x80\n" " label 0\xf0\x9f\x98\x82\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of boundary conditions: label 0 and 1 have just enough clearance, @@ -4722,7 +4722,7 @@ test_one_liner_labels_utf8 () " | | c\n" " aaaaa\xf0\x9f\x98\x82\xcf\x80" " bb\xf0\x9f\x98\x82\xf0\x9f\x98\x82\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of escaping the source lines. */ @@ -4745,7 +4745,7 @@ test_one_liner_labels_utf8 () " label 0\xf0\x9f\x98\x82" /* ... */ " label 1\xcf\x80" /* ...................*/ " label 2\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -4758,7 +4758,7 @@ test_one_liner_labels_utf8 () " label 0\xf0\x9f\x98\x82" /* ... */ " label 1\xcf\x80" /* ..........................*/ " label 2\xcf\x80\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } } @@ -4777,7 +4777,7 @@ test_one_liner_colorized_utf8 () /* In order to avoid having the test depend on exactly how the colorization was effected, just confirm there are two pi characters in the output. */ - const char *result = pp_formatted_text (dc.printer); + const char *result = pp_formatted_text (dc.m_printer); const char *null_term = result + strlen (result); const char *first_pi = strstr (result, "\xcf\x80"); ASSERT_TRUE (first_pi && first_pi <= null_term - 2); @@ -4886,7 +4886,7 @@ test_add_location_if_nearby (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" struct same_line { double x; double y; ;\n" " ~ ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Test of add_location_if_nearby on a different line to the @@ -4953,7 +4953,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_) ASSERT_STREQ (" struct point origin = {x: 0.0,\n" " ^\n" " .=\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* The multiline case. The caret for the rich_location is on line 6; @@ -4977,7 +4977,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_) " : 0.0};\n" " ^\n" " =\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* As above, but verify the behavior of multiple line spans @@ -4999,7 +4999,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_) " 6 | : 0.0};\n" " | ^\n" " | =\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5208,7 +5208,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " ^~~~~~~~~~\n" " -----------------\n" " const_cast<foo *> (ptr->field)\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); /* Unit-test the line_corrections machinery. */ char_display_policy policy (make_policy (dc, richloc)); @@ -5279,7 +5279,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " -\n" " CAST (-\n" " ) ( )\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example where none are consolidated during printing. */ @@ -5296,7 +5296,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " -\n" " CST ( -\n" " ) ( )\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of deletion fix-it hints. */ @@ -5316,7 +5316,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " ^~~~~~~~~~\n" " -------\n" " (bar *)\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of deletion fix-it hints that would overlap. */ @@ -5336,7 +5336,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " ^~~~~~~~~~\n" " -----------------\n" " (longer *)(foo *)\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of insertion fix-it hints that would overlap. */ @@ -5354,7 +5354,7 @@ test_overlapped_fixit_printing (const line_table_case &case_) " ^~~~~~~~~~\n" " -------\n" " LONGER THAN THE CAST(foo *)TEST\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5425,7 +5425,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " const_cast<f\xf0\x9f\x98\x82" " *> (ptr->field\xcf\x80" ")\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); /* Unit-test the line_corrections machinery. */ char_display_policy policy (make_policy (dc, richloc)); @@ -5500,7 +5500,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " -\n" " CAST (-\n" " ) ( )\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example where none are consolidated during printing. */ @@ -5520,7 +5520,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " -\n" " CST ( -\n" " ) ( )\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of deletion fix-it hints. */ @@ -5544,7 +5544,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " -------\n" " (bar\xf0\x9f\x98\x82" " *)\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of deletion fix-it hints that would overlap. */ @@ -5569,7 +5569,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " (long\xf0\x9f\x98\x82" " *)(f\xf0\x9f\x98\x82" " *)\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Example of insertion fix-it hints that would overlap. */ @@ -5593,7 +5593,7 @@ test_overlapped_fixit_printing_utf8 (const line_table_case &case_) " L\xf0\x9f\x98\x82" "NGER THAN THE CAST(f\xf0\x9f\x98\x82" " *)TEST\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5663,7 +5663,7 @@ test_overlapped_fixit_printing_2 (const line_table_case &case_) ASSERT_STREQ (" int a5[][0][0] = { 1, 2 };\n" " ^\n" " } {\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Various overlapping insertions, some occurring "out of order" @@ -5686,7 +5686,7 @@ test_overlapped_fixit_printing_2 (const line_table_case &case_) " ^\n" " { -----\n" " {{1}}}}, {{{2 }}\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5729,7 +5729,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_) "+ break;\n" " case 'b':\n" " ^~~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* With line numbers. */ @@ -5741,7 +5741,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_) " +++ |+ break;\n" " 3 | case 'b':\n" " | ^~~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5755,7 +5755,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" case 'b':\n" " ^~~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5807,7 +5807,7 @@ test_fixit_insert_containing_newline_2 (const line_table_case &case_) "FILENAME:3:2:\n" " putchar (ch);\n" " ^~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* With line-numbering, the line spans are close enough to be @@ -5821,7 +5821,7 @@ test_fixit_insert_containing_newline_2 (const line_table_case &case_) " 2 | {\n" " 3 | putchar (ch);\n" " | ^~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -5861,7 +5861,7 @@ test_fixit_replace_containing_newline (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" foo = bar ();\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Fix-it hint, attempting to delete a newline. @@ -5907,7 +5907,7 @@ test_fixit_deletion_affecting_newline (const line_table_case &case_) " ~^\n" " );\n" " ~ \n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } static void @@ -5951,7 +5951,7 @@ test_tab_expansion (const line_table_case &case_) test_layout.print_line (1); ASSERT_STREQ (" This: ` ' is a tab.\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Confirm the display width was tracked correctly across the internal tab @@ -5966,7 +5966,7 @@ test_tab_expansion (const line_table_case &case_) test_layout.print_line (1); ASSERT_STREQ (" This: ` ' is a tab.\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -6004,7 +6004,7 @@ test_escaping_bytes_1 (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" before \1\2\3\v\x80\xff""after\n" " ^ ~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } richloc.set_escape_on_output (true); { @@ -6014,7 +6014,7 @@ test_escaping_bytes_1 (const line_table_case &case_) ASSERT_STREQ (" before<U+0000><U+0001><U+0002><U+0003><U+000B><80><ff>after\n" " ^~~~~~~~ ~~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -6022,7 +6022,7 @@ test_escaping_bytes_1 (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" before<00><01><02><03><0b><80><ff>after\n" " ^~~~ ~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -6057,7 +6057,7 @@ test_escaping_bytes_2 (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" after\n" " ^\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } richloc.set_escape_on_output (true); { @@ -6066,7 +6066,7 @@ test_escaping_bytes_2 (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" <U+0000>after\n" " ^~~~~~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } { test_diagnostic_context dc; @@ -6074,7 +6074,7 @@ test_escaping_bytes_2 (const line_table_case &case_) diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ (" <00>after\n" " ^~~~\n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } } @@ -6120,7 +6120,7 @@ test_line_numbers_multiline_range () " | ~~~~~^~~~~~~~~~\n" "11 | this is line 11\n" " | ~~~~ \n", - pp_formatted_text (dc.printer)); + pp_formatted_text (dc.m_printer)); } /* Run all of the selftests within this file. */ diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 58d6458..32eab7d 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -89,9 +89,10 @@ build_message_string (const char *msg, ...) char * file_name_as_prefix (diagnostic_context *context, const char *f) { + pretty_printer *const pp = context->m_printer; const char *locus_cs - = colorize_start (pp_show_color (context->printer), "locus"); - const char *locus_ce = colorize_stop (pp_show_color (context->printer)); + = colorize_start (pp_show_color (pp), "locus"); + const char *locus_ce = colorize_stop (pp_show_color (pp)); return build_message_string ("%s%s:%s ", locus_cs, f, locus_ce); } @@ -126,7 +127,7 @@ diagnostic_set_caret_max_width (diagnostic_context *context, int value) { /* One minus to account for the leading empty space. */ value = value ? value - 1 - : (isatty (fileno (pp_buffer (context->printer)->m_stream)) + : (isatty (fileno (pp_buffer (context->m_printer)->m_stream)) ? get_terminal_width () - 1: INT_MAX); if (value <= 0) @@ -194,8 +195,8 @@ diagnostic_context::initialize (int n_opts) { /* Allocate a basic pretty-printer. Clients will replace this a much more elaborated pretty-printer if they wish. */ - this->printer = XNEW (pretty_printer); - new (this->printer) pretty_printer (); + m_printer = XNEW (pretty_printer); + new (m_printer) pretty_printer (); m_file_cache = new file_cache (); memset (m_diagnostic_count, 0, sizeof m_diagnostic_count); @@ -203,7 +204,7 @@ diagnostic_context::initialize (int n_opts) m_n_opts = n_opts; m_option_classifier.init (n_opts); m_source_printing.enabled = false; - diagnostic_set_caret_max_width (this, pp_line_cutoff (this->printer)); + diagnostic_set_caret_max_width (this, pp_line_cutoff (m_printer)); for (int i = 0; i < rich_location::STATICALLY_ALLOCATED_RANGES; i++) m_source_printing.caret_chars[i] = '^'; m_show_cwe = false; @@ -302,7 +303,7 @@ diagnostic_context::color_init (int value) else value = DIAGNOSTICS_COLOR_DEFAULT; } - pp_show_color (this->printer) + pp_show_color (m_printer) = colorize_init ((diagnostic_color_rule_t) value); } @@ -330,7 +331,7 @@ diagnostic_context::urls_init (int value) value = DIAGNOSTICS_URLS_DEFAULT; } - this->printer->set_url_format + m_printer->set_url_format (determine_url_format ((diagnostic_url_rule_t) value)); } @@ -373,9 +374,9 @@ diagnostic_context::finish () /* diagnostic_context::initialize allocates this->printer using XNEW and placement-new. */ - this->printer->~pretty_printer (); - XDELETE (this->printer); - this->printer = nullptr; + m_printer->~pretty_printer (); + XDELETE (m_printer); + m_printer = nullptr; if (m_edit_context_ptr) { @@ -589,7 +590,7 @@ maybe_line_and_column (int line, int col) label_text diagnostic_context::get_location_text (const expanded_location &s) const { - pretty_printer *pp = this->printer; + pretty_printer *pp = m_printer; const char *locus_cs = colorize_start (pp_show_color (pp), "locus"); const char *locus_ce = colorize_stop (pp_show_color (pp)); const char *file = s.file ? s.file : progname; @@ -633,7 +634,7 @@ diagnostic_build_prefix (diagnostic_context *context, const char *text = _(diagnostic_kind_text[diagnostic->kind]); const char *text_cs = "", *text_ce = ""; - pretty_printer *pp = context->printer; + pretty_printer *pp = context->m_printer; if (diagnostic_kind_color[diagnostic->kind]) { @@ -873,12 +874,13 @@ diagnostic_context::includes_seen_p (const line_map_ordinary *map) void diagnostic_context::report_current_module (location_t where) { + pretty_printer *pp = m_printer; const line_map_ordinary *map = NULL; - if (pp_needs_newline (this->printer)) + if (pp_needs_newline (m_printer)) { - pp_newline (this->printer); - pp_needs_newline (this->printer) = false; + pp_newline (pp); + pp_needs_newline (pp) = false; } if (where <= BUILTINS_LOCATION) @@ -924,15 +926,15 @@ diagnostic_context::report_current_module (location_t where) unsigned index = (was_module ? 6 : is_module ? 4 : need_inc ? 2 : 0) + !first; - pp_verbatim (this->printer, "%s%s %r%s%s%R", + pp_verbatim (pp, "%s%s %r%s%s%R", first ? "" : was_module ? ", " : ",\n", _(msgs[index]), "locus", s.file, line_col); first = false, need_inc = was_module, was_module = is_module; } while (!includes_seen_p (map)); - pp_verbatim (this->printer, ":"); - pp_newline (this->printer); + pp_verbatim (pp, ":"); + pp_newline (pp); } } } @@ -981,8 +983,8 @@ default_diagnostic_starter (diagnostic_context *context, const diagnostic_info *diagnostic) { diagnostic_report_current_module (context, diagnostic_location (diagnostic)); - pp_set_prefix (context->printer, diagnostic_build_prefix (context, - diagnostic)); + pretty_printer *const pp = context->m_printer; + pp_set_prefix (pp, diagnostic_build_prefix (context, diagnostic)); } void @@ -990,8 +992,9 @@ default_diagnostic_start_span_fn (diagnostic_context *context, expanded_location exploc) { label_text text = context->get_location_text (exploc); - pp_string (context->printer, text.get ()); - pp_newline (context->printer); + pretty_printer *pp = context->m_printer; + pp_string (pp, text.get ()); + pp_newline (pp); } void @@ -999,12 +1002,13 @@ default_diagnostic_finalizer (diagnostic_context *context, const diagnostic_info *diagnostic, diagnostic_t) { - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, NULL); - pp_newline (context->printer); - diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind); - pp_set_prefix (context->printer, saved_prefix); - pp_flush (context->printer); + pretty_printer *const pp = context->m_printer; + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, NULL); + pp_newline (pp); + diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind, pp); + pp_set_prefix (pp, saved_prefix); + pp_flush (pp); } /* Interface to specify diagnostic kind overrides. Returns the @@ -1342,7 +1346,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) through. Don't do this more than once. */ if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) && m_lock == 1) - pp_newline_and_flush (this->printer); + pp_newline_and_flush (m_printer); else error_recursion (); } @@ -1407,7 +1411,7 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) m_output_format->on_begin_group (); m_diagnostic_groups.m_emission_count++; - pp_format (this->printer, &diagnostic->message); + pp_format (m_printer, &diagnostic->message); /* Call vfunc in the output format. This is responsible for phase 3 of formatting, and for printing the result. */ m_output_format->on_report_diagnostic (*diagnostic, orig_diag_kind); @@ -1418,17 +1422,17 @@ diagnostic_context::report_diagnostic (diagnostic_info *diagnostic) break; case EXTRA_DIAGNOSTIC_OUTPUT_fixits_v1: print_parseable_fixits (get_file_cache (), - this->printer, diagnostic->richloc, + m_printer, diagnostic->richloc, DIAGNOSTICS_COLUMN_UNIT_BYTE, m_tabstop); - pp_flush (this->printer); + pp_flush (m_printer); break; case EXTRA_DIAGNOSTIC_OUTPUT_fixits_v2: print_parseable_fixits (get_file_cache (), - this->printer, diagnostic->richloc, + m_printer, diagnostic->richloc, DIAGNOSTICS_COLUMN_UNIT_DISPLAY, m_tabstop); - pp_flush (this->printer); + pp_flush (m_printer); break; } diagnostic_action_after_output (this, diagnostic->kind); @@ -1513,15 +1517,16 @@ diagnostic_append_note (diagnostic_context *context, va_end (ap); return; } - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, + pretty_printer *pp = context->m_printer; + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, diagnostic_build_prefix (context, &diagnostic)); - pp_format (context->printer, &diagnostic.message); - pp_output_formatted_text (context->printer); - pp_destroy_prefix (context->printer); - pp_set_prefix (context->printer, saved_prefix); - pp_newline (context->printer); - diagnostic_show_locus (context, &richloc, DK_NOTE); + pp_format (pp, &diagnostic.message); + pp_output_formatted_text (pp); + pp_destroy_prefix (pp); + pp_set_prefix (pp, saved_prefix); + pp_newline (pp); + diagnostic_show_locus (context, &richloc, DK_NOTE, pp); va_end (ap); } @@ -1602,7 +1607,7 @@ void diagnostic_context::error_recursion () { if (m_lock < 3) - pp_newline_and_flush (this->printer); + pp_newline_and_flush (m_printer); fnotice (stderr, "internal compiler error: error reporting routines re-entered.\n"); @@ -1632,7 +1637,7 @@ fancy_abort (const char *file, int line, const char *function) initialized yet, or might be in use by another thread). Handle such cases as gracefully as possible by falling back to a minimal abort handler that only relies on i18n. */ - if (global_dc->printer == NULL) + if (global_dc->m_printer == nullptr) { /* Print the error message. */ fnotice (stderr, diagnostic_kind_text[DK_ICE]); diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 1d54e86..4d6147b 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -431,7 +431,7 @@ public: void set_show_rules (bool val) { m_show_rules = val; } void set_show_highlight_colors (bool val) { - pp_show_highlight_colors (printer) = val; + pp_show_highlight_colors (m_printer) = val; } void set_path_format (enum diagnostic_path_format val) { @@ -557,11 +557,11 @@ private: void print_path (const diagnostic_path &path); /* Data members. - Ideally, all of these would be private and have "m_" prefixes. */ + Ideally, all of these would be private. */ public: /* Where most of the diagnostic formatting work is done. */ - pretty_printer *printer; + pretty_printer *m_printer; private: /* Cache of source code. */ @@ -818,10 +818,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) pp_format_decoder ((DC)->printer) +#define diagnostic_format_decoder(DC) pp_format_decoder ((DC)->m_printer) /* Same as pp_prefixing_rule. Works on 'diagnostic_context *'. */ -#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->printer) +#define diagnostic_prefixing_rule(DC) pp_prefixing_rule ((DC)->m_printer) /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */ inline void @@ -840,7 +840,7 @@ extern diagnostic_context *global_dc; inline bool diagnostic_ready_p () { - return global_dc->printer != nullptr; + return global_dc->m_printer != nullptr; } /* The number of errors that have been issued so far. Ideally, these diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc index ffe95d1..e328dbd 100644 --- a/gcc/fortran/error.cc +++ b/gcc/fortran/error.cc @@ -923,7 +923,7 @@ error_printf (const char *gmsgid, ...) static void gfc_clear_pp_buffer (output_buffer *this_buffer) { - pretty_printer *pp = global_dc->printer; + pretty_printer *pp = global_dc->m_printer; output_buffer *tmp_buffer = pp_buffer (pp); pp_buffer (pp) = this_buffer; pp_clear_output_area (pp); @@ -963,7 +963,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap) diagnostic_info diagnostic; rich_location rich_loc (line_table, UNKNOWN_LOCATION); bool fatal_errors = global_dc->m_fatal_errors; - pretty_printer *pp = global_dc->printer; + pretty_printer *pp = global_dc->m_printer; output_buffer *tmp_buffer = pp_buffer (pp); gfc_clear_pp_buffer (pp_warning_buffer); @@ -1196,7 +1196,7 @@ gfc_diagnostic_build_kind_prefix (diagnostic_context *context, gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND); const char *text = _(diagnostic_kind_text[diagnostic->kind]); const char *text_cs = "", *text_ce = ""; - pretty_printer *pp = context->printer; + pretty_printer *const pp = context->m_printer; if (diagnostic_kind_color[diagnostic->kind]) { @@ -1213,7 +1213,7 @@ static char * gfc_diagnostic_build_locus_prefix (diagnostic_context *context, expanded_location s) { - pretty_printer *pp = context->printer; + pretty_printer *const pp = context->m_printer; const char *locus_cs = colorize_start (pp_show_color (pp), "locus"); const char *locus_ce = colorize_stop (pp_show_color (pp)); return (s.file == NULL @@ -1232,7 +1232,7 @@ static char * gfc_diagnostic_build_locus_prefix (diagnostic_context *context, expanded_location s, expanded_location s2) { - pretty_printer *pp = context->printer; + pretty_printer *const pp = context->m_printer; const char *locus_cs = colorize_start (pp_show_color (pp), "locus"); const char *locus_ce = colorize_stop (pp_show_color (pp)); @@ -1269,6 +1269,7 @@ static void gfc_diagnostic_starter (diagnostic_context *context, const diagnostic_info *diagnostic) { + pretty_printer *const pp = context->m_printer; char * kind_prefix = gfc_diagnostic_build_kind_prefix (context, diagnostic); expanded_location s1 = diagnostic_expand_location (diagnostic); @@ -1290,7 +1291,7 @@ gfc_diagnostic_starter (diagnostic_context *context, || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION || diagnostic_location (diagnostic, 0) == context->m_last_location) { - pp_set_prefix (context->printer, + pp_set_prefix (pp, concat (locus_prefix, " ", kind_prefix, NULL)); free (locus_prefix); @@ -1304,26 +1305,27 @@ gfc_diagnostic_starter (diagnostic_context *context, [locus]:[prefix]: (1) and we flush with a new line before setting the new prefix. */ - pp_string (context->printer, "(1)"); - pp_newline (context->printer); + pp_string (pp, "(1)"); + pp_newline (pp); locus_prefix = gfc_diagnostic_build_locus_prefix (context, s2); - pp_set_prefix (context->printer, + pp_set_prefix (pp, concat (locus_prefix, " ", kind_prefix, NULL)); free (kind_prefix); free (locus_prefix); } else { - pp_verbatim (context->printer, "%s", locus_prefix); + pp_verbatim (pp, "%s", locus_prefix); free (locus_prefix); /* Fortran uses an empty line between locus and caret line. */ - pp_newline (context->printer); - pp_set_prefix (context->printer, NULL); - pp_newline (context->printer); - diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind); + pp_newline (pp); + pp_set_prefix (pp, NULL); + pp_newline (pp); + diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind, + pp); /* If the caret line was shown, the prefix does not contain the locus. */ - pp_set_prefix (context->printer, kind_prefix); + pp_set_prefix (pp, kind_prefix); } } @@ -1333,11 +1335,12 @@ gfc_diagnostic_start_span (diagnostic_context *context, { char *locus_prefix; locus_prefix = gfc_diagnostic_build_locus_prefix (context, exploc); - pp_verbatim (context->printer, "%s", locus_prefix); + pretty_printer * const pp = context->m_printer; + pp_verbatim (pp, "%s", locus_prefix); free (locus_prefix); - pp_newline (context->printer); + pp_newline (pp); /* Fortran uses an empty line between locus and caret line. */ - pp_newline (context->printer); + pp_newline (pp); } @@ -1346,8 +1349,9 @@ gfc_diagnostic_finalizer (diagnostic_context *context, const diagnostic_info *diagnostic ATTRIBUTE_UNUSED, diagnostic_t orig_diag_kind ATTRIBUTE_UNUSED) { - pp_destroy_prefix (context->printer); - pp_newline_and_flush (context->printer); + pretty_printer *const pp = context->m_printer; + pp_destroy_prefix (pp); + pp_newline_and_flush (pp); } /* Immediate warning (i.e. do not buffer the warning) with an explicit @@ -1461,7 +1465,7 @@ gfc_warning_check (void) { if (! gfc_output_buffer_empty_p (pp_warning_buffer)) { - pretty_printer *pp = global_dc->printer; + pretty_printer *pp = global_dc->m_printer; output_buffer *tmp_buffer = pp_buffer (pp); pp_buffer (pp) = pp_warning_buffer; pp_really_flush (pp); @@ -1502,7 +1506,7 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap) diagnostic_info diagnostic; rich_location richloc (line_table, UNKNOWN_LOCATION); bool fatal_errors = global_dc->m_fatal_errors; - pretty_printer *pp = global_dc->printer; + pretty_printer *pp = global_dc->m_printer; output_buffer *tmp_buffer = pp_buffer (pp); gfc_clear_pp_buffer (pp_error_buffer); @@ -1609,7 +1613,7 @@ gfc_error_check (void) || ! gfc_output_buffer_empty_p (pp_error_buffer)) { error_buffer.flag = false; - pretty_printer *pp = global_dc->printer; + pretty_printer *pp = global_dc->m_printer; output_buffer *tmp_buffer = pp_buffer (pp); pp_buffer (pp) = pp_error_buffer; pp_really_flush (pp); diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index 61f9f0f..6900790 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -2943,7 +2943,7 @@ pass_waccess::maybe_warn_memmodel (gimple *stmt, tree ord_sucs, /* Print a note with the valid memory models. */ pretty_printer pp; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); for (unsigned i = 0; valid[i] != UCHAR_MAX; ++i) { const char *modname = memory_models[valid[i]].modname; diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 3e71775..583956f 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -3691,7 +3691,7 @@ add_diagnostic (diagnostic_context *diag_context, { /* At this point the text has been formatted into the pretty-printer's output buffer. */ - pretty_printer *pp = diag_context->printer; + pretty_printer *pp = diag_context->m_printer; const char *text = pp_formatted_text (pp); /* Get location information (if any) from the diagnostic. diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc index 61f2b67..8614f44 100644 --- a/gcc/langhooks.cc +++ b/gcc/langhooks.cc @@ -373,15 +373,16 @@ lhd_print_error_function (diagnostic_context *context, const char *file, { if (diagnostic_last_function_changed (context, diagnostic)) { - char *old_prefix = pp_take_prefix (context->printer); + pretty_printer *const pp = context->m_printer; + char *old_prefix = pp_take_prefix (pp); tree abstract_origin = diagnostic_abstract_origin (diagnostic); char *new_prefix = (file && abstract_origin == NULL) ? file_name_as_prefix (context, file) : NULL; - pp_set_prefix (context->printer, new_prefix); + pp_set_prefix (pp, new_prefix); if (current_function_decl == NULL) - pp_printf (context->printer, _("At top level:")); + pp_printf (pp, _("At top level:")); else { tree fndecl, ao; @@ -397,11 +398,11 @@ lhd_print_error_function (diagnostic_context *context, const char *file, if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) pp_printf - (context->printer, _("In member function %qs"), + (pp, _("In member function %qs"), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); else pp_printf - (context->printer, _("In function %qs"), + (pp, _("In function %qs"), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); while (abstract_origin) @@ -440,33 +441,33 @@ lhd_print_error_function (diagnostic_context *context, const char *file, if (fndecl) { expanded_location s = expand_location (*locus); - pp_comma (context->printer); - pp_newline (context->printer); + pp_comma (pp); + pp_newline (pp); if (s.file != NULL) { if (context->m_show_column) - pp_printf (context->printer, + pp_printf (pp, _(" inlined from %qs at %r%s:%d:%d%R"), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), "locus", s.file, s.line, s.column); else - pp_printf (context->printer, + pp_printf (pp, _(" inlined from %qs at %r%s:%d%R"), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), "locus", s.file, s.line); } else - pp_printf (context->printer, _(" inlined from %qs"), + pp_printf (pp, _(" inlined from %qs"), identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); } } - pp_colon (context->printer); + pp_colon (pp); } diagnostic_set_last_function (context, diagnostic); - pp_newline_and_flush (context->printer); - context->printer->set_prefix (old_prefix); + pp_newline_and_flush (pp); + pp->set_prefix (old_prefix); } } diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc index c07765b..5b6f16b 100644 --- a/gcc/lto-wrapper.cc +++ b/gcc/lto-wrapper.cc @@ -1364,7 +1364,7 @@ init_num_threads (void) void print_lto_docs_link () { - bool print_url = global_dc->printer->supports_urls_p (); + bool print_url = global_dc->m_printer->supports_urls_p (); const char *url = global_dc->make_option_url (OPT_flto); pretty_printer pp; diff --git a/gcc/opts-global.cc b/gcc/opts-global.cc index e2b83d0..a9bc0d5 100644 --- a/gcc/opts-global.cc +++ b/gcc/opts-global.cc @@ -257,7 +257,7 @@ init_options_once (void) initial_lang_mask = lang_hooks.option_lang_mask (); const bool show_highlight_colors - = pp_show_highlight_colors (global_dc->printer); + = pp_show_highlight_colors (global_dc->m_printer); lang_hooks.initialize_diagnostics (global_dc); /* ??? Ideally, we should do this earlier and the FEs will override diff --git a/gcc/opts.cc b/gcc/opts.cc index fc6abf6..7a15318 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -3056,7 +3056,7 @@ common_handle_option (struct gcc_options *opts, break; case OPT_fmessage_length_: - pp_set_line_maximum_length (dc->printer, value); + pp_set_line_maximum_length (dc->m_printer, value); diagnostic_set_caret_max_width (dc, value); break; diff --git a/gcc/simple-diagnostic-path.cc b/gcc/simple-diagnostic-path.cc index 7c47b83..e1fcd56 100644 --- a/gcc/simple-diagnostic-path.cc +++ b/gcc/simple-diagnostic-path.cc @@ -220,16 +220,17 @@ simple_diagnostic_path_cc_tests () { /* In a few places we use the global dc's printer to determine colorization so ensure this off during the tests. */ - const bool saved_show_color = pp_show_color (global_dc->printer); - pp_show_color (global_dc->printer) = false; + pretty_printer *global_pp = global_dc->m_printer; + const bool saved_show_color = pp_show_color (global_pp); + pp_show_color (global_pp) = false; auto_fix_quotes fix_quotes; std::unique_ptr<pretty_printer> event_pp - = std::unique_ptr<pretty_printer> (global_dc->printer->clone ()); + = std::unique_ptr<pretty_printer> (global_pp->clone ()); test_intraprocedural_path (event_pp.get ()); - pp_show_color (global_dc->printer) = saved_show_color; + pp_show_color (global_pp) = saved_show_color; } } // namespace selftest diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c index d71b75f..d0fe110 100644 --- a/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.c @@ -529,7 +529,7 @@ dump_refcnt_info (const hash_map<const region *, int> ®ion_to_refcnt, region_model_manager *mgr = model->get_manager (); pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (stderr); for (const auto ®ion_refcnt : region_to_refcnt) diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c index a47fff7..047ba36 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_group_plugin.c @@ -168,7 +168,7 @@ void test_diagnostic_starter (diagnostic_context *context, const diagnostic_info *diagnostic) { - pp_set_prefix (context->printer, xstrdup ("PREFIX: ")); + pp_set_prefix (context->m_printer, xstrdup ("PREFIX: ")); } /* Custom diagnostic callback, to avoid having the path in the @@ -178,8 +178,8 @@ void test_diagnostic_start_span_fn (diagnostic_context *context, expanded_location exploc) { - pp_string (context->printer, "START_SPAN_FN: "); - pp_newline (context->printer); + pp_string (context->m_printer, "START_SPAN_FN: "); + pp_newline (context->m_printer); } /* Custom output format subclass. */ @@ -194,17 +194,17 @@ class test_output_format : public diagnostic_text_output_format void on_begin_group () final override { /* Loudly announce a new diagnostic group. */ - pp_string (m_context.printer, + pp_string (m_context.m_printer, "================================= BEGIN GROUP =============================="); - pp_newline (m_context.printer); + pp_newline (m_context.m_printer); } void on_end_group () final override { /* Loudly announce the end of a diagnostic group. */ - pp_set_prefix (m_context.printer, NULL); - pp_string (m_context.printer, + pp_set_prefix (m_context.m_printer, NULL); + pp_string (m_context.m_printer, "---------------------------------- END GROUP -------------------------------"); - pp_newline_and_flush (m_context.printer); + pp_newline_and_flush (m_context.m_printer); } }; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c index 43e16a6..f7952e7 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c @@ -147,7 +147,7 @@ example_1 () { auto_diagnostic_group d; gcc_rich_location richloc (gimple_location (call_to_PyList_Append)); - simple_diagnostic_path path (global_dc->printer); + simple_diagnostic_path path (global_dc->m_printer); diagnostic_event_id_t alloc_event_id = path.add_event (gimple_location (call_to_PyList_New), example_a_fun->decl, 0, @@ -335,7 +335,7 @@ example_2 () auto_diagnostic_group d; gcc_rich_location richloc (call_to_free.m_loc); - test_diagnostic_path path (global_dc->printer); + test_diagnostic_path path (global_dc->m_printer); path.add_entry (entry_to_test, 0, "test"); path.add_call (call_to_make_boxed_int, 0, entry_to_make_boxed_int, "make_boxed_int"); @@ -420,7 +420,7 @@ example_3 () auto_diagnostic_group d; gcc_rich_location richloc (call_to_fprintf.m_loc); - test_diagnostic_path path (global_dc->printer); + test_diagnostic_path path (global_dc->m_printer); path.add_entry (entry_to_test, 1, "test"); path.add_call (call_to_register_handler, 1, entry_to_register_handler, "register_handler"); @@ -495,7 +495,7 @@ example_4 () auto_diagnostic_group d; gcc_rich_location richloc (call_to_acquire_lock_a_in_bar.m_loc); - test_diagnostic_path path (global_dc->printer); + test_diagnostic_path path (global_dc->m_printer); diagnostic_thread_id_t thread_1 = path.add_thread ("Thread 1"); diagnostic_thread_id_t thread_2 = path.add_thread ("Thread 2"); path.add_entry (entry_to_foo, 0, "foo", thread_1); diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c index ad84a4a..ec6f0ec 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c @@ -133,16 +133,17 @@ custom_diagnostic_finalizer (diagnostic_context *context, const diagnostic_info *diagnostic, diagnostic_t) { - bool old_show_color = pp_show_color (context->printer); + pretty_printer *const pp = context->m_printer; + bool old_show_color = pp_show_color (pp); if (force_show_locus_color) - pp_show_color (context->printer) = true; - char *saved_prefix = pp_take_prefix (context->printer); - pp_set_prefix (context->printer, NULL); - pp_newline (context->printer); + pp_show_color (pp) = true; + char *saved_prefix = pp_take_prefix (pp); + pp_set_prefix (pp, NULL); + pp_newline (pp); diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind); - pp_show_color (context->printer) = old_show_color; - pp_set_prefix (context->printer, saved_prefix); - pp_flush (context->printer); + pp_show_color (pp) = old_show_color; + pp_set_prefix (pp, saved_prefix); + pp_flush (pp); } /* Add a location to RICHLOC with caret==start at START, ranging to FINISH. */ diff --git a/gcc/text-art/dump.h b/gcc/text-art/dump.h index 4659d14..74492bc 100644 --- a/gcc/text-art/dump.h +++ b/gcc/text-art/dump.h @@ -62,7 +62,7 @@ void dump_to_file (const T &obj, FILE *outf) pretty_printer pp; pp_format_decoder (&pp) = default_tree_printer; if (outf == stderr) - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); pp.set_output_stream (outf); text_art::theme *theme = global_dc->get_diagram_theme (); diff --git a/gcc/toplev.cc b/gcc/toplev.cc index bc442a0..abc66c1 100644 --- a/gcc/toplev.cc +++ b/gcc/toplev.cc @@ -229,7 +229,7 @@ announce_function (tree decl) fprintf (stderr, " %s", identifier_to_locale (lang_hooks.decl_printable_name (decl, 2))); fflush (stderr); - pp_needs_newline (global_dc->printer) = true; + pp_needs_newline (global_dc->m_printer) = true; diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL); } } @@ -2387,7 +2387,7 @@ toplev::main (int argc, char **argv) if (auto edit_context_ptr = global_dc->get_edit_context ()) { pretty_printer pp; - pp_show_color (&pp) = pp_show_color (global_dc->printer); + pp_show_color (&pp) = pp_show_color (global_dc->m_printer); edit_context_ptr->print_diff (&pp, true); pp_flush (&pp); } diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc index 466725f..b9b2704 100644 --- a/gcc/tree-diagnostic.cc +++ b/gcc/tree-diagnostic.cc @@ -46,9 +46,9 @@ static void default_tree_diagnostic_starter (diagnostic_context *context, const diagnostic_info *diagnostic) { + pretty_printer *pp = context->m_printer; diagnostic_report_current_function (context, diagnostic); - pp_set_prefix (context->printer, diagnostic_build_prefix (context, - diagnostic)); + pp_set_prefix (pp, diagnostic_build_prefix (context, diagnostic)); } /* Default tree printer. Handles declarations only. */ diff --git a/gcc/tree.cc b/gcc/tree.cc index b14cfbe..bc50afc 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -12404,7 +12404,7 @@ escaped_string::escape (const char *unescaped) continue; } - if (c != '\n' || !pp_is_wrapping_line (global_dc->printer)) + if (c != '\n' || !pp_is_wrapping_line (global_dc->m_printer)) { if (escaped == NULL) { @@ -15832,8 +15832,9 @@ test_escaped_strings (void) ASSERT_STREQ ("foobar", (const char *) msg); /* Ensure that we have -fmessage-length set to 0. */ - saved_cutoff = pp_line_cutoff (global_dc->printer); - pp_line_cutoff (global_dc->printer) = 0; + pretty_printer *pp = global_dc->m_printer; + saved_cutoff = pp_line_cutoff (pp); + pp_line_cutoff (pp) = 0; msg.escape ("foo\nbar"); ASSERT_STREQ ("foo\\nbar", (const char *) msg); @@ -15842,7 +15843,7 @@ test_escaped_strings (void) ASSERT_STREQ ("\\a\\b\\f\\n\\r\\t\\v", (const char *) msg); /* Now repeat the tests with -fmessage-length set to 5. */ - pp_line_cutoff (global_dc->printer) = 5; + pp_line_cutoff (pp) = 5; /* Note that the newline is not translated into an escape. */ msg.escape ("foo\nbar"); @@ -15852,7 +15853,7 @@ test_escaped_strings (void) ASSERT_STREQ ("\\a\\b\\f\n\\r\\t\\v", (const char *) msg); /* Restore the original message length setting. */ - pp_line_cutoff (global_dc->printer) = saved_cutoff; + pp_line_cutoff (pp) = saved_cutoff; } /* Run all of the selftests within this file. */ |