diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-09-20 18:51:55 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-09-20 18:51:55 -0400 |
commit | 39f7703fffee0c1a8aa999b29ae52b2a31903715 (patch) | |
tree | e620ef021654616b7652f2b89ab566b24398e911 /gcc/analyzer/program-state.cc | |
parent | 725231e16768bd9f16169b3b7e4cb5a98b251d1c (diff) | |
download | gcc-39f7703fffee0c1a8aa999b29ae52b2a31903715.zip gcc-39f7703fffee0c1a8aa999b29ae52b2a31903715.tar.gz gcc-39f7703fffee0c1a8aa999b29ae52b2a31903715.tar.bz2 |
analyzer: simplify dumps using tree_dump_pretty_printer [PR116613]
There are numerous "dump" member functions in the analyzer with
copied-and-pasted logic. Simplify them by moving the shared code
to a new class tree_dump_pretty_printer.
As well as reducing code duplication, this eliminates numerous
uses of pp_show_color (global_dc->m_printer), which should
ultimately help with supporting multiple diagnostic sinks.
No functional change intended.
gcc/analyzer/ChangeLog:
PR other/116613
* access-diagram.cc (access_range::dump): Simplify using
tree_dump_pretty_printer.
* 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.
* engine.cc (exploded_node::dump): Likewise.
(exploded_path::dump): Likewise.
* program-point.cc (program_point::dump): Likewise.
* program-state.cc (extrinsic_state::dump_to_file): Likewise.
(sm_state_map::dump): Likewise.
(program_state::dump_to_file): Likewise.
* ranges.cc (symbolic_byte_offset::dump): Likewise.
(symbolic_byte_range::dump): Likewise.
* record-layout.cc (record_layout::dump): Likewise.
* region-model-reachability.cc (reachable_regions::dump):
Likewise.
* region-model.cc (region_to_value_map::dump): Likewise.
(region_model::dump): Likewise.
(model_merger::dump): Likewise.
* region.cc (region_offset::dump): Likewise.
(region::dump): Likewise.
* sm-malloc.cc (deallocator_set::dump): Likewise.
* store.cc (uncertainty_t::dump): Likewise.
(binding_key::dump): Likewise.
(bit_range::dump): Likewise.
(byte_range::dump): Likewise.
(binding_map::dump): Likewise.
(binding_cluster::dump): Likewise.
(store::dump): Likewise.
* supergraph.cc (superedge::dump): Likewise.
* svalue.cc (svalue::dump): Likewise.
gcc/ChangeLog:
PR other/116613
* text-art/dump.h (dump_to_file): Simplify using
tree_dump_pretty_printer.
* tree-diagnostic.h (class tree_dump_pretty_printer): New.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/analyzer/program-state.cc')
-rw-r--r-- | gcc/analyzer/program-state.cc | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index 1d86013..bce7acb 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -83,12 +83,8 @@ extrinsic_state::dump_to_pp (pretty_printer *pp) const void extrinsic_state::dump_to_file (FILE *outf) const { - pretty_printer pp; - if (outf == stderr) - pp_show_color (&pp) = pp_show_color (global_dc->m_printer); - pp.set_output_stream (outf); + tree_dump_pretty_printer pp (outf); dump_to_pp (&pp); - pp_flush (&pp); } /* Dump a multiline representation of this state to stderr. */ @@ -271,13 +267,9 @@ sm_state_map::print (const region_model *model, DEBUG_FUNCTION void 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->m_printer); - pp.set_output_stream (stderr); + tree_dump_pretty_printer pp (stderr); print (NULL, simple, true, &pp); pp_newline (&pp); - pp_flush (&pp); } /* Return a new json::object of the form @@ -1165,13 +1157,8 @@ program_state::dump_to_file (const extrinsic_state &ext_state, bool summarize, bool multiline, FILE *outf) const { - pretty_printer pp; - pp_format_decoder (&pp) = default_tree_printer; - if (outf == stderr) - pp_show_color (&pp) = pp_show_color (global_dc->m_printer); - pp.set_output_stream (outf); + tree_dump_pretty_printer pp (outf); dump_to_pp (ext_state, summarize, multiline, &pp); - pp_flush (&pp); } /* Dump a multiline representation of this state to stderr. */ |