From: Daniel R. Carvalho Date: Sat, 26 Dec 2020 14:31:03 +0000 (-0300) Subject: base: Remove dubious/unused Flags functions X-Git-Tag: develop-gem5-snapshot~276 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2aa5fb0d63ecc769085a7ebe9b1abda79668f5da;p=gem5.git 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 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38736 Maintainer: Bobby R. Bruce Tested-by: kokoro Reviewed-by: Jason Lowe-Power Reviewed-by: Bobby R. Bruce --- diff --git a/src/base/flags.hh b/src/base/flags.hh index 170abc544..6e8221004 100644 --- a/src/base/flags.hh +++ b/src/base/flags.hh @@ -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. * diff --git a/src/base/flags.test.cc b/src/base/flags.test.cc index 297abc8f3..c45a7a89d 100644 --- a/src/base/flags.test.cc +++ b/src/base/flags.test.cc @@ -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 flags_a; - const Flags 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::max(); - const Flags flags_a; - const Flags flags_b(value_b); - const Flags 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 flags_a; - const Flags 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 flags(value); flags.clear(); - ASSERT_TRUE(flags.noneSet()); + ASSERT_EQ(0, uint32_t(flags)); } /** Test clearing specific bits. */