base: Remove dubious/unused Flags functions

The functions isSet(), noneSet(), and allSet() assume that
all bits of the underlying container have a corresponding
flag. This is typically not true, and the likelihood of
incorrectly using these functions is high.

Fortunately these functions are not being used anywhere,
and can be safely removed.

Alternatively, a mask could be provided on construction to
determine which bits of the underlying container correspond
to a flag bit, so that the proper bits are checked in these
functions.

Change-Id: Ia7cbfd0726943506a3f04dc417e67a0b57cdbf95
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38736
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Daniel R. Carvalho
2020-12-26 11:31:03 -03:00
committed by Daniel Carvalho
parent e67b00710c
commit 2aa5fb0d63
2 changed files with 1 additions and 55 deletions

View File

@@ -71,13 +71,6 @@ class Flags
return *this;
}
/**
* Verifies whether any bit in the flags is set.
*
* @return True if any flag bit is set; false otherwise.
*/
bool isSet() const { return _flags; }
/**
* Verifies whether any bit matching the given mask is set.
*
@@ -86,13 +79,6 @@ class Flags
*/
bool isSet(Type mask) const { return (_flags & mask); }
/**
* Verifies whether all bits in the flags are set.
*
* @return True if all flag bits are set; false otherwise.
*/
bool allSet() const { return !(~_flags); }
/**
* Verifies whether no bits matching the given mask are set.
*
@@ -101,13 +87,6 @@ class Flags
*/
bool allSet(Type mask) const { return (_flags & mask) == mask; }
/**
* Verifies whether no bits in the flags are set.
*
* @return True if all flag bits are cleared; false otherwise.
*/
bool noneSet() const { return _flags == 0; }
/**
* Verifies whether no bits matching the given mask are set.
*

View File

@@ -99,16 +99,6 @@ TEST(FlagsTest, FlagsAssignmentOverwrite)
ASSERT_EQ(uint32_t(flags_a), uint32_t(flags_b));
}
/** Test isSet for any bit set. */
TEST(FlagsTest, IsSetAny)
{
const uint32_t value = (1 << 3);
const Flags<uint32_t> flags_a;
const Flags<uint32_t> flags_b(value);
ASSERT_FALSE(flags_a.isSet());
ASSERT_TRUE(flags_b.isSet());
}
/** Test isSet for multiple bits set. */
TEST(FlagsTest, IsSetValue)
{
@@ -131,19 +121,6 @@ TEST(FlagsTest, IsSetType)
ASSERT_FALSE(flags.isSet(value_c));
}
/** Test if all bits are set with allSet. */
TEST(FlagsTest, AllSet)
{
const uint32_t value_b = (1 << 5) | (1 << 6);
const uint32_t value_c = std::numeric_limits<uint32_t>::max();
const Flags<uint32_t> flags_a;
const Flags<uint32_t> flags_b(value_b);
const Flags<uint32_t> flags_c(value_c);
ASSERT_FALSE(flags_a.allSet());
ASSERT_FALSE(flags_b.allSet());
ASSERT_TRUE(flags_c.allSet());
}
/** Test allSet comparing against another flag. */
TEST(FlagsTest, AllSetMatch)
{
@@ -154,16 +131,6 @@ TEST(FlagsTest, AllSetMatch)
ASSERT_FALSE(flags.allSet(value_b));
}
/** Test if no bits are set with noneSet. */
TEST(FlagsTest, NoneSet)
{
const uint32_t value_b = (1 << 5) | (1 << 6);
const Flags<uint32_t> flags_a;
const Flags<uint32_t> flags_b(value_b);
ASSERT_TRUE(flags_a.noneSet());
ASSERT_FALSE(flags_b.noneSet());
}
/** Test noneSet comparing against another flag. */
TEST(FlagsTest, NoneSetMatch)
{
@@ -182,7 +149,7 @@ TEST(FlagsTest, Clear)
const uint32_t value = (1 << 5) | (1 << 6);
Flags<uint32_t> flags(value);
flags.clear();
ASSERT_TRUE(flags.noneSet());
ASSERT_EQ(0, uint32_t(flags));
}
/** Test clearing specific bits. */