[PATCH 2/8] gdbsupport: Make function arguments constant in enum-flags.h

Andrew Burgess
2020-08-13T12:58:54Z

Make the arguments used for the operators within enum-flags.h constant
references where possible. There should be no user visible changes
after this commit.

gdbsupport/ChangeLog:

* enum-flags.h (enum_flags) <operator&=>: Make arguments const.
<operator|=>: Likewise.
<operator^=>: Likewise.
<operator&>: Likewise.
<operator&>: Likewise.
<operator|>: Likewise.
<operator^>: Likewise.
(operator&): Likewise.
(operator|): Likewise.
(operator^): Likewise.
(operator~): Likewise.
---
gdbsupport/ChangeLog | 14 ++++++++++++++
gdbsupport/enum-flags.h | 20 ++++++++++----------
2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/gdbsupport/enum-flags.h b/gdbsupport/enum-flags.h
index 78db3c7d88e..356eb7da785 100644
--- a/gdbsupport/enum-flags.h
+++ b/gdbsupport/enum-flags.h
@@ -129,17 +129,17 @@ class enum_flags
: m_enum_value ((enum_type) 0)
{}

- enum_flags &operator&= (enum_type e)
+ enum_flags &operator&= (const enum_type &e)
{
m_enum_value = (enum_type) (underlying_value () & e);
return *this;
}
- enum_flags &operator|= (enum_type e)
+ enum_flags &operator|= (const enum_type &e)
{
m_enum_value = (enum_type) (underlying_value () | e);
return *this;
}
- enum_flags &operator^= (enum_type e)
+ enum_flags &operator^= (const enum_type &e)
{
m_enum_value = (enum_type) (underlying_value () ^ e);
return *this;
@@ -150,15 +150,15 @@ class enum_flags
return m_enum_value;
}

- enum_flags operator& (enum_type e) const
+ enum_flags operator& (const enum_type &e) const
{
return (enum_type) (underlying_value () & e);
}
- enum_flags operator| (enum_type e) const
+ enum_flags operator| (const enum_type &e) const
{
return (enum_type) (underlying_value () | e);
}
- enum_flags operator^ (enum_type e) const
+ enum_flags operator^ (const enum_type &e) const
{
return (enum_type) (underlying_value () ^ e);
}
@@ -183,28 +183,28 @@ class enum_flags

template <typename enum_type>
typename enum_flags_type<enum_type>::type
-operator& (enum_type e1, enum_type e2)
+operator& (const enum_type &e1, const enum_type &e2)
{
return enum_flags<enum_type> (e1) & e2;
}

template <typename enum_type>
typename enum_flags_type<enum_type>::type
-operator| (enum_type e1, enum_type e2)
+operator| (const enum_type &e1, const enum_type &e2)
{
return enum_flags<enum_type> (e1) | e2;
}

template <typename enum_type>
typename enum_flags_type<enum_type>::type
-operator^ (enum_type e1, enum_type e2)
+operator^ (const enum_type &e1, const enum_type &e2)
{
return enum_flags<enum_type> (e1) ^ e2;
}

template <typename enum_type>
typename enum_flags_type<enum_type>::type
-operator~ (enum_type e)
+operator~ (const enum_type &e)
{
return ~enum_flags<enum_type> (e);
}
--
2.25.4