diff mbox series

analyzer: Fix g++ 4.8 bootstrap without using std::move to return std::unique_ptr

Message ID 20240614125755.1279173-1-jwakely@redhat.com
State New
Headers show
Series analyzer: Fix g++ 4.8 bootstrap without using std::move to return std::unique_ptr | expand

Commit Message

Jonathan Wakely June 14, 2024, 12:57 p.m. UTC
This builds successfully using both gcc-4.8.5 and gcc-13.3.1 as host
compiler.

OK for trunk if testing succeeds?

-- >8 --

Revert the changes in r15-1111-ge22b7f741ab54f and fix bootstrap with
GCC 4.8 a different way. The original problem is not related to C++17
guaranteed copy elision, it's related to Core DR 1579 [1], which was
part of C++14 but only implemented in G++ as a C++11 DR with
r5-1576-gfb682f9458c6cf (so GCC 4.8 doesn't implement it).

The original fix causes -Wredundant-move warnings with GCC trunk.

[1] https://cplusplus.github.io/CWG/issues/1579.html

gcc/analyzer/ChangeLog
	* constraint-manager.cc (equiv_class::make_dump_widget): Change
	return type to match return value and do not use std::move on
	return value.
	(bounded_ranges_constraint::make_dump_widget): Likewise.
	(constraint_manager::make_dump_widget): Likewise.
	* constraint-manager.h (equiv_class::make_dump_widget): Change
	return type.
	(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.
	* program-state.h (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-model.h (region_to_value_map::make_dump_widget): Likewise.
	(region_model::make_dump_widget): Likewise.
	* region.cc (region::make_dump_widget): Likewise.
	* region.h (region::make_dump_widget): Likewise.
	* store.cc (binding_cluster::make_dump_widget): Likewise.
	(store::make_dump_widget): Likewise.
	* store.h (binding_cluster::make_dump_widget): Likewise.
	(store::make_dump_widget): Likewise.
	* svalue.cc (svalue::make_dump_widget): Likewise.
	* svalue.h (svalue::make_dump_widget): Likewise.
---
 gcc/analyzer/constraint-manager.cc | 12 ++++++------
 gcc/analyzer/constraint-manager.h  |  6 +++---
 gcc/analyzer/program-state.cc      |  8 ++++----
 gcc/analyzer/program-state.h       |  4 ++--
 gcc/analyzer/region-model.cc       |  8 ++++----
 gcc/analyzer/region-model.h        |  4 ++--
 gcc/analyzer/region.cc             |  4 ++--
 gcc/analyzer/region.h              |  2 +-
 gcc/analyzer/store.cc              |  8 ++++----
 gcc/analyzer/store.h               |  4 ++--
 gcc/analyzer/svalue.cc             |  4 ++--
 gcc/analyzer/svalue.h              |  2 +-
 12 files changed, 33 insertions(+), 33 deletions(-)

Comments

David Malcolm June 14, 2024, 2:27 p.m. UTC | #1
On Fri, 2024-06-14 at 13:57 +0100, Jonathan Wakely wrote:
> This builds successfully using both gcc-4.8.5 and gcc-13.3.1 as host
> compiler.
> 
> OK for trunk if testing succeeds?

Yes, thanks!

Dave
diff mbox series

Patch

diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index a9d58c9cdcf..29539060ebd 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -1146,7 +1146,7 @@  equiv_class::to_json () const
   return ec_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 equiv_class::make_dump_widget (const text_art::dump_widget_info &dwi,
 			       unsigned id) const
 {
@@ -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 std::move (ec_widget);
+  return ec_widget;
 }
 
 /* Generate a hash value for this equiv_class.
@@ -1491,7 +1491,7 @@  bounded_ranges_constraint::to_json () const
   return con_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 bounded_ranges_constraint::
 make_dump_widget (const text_art::dump_widget_info &dwi) const
 {
@@ -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 std::move (brc_widget);
+  return brc_widget;
 }
 
 bool
@@ -1829,7 +1829,7 @@  constraint_manager::to_json () const
   return cm_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 constraint_manager::make_dump_widget (const text_art::dump_widget_info &dwi) const
 {
   using text_art::tree_widget;
@@ -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 std::move (cm_widget);
+  return cm_widget;
 }
 
 /* Attempt to add the constraint LHS OP RHS to this constraint_manager.
diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h
index 31556aebc7a..81e9c7ec035 100644
--- a/gcc/analyzer/constraint-manager.h
+++ b/gcc/analyzer/constraint-manager.h
@@ -273,7 +273,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi,
 		    unsigned id) const;
 
@@ -408,7 +408,7 @@  public:
 
   void add_to_hash (inchash::hash *hstate) const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi) const;
 
   equiv_class_id m_ec_id;
@@ -444,7 +444,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi) const;
 
   const equiv_class &get_equiv_class_by_index (unsigned idx) const
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc
index cb9c3888002..c42fc752350 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -309,7 +309,7 @@  sm_state_map::to_json () const
 /* Make a text_art::tree_widget describing this sm_state_map,
    using MODEL if non-null to describe svalues.  */
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 sm_state_map::make_dump_widget (const text_art::dump_widget_info &dwi,
 				const region_model *model) const
 {
@@ -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 std::move (state_widget);
+  return state_widget;
 }
 
 /* Return true if no states have been set within this map
@@ -1229,7 +1229,7 @@  program_state::to_json (const extrinsic_state &ext_state) const
 }
 
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 program_state::make_dump_widget (const text_art::dump_widget_info &dwi) const
 {
   using text_art::tree_widget;
@@ -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 std::move (state_widget);
+  return state_widget;
 }
 
 /* Update this program_state to reflect a top-level call to FUN.
diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h
index 7e751386b21..322ca8d0f11 100644
--- a/gcc/analyzer/program-state.h
+++ b/gcc/analyzer/program-state.h
@@ -119,7 +119,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi,
 		    const region_model *model) const;
 
@@ -233,7 +233,7 @@  public:
 
   json::object *to_json (const extrinsic_state &ext_state) const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi) const;
 
   void push_frame (const extrinsic_state &ext_state, const function &fun);
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 7969055a59c..4d6e16cf0f4 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -258,7 +258,7 @@  region_to_value_map::to_json () const
   return map_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 region_to_value_map::
 make_dump_widget (const text_art::dump_widget_info &dwi) const
 {
@@ -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 std::move (w);
+  return w;
 }
 
 /* Attempt to merge THIS with OTHER, writing the result
@@ -532,7 +532,7 @@  region_model::to_json () const
   return model_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 region_model::make_dump_widget (const text_art::dump_widget_info &dwi) const
 {
   using text_art::tree_widget;
@@ -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 std::move (model_widget);
+  return model_widget;
 }
 
 /* Assert that this object is valid.  */
diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h
index f57d2069b3b..4683c1a4314 100644
--- a/gcc/analyzer/region-model.h
+++ b/gcc/analyzer/region-model.h
@@ -179,7 +179,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi) const;
 
   bool can_merge_with_p (const region_to_value_map &other,
@@ -288,7 +288,7 @@  class region_model
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi) const;
 
   void validate () const;
diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index 2eabda41941..d110b0eef35 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -1076,7 +1076,7 @@  region::maybe_print_for_user (pretty_printer *pp,
 /* Use DWI to create a text_art::widget describing this region in
    a tree-like form, using PREFIX as a prefix (e.g. for field names).  */
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 region::make_dump_widget (const text_art::dump_widget_info &dwi,
 			  const char *prefix) const
 {
@@ -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 std::move (w);
+  return w;
 }
 
 void
diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h
index 211dd3458c0..ffc05e034f1 100644
--- a/gcc/analyzer/region.h
+++ b/gcc/analyzer/region.h
@@ -182,7 +182,7 @@  public:
   bool maybe_print_for_user (pretty_printer *pp,
 			     const region_model &model) const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi,
 		    const char *prefix = nullptr) const;
 
diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc
index f58b84ef946..284866c7eff 100644
--- a/gcc/analyzer/store.cc
+++ b/gcc/analyzer/store.cc
@@ -1451,7 +1451,7 @@  binding_cluster::to_json () const
   return cluster_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 binding_cluster::make_dump_widget (const text_art::dump_widget_info &dwi,
 				   store_manager *mgr) const
 {
@@ -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 std::move (cluster_widget);
+      return cluster_widget;
     }
 }
 
@@ -2710,7 +2710,7 @@  store::to_json () const
   return store_obj;
 }
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 store::make_dump_widget (const text_art::dump_widget_info &dwi,
 			 store_manager *mgr) const
 {
@@ -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 std::move (store_widget);
+  return store_widget;
 }
 
 /* Get any svalue bound to REG, or NULL.  */
diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h
index affb6e218a6..af9ea4172a2 100644
--- a/gcc/analyzer/store.h
+++ b/gcc/analyzer/store.h
@@ -617,7 +617,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi,
 		    store_manager *mgr) const;
 
@@ -760,7 +760,7 @@  public:
 
   json::object *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const text_art::dump_widget_info &dwi,
 		    store_manager *mgr) const;
 
diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index cad6b7dd3cd..c82aa107b3c 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -230,7 +230,7 @@  svalue::maybe_print_for_user (pretty_printer *pp,
    (a) print_dump_widget_label, to populate the text of a tree_widget, and
    (b) add_dump_widget_children, to add children to the tree_widget.  */
 
-std::unique_ptr<text_art::widget>
+std::unique_ptr<text_art::tree_widget>
 svalue::make_dump_widget (const text_art::dump_widget_info &dwi,
 			  const char *prefix) const
 {
@@ -252,7 +252,7 @@  svalue::make_dump_widget (const text_art::dump_widget_info &dwi,
 
   add_dump_widget_children (*w, dwi);
 
-  return std::move (w);
+  return w;
 }
 
 /* If this svalue is a constant_svalue, return the underlying tree constant.
diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h
index e5503a54177..bc2374fe889 100644
--- a/gcc/analyzer/svalue.h
+++ b/gcc/analyzer/svalue.h
@@ -107,7 +107,7 @@  public:
 
   json::value *to_json () const;
 
-  std::unique_ptr<text_art::widget>
+  std::unique_ptr<text_art::tree_widget>
   make_dump_widget (const dump_widget_info &dwi,
 		    const char *prefix = nullptr) const;