https://gcc.gnu.org/g:e22b7f741ab54ff3a3f8a676ce9e7414fe174958
commit r15-1111-ge22b7f741ab54ff3a3f8a676ce9e7414fe174958 Author: Roger Sayle <ro...@nextmovesoftware.com> Date: Sat Jun 8 05:01:38 2024 +0100 analyzer: Restore g++ 4.8 bootstrap; use std::move to return std::unique_ptr. This patch restores bootstrap when using g++ 4.8 as a host compiler. Returning a std::unique_ptr requires a std::move on C++ compilers (pre-C++17) that don't guarantee copy elision/return value optimization. 2024-06-08 Roger Sayle <ro...@nextmovesoftware.com> gcc/analyzer/ChangeLog * constraint-manager.cc (equiv_class::make_dump_widget): Use std::move to return a std::unique_ptr. (bounded_ranges_constraint::make_dump_widget): Likewise. (constraint_manager::make_dump_widget): Likewise. * program-state.cc (sm_state_map::make_dump_widget): Likewise. (program_state::make_dump_widget): Likewise. * region-model.cc (region_to_value_map::make_dump_widget): Likewise. (region_model::make_dump_widget): Likewise. * region.cc (region::make_dump_widget): Likewise. * store.cc (binding_cluster::make_dump_widget): Likewise. (store::make_dump_widget): Likewise. * svalue.cc (svalue::make_dump_widget): Likewise. Diff: --- gcc/analyzer/constraint-manager.cc | 6 +++--- gcc/analyzer/program-state.cc | 4 ++-- gcc/analyzer/region-model.cc | 4 ++-- gcc/analyzer/region.cc | 2 +- gcc/analyzer/store.cc | 4 ++-- gcc/analyzer/svalue.cc | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 707385d3fa6..883f33b2cdd 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -1176,7 +1176,7 @@ equiv_class::make_dump_widget (const text_art::dump_widget_info &dwi, ec_widget->add_child (tree_widget::make (dwi, &pp)); } - return ec_widget; + return std::move (ec_widget); } /* Generate a hash value for this equiv_class. @@ -1500,7 +1500,7 @@ make_dump_widget (const text_art::dump_widget_info &dwi) const (tree_widget::from_fmt (dwi, nullptr, "ec%i bounded ranges", m_ec_id.as_int ())); m_ranges->add_to_dump_widget (*brc_widget.get (), dwi); - return brc_widget; + return std::move (brc_widget); } bool @@ -1853,7 +1853,7 @@ constraint_manager::make_dump_widget (const text_art::dump_widget_info &dwi) con if (cm_widget->get_num_children () == 0) return nullptr; - return cm_widget; + return std::move (cm_widget); } /* Attempt to add the constraint LHS OP RHS to this constraint_manager. diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index dc2d4bdf7b0..efaf569a490 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -382,7 +382,7 @@ sm_state_map::make_dump_widget (const text_art::dump_widget_info &dwi, state_widget->add_child (tree_widget::make (dwi, pp)); } - return state_widget; + return std::move (state_widget); } /* Return true if no states have been set within this map @@ -1247,7 +1247,7 @@ program_state::make_dump_widget (const text_art::dump_widget_info &dwi) const state_widget->add_child (smap->make_dump_widget (dwi, m_region_model)); } - return state_widget; + return std::move (state_widget); } /* Update this program_state to reflect a top-level call to FUN. diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index a25181f2a3e..1a44ff073bd 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -288,7 +288,7 @@ make_dump_widget (const text_art::dump_widget_info &dwi) const sval->dump_to_pp (pp, true); w->add_child (text_art::tree_widget::make (dwi, pp)); } - return w; + return std::move (w); } /* Attempt to merge THIS with OTHER, writing the result @@ -556,7 +556,7 @@ region_model::make_dump_widget (const text_art::dump_widget_info &dwi) const m_mgr->get_store_manager ())); model_widget->add_child (m_constraints->make_dump_widget (dwi)); model_widget->add_child (m_dynamic_extents.make_dump_widget (dwi)); - return model_widget; + return std::move (model_widget); } /* Assert that this object is valid. */ diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 1fc42f2cd97..d5cfd476fd8 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -1101,7 +1101,7 @@ region::make_dump_widget (const text_art::dump_widget_info &dwi, if (m_parent) w->add_child (m_parent->make_dump_widget (dwi, "parent")); - return w; + return std::move (w); } void diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index d5c1a9f6aff..5a33d740ce2 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -1489,7 +1489,7 @@ binding_cluster::make_dump_widget (const text_art::dump_widget_info &dwi, m_map.add_to_tree_widget (*cluster_widget, dwi); - return cluster_widget; + return std::move (cluster_widget); } } @@ -2769,7 +2769,7 @@ store::make_dump_widget (const text_art::dump_widget_info &dwi, store_widget->add_child (std::move (parent_reg_widget)); } - return store_widget; + return std::move (store_widget); } /* Get any svalue bound to REG, or NULL. */ diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index f1fd21e4cda..b67780a5ef1 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -252,7 +252,7 @@ svalue::make_dump_widget (const text_art::dump_widget_info &dwi, add_dump_widget_children (*w, dwi); - return w; + return std::move (w); } /* If this svalue is a constant_svalue, return the underlying tree constant.