While making range_op_table a singleton, I noticed that constification
should be done to `operator[]` and that operator_table could be made
as const as it does not get changed after it is initialized.
Bootstrapped and tested on x86_64-linux.
gcc/ChangeLog:
* range-op.h (range_op_table): Make operator[] const.
Have singleton return const reference.
* range-op.cc (range_op_table::singleton): Update return type.
(operator_table): Make const.
Signed-off-by: Andrew Pinski <[email protected]>
---
gcc/range-op.cc | 4 ++--
gcc/range-op.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 56a014e99bc..9a889ea4bb4 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -75,7 +75,7 @@ operator_min op_min;
operator_max op_max;
// Instantaite a range operator table.
-range_op_table &operator_table = range_op_table::singleton();
+const range_op_table &operator_table = range_op_table::singleton();
// Instantiate a default range operator for opcodes with no entry.
range_operator default_operator;
@@ -118,7 +118,7 @@ range_op_table::range_op_table ()
}
// Returns the singleton instance of the table.
-range_op_table &range_op_table::singleton()
+const range_op_table &range_op_table::singleton()
{
static range_op_table single;
return single;
diff --git a/gcc/range-op.h b/gcc/range-op.h
index e4e11f89624..f7ecc660fb9 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -391,12 +391,12 @@ extern void wi_set_zero_nonzero_bits (tree type,
class range_op_table final
{
public:
- inline range_operator *operator[] (unsigned code)
+ inline range_operator *operator[] (unsigned code) const
{
gcc_checking_assert (code < RANGE_OP_TABLE_SIZE);
return m_range_tree[code];
}
- static range_op_table &singleton();
+ static const range_op_table &singleton();
private:
inline void set (unsigned code, range_operator &op)
{
--
2.43.0