diff mbox series

[4/5] ranger: Make some classes local to the TU

Message ID 20240806212714.308434-5-quic_apinski@quicinc.com
State New
Headers show
Series some small ranger op table cleanup | expand

Commit Message

Andrew Pinski Aug. 6, 2024, 9:27 p.m. UTC
This is another small cleanup in the ranger code,
since these classes and the instance of them are local
to the sources already, make them final classes and make them
local by wrapping them with an anonymous namespace.
Note some classes/instances were unused in the first place
so I didn't deleted them but `#if 0` them out. I don't know
if they are being planned to be used in the future or not
but still having them be compiled in is wrong and would cause
an unused variable warnings now with them being in an anonymous
namespace.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* range-op-float.cc (class foperator_unordered): Wrap
	with anonymous namespace and mark as final.
	(class foperator_ordered): Likewise.
	(class foperator_unordered_lt): Likewise.
	(class foperator_unordered_le): Likewise.
	(class foperator_unordered_gt): Likewise.
	(class foperator_unordered_ge): Likewise.
	(class foperator_unordered_equal): Likewise.
	(class foperator_ltgt): Likewise.
	* range-op-ptr.cc (class pointer_plus_operator): Wrap with
	anonymous namespace and mark as final.
	(class pointer_min_max_operator): #if out and mark as final.
	(class pointer_and_operator): Likewise.
	(class pointer_or_operator): Likewise.
	(class operator_pointer_diff): Wrap with anonymous
	namespace and mark as final.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
 gcc/range-op-float.cc | 27 +++++++++++++++++++--------
 gcc/range-op-ptr.cc   | 20 +++++++++++++++-----
 2 files changed, 34 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 2754dd87568..e8e06d5fec3 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -1333,9 +1333,11 @@  operator_ge::op1_op2_relation (const irange &lhs, const frange &,
   return VREL_VARYING;
 }
 
+namespace {
+
 // UNORDERED_EXPR comparison.
 
-class foperator_unordered : public range_operator
+class foperator_unordered final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -1409,7 +1411,7 @@  foperator_unordered::op1_range (frange &r, tree type,
 
 // ORDERED_EXPR comparison.
 
-class foperator_ordered : public range_operator
+class foperator_ordered final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -1478,6 +1480,8 @@  foperator_ordered::op1_range (frange &r, tree type,
   return true;
 }
 
+} // anonymous namespace
+
 bool
 operator_negate::fold_range (frange &r, tree type,
 			     const frange &op1, const frange &op2,
@@ -1607,7 +1611,9 @@  operator_abs::op1_range (frange &r, tree type,
   return true;
 }
 
-class foperator_unordered_lt : public range_operator
+namespace {
+
+class foperator_unordered_lt final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -1719,7 +1725,7 @@  foperator_unordered_lt::op2_range (frange &r, tree type,
   return true;
 }
 
-class foperator_unordered_le : public range_operator
+class foperator_unordered_le final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -1827,7 +1833,7 @@  foperator_unordered_le::op2_range (frange &r,
   return true;
 }
 
-class foperator_unordered_gt : public range_operator
+class foperator_unordered_gt final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -1939,7 +1945,7 @@  foperator_unordered_gt::op2_range (frange &r,
   return true;
 }
 
-class foperator_unordered_ge : public range_operator
+class foperator_unordered_ge final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -2050,7 +2056,7 @@  foperator_unordered_ge::op2_range (frange &r, tree type,
   return true;
 }
 
-class foperator_unordered_equal : public range_operator
+class foperator_unordered_equal final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -2132,7 +2138,7 @@  foperator_unordered_equal::op1_range (frange &r, tree type,
   return true;
 }
 
-class foperator_ltgt : public range_operator
+class foperator_ltgt final : public range_operator
 {
   using range_operator::fold_range;
   using range_operator::op1_range;
@@ -2214,6 +2220,8 @@  foperator_ltgt::op1_range (frange &r, tree type,
   return true;
 }
 
+} // anonymous namespace
+
 // Final tweaks for float binary op op1_range/op2_range.
 // Return TRUE if the operation is performed and a valid range is available.
 
@@ -2729,6 +2737,7 @@  operator_mult::rv_fold (frange &r, tree type,
   r.set (type, lb, ub, nan_state (maybe_nan));
 }
 
+namespace {
 
 class foperator_div : public range_operator
 {
@@ -2899,6 +2908,8 @@  private:
   }
 } fop_div;
 
+}
+
 
 // Initialize any float operators to the primary table
 
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 24e206c00cd..e5b496eaac2 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -288,7 +288,9 @@  build_ge (prange &r, tree type, const prange &val)
   r.set (type, val.lower_bound (), max_limit (type));
 }
 
-class pointer_plus_operator : public range_operator
+namespace {
+
+class pointer_plus_operator final : public range_operator
 {
   using range_operator::update_bitmask;
   using range_operator::fold_range;
@@ -451,7 +453,11 @@  pointer_plus_operator::op2_range (irange &r, tree type,
   return true;
 }
 
-class pointer_min_max_operator : public range_operator
+#if 0
+
+/* These are not used currently. Since we are in an
+   anonymous namespace, they are needed to be #if'ed out. */
+class pointer_min_max_operator final : public range_operator
 {
 public:
   virtual void wi_fold (irange & r, tree type,
@@ -479,7 +485,7 @@  pointer_min_max_operator::wi_fold (irange &r, tree type,
     r.set_varying (type);
 }
 
-class pointer_and_operator : public range_operator
+class pointer_and_operator final : public range_operator
 {
 public:
   virtual void wi_fold (irange &r, tree type,
@@ -503,7 +509,7 @@  pointer_and_operator::wi_fold (irange &r, tree type,
 }
 
 
-class pointer_or_operator : public range_operator
+class pointer_or_operator final : public range_operator
 {
 public:
   using range_operator::op1_range;
@@ -565,7 +571,9 @@  pointer_or_operator::wi_fold (irange &r, tree type,
     r.set_varying (type);
 }
 
-class operator_pointer_diff : public range_operator
+#endif
+
+class operator_pointer_diff final : public range_operator
 {
   using range_operator::update_bitmask;
   using range_operator::op1_op2_relation_effect;
@@ -612,6 +620,8 @@  operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type,
 					rel);
 }
 
+} // anonymous namespace
+
 bool
 operator_identity::fold_range (prange &r, tree type ATTRIBUTE_UNUSED,
 			       const prange &lh ATTRIBUTE_UNUSED,