libcpp: Improve encapsulation of label_text
authorJonathan Wakely <jwakely@redhat.com>
Wed, 13 Jul 2022 10:58:05 +0000 (11:58 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 15 Jul 2022 08:40:47 +0000 (09:40 +0100)
commitf858fe7a8b250995bc5b0d18720a2ceb6815622d
tree25d0bc8282256c6407fa5474dfbe54a7cbdab7be
parentae69e6f61b93dcb5b1e7ef609431f100c1b9b2e5
libcpp: Improve encapsulation of label_text

This adjusts the API of label_text so that the data members are private
and cannot be modified by callers.  Add accessors for them instead, and
make the accessors const-correct.  Also rename moved_from () to the more
idiomatic release ().  Also remove the unused take_or_copy () member
function which has confusing ownership semantics.

gcc/analyzer/ChangeLog:

* call-info.cc (call_info::print): Adjust to new label_text API.
* checker-path.cc (checker_event::dump): Likewise.
(region_creation_event::get_desc): Likewise.
(state_change_event::get_desc): Likewise.
(superedge_event::should_filter_p): Likewise.
(start_cfg_edge_event::get_desc): Likewise.
(call_event::get_desc): Likewise.
(return_event::get_desc): Likewise.
(warning_event::get_desc): Likewise.
(checker_path::dump): Likewise.
(checker_path::debug): Likewise.
* diagnostic-manager.cc (diagnostic_manager::prune_for_sm_diagnostic):
Likewise.
(diagnostic_manager::prune_interproc_events): Likewise.
* engine.cc (feasibility_state::maybe_update_for_edge):
Likewise.
* program-state.cc (sm_state_map::to_json): Likewise.
* region-model-impl-calls.cc (region_model::impl_call_analyzer_describe): Likewise.
(region_model::impl_call_analyzer_dump_capacity): Likewise.
* region.cc (region::to_json): Likewise.
* sm-malloc.cc (inform_nonnull_attribute): Likewise.
* store.cc (binding_map::to_json): Likewise.
(store::to_json): Likewise.
* supergraph.cc (superedge::dump): Likewise.
* svalue.cc (svalue::to_json): Likewise.

gcc/c-family/ChangeLog:

* c-format.cc (class range_label_for_format_type_mismatch):
Adjust to new label_text API.

gcc/ChangeLog:

* diagnostic-format-json.cc (json_from_location_range): Adjust
to new label_text API.
* diagnostic-format-sarif.cc (sarif_builder::make_location_object):
Likewise.
* diagnostic-show-locus.cc (struct pod_label_text): Likewise.
(layout::print_any_labels): Likewise.
* tree-diagnostic-path.cc (class path_label): Likewise.
(struct event_range): Likewise.
(default_tree_diagnostic_path_printer): Likewise.
(default_tree_make_json_for_path): Likewise.

libcpp/ChangeLog:

* include/line-map.h (label_text::take_or_copy): Remove.
(label_text::moved_from): Rename to release.
(label_text::m_buffer, label_text::m_owned): Make private.
(label_text::get, label_text::is_owned): New accessors.
17 files changed:
gcc/analyzer/call-info.cc
gcc/analyzer/checker-path.cc
gcc/analyzer/diagnostic-manager.cc
gcc/analyzer/engine.cc
gcc/analyzer/program-state.cc
gcc/analyzer/region-model-impl-calls.cc
gcc/analyzer/region.cc
gcc/analyzer/sm-malloc.cc
gcc/analyzer/store.cc
gcc/analyzer/supergraph.cc
gcc/analyzer/svalue.cc
gcc/c-family/c-format.cc
gcc/diagnostic-format-json.cc
gcc/diagnostic-format-sarif.cc
gcc/diagnostic-show-locus.cc
gcc/tree-diagnostic-path.cc
libcpp/include/line-map.h