summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-09-16 18:02:49 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-09-16 18:02:49 +0000
commit0d8a008611fa03e9eeacfd8cfe6be3e4f56ff2b9 (patch)
tree6fc5f5e63a3c8eae728c46873c04a9785d7e8d16
parent21641a2f6dbac22653befd03496e0850537882ff (diff)
downloadbcm5719-llvm-0d8a008611fa03e9eeacfd8cfe6be3e4f56ff2b9.tar.gz
bcm5719-llvm-0d8a008611fa03e9eeacfd8cfe6be3e4f56ff2b9.zip
[lldb] Remove SetCount/ClearCount from Flags
Summary: These functions are only used in tests where we should test the actual flag values instead of counting all bits for an approximate check. Also these popcount implementation aren't very efficient and doesn't seem to be optimised to anything fast. Reviewers: davide, JDevlieghere Reviewed By: davide, JDevlieghere Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67540 llvm-svn: 372018
-rw-r--r--lldb/include/lldb/Utility/Flags.h26
-rw-r--r--lldb/unittests/Utility/FlagsTest.cpp41
2 files changed, 3 insertions, 64 deletions
diff --git a/lldb/include/lldb/Utility/Flags.h b/lldb/include/lldb/Utility/Flags.h
index 48b14e7d2a2..aa869eca0c6 100644
--- a/lldb/include/lldb/Utility/Flags.h
+++ b/lldb/include/lldb/Utility/Flags.h
@@ -121,32 +121,6 @@ public:
/// \b true if \a bit is 0, \b false otherwise.
bool IsClear(ValueType bit) const { return (m_flags & bit) == 0; }
- /// Get the number of zero bits in \a m_flags.
- ///
- /// \return
- /// The number of bits that are set to 0 in the current flags.
- size_t ClearCount() const {
- size_t count = 0;
- for (ValueType shift = 0; shift < sizeof(ValueType) * 8; ++shift) {
- if ((m_flags & (1u << shift)) == 0)
- ++count;
- }
- return count;
- }
-
- /// Get the number of one bits in \a m_flags.
- ///
- /// \return
- /// The number of bits that are set to 1 in the current flags.
- size_t SetCount() const {
- size_t count = 0;
- for (ValueType mask = m_flags; mask; mask >>= 1) {
- if (mask & 1u)
- ++count;
- }
- return count;
- }
-
protected:
ValueType m_flags; ///< The flags.
};
diff --git a/lldb/unittests/Utility/FlagsTest.cpp b/lldb/unittests/Utility/FlagsTest.cpp
index e26b620f9e2..6a46bcc2d6f 100644
--- a/lldb/unittests/Utility/FlagsTest.cpp
+++ b/lldb/unittests/Utility/FlagsTest.cpp
@@ -30,19 +30,18 @@ TEST(Flags, Reset) {
Flags f;
f.Reset(0x3);
EXPECT_EQ(0x3U, f.Get());
- EXPECT_EQ(2U, f.SetCount());
}
TEST(Flags, Clear) {
Flags f;
f.Reset(0x3);
- EXPECT_EQ(2U, f.SetCount());
+ EXPECT_EQ(0x3U, f.Get());
f.Clear(0x5);
- EXPECT_EQ(1U, f.SetCount());
+ EXPECT_EQ(0x2U, f.Get());
f.Clear();
- EXPECT_EQ(0U, f.SetCount());
+ EXPECT_EQ(0x0U, f.Get());
}
TEST(Flags, AllSet) {
@@ -162,37 +161,3 @@ TEST(Flags, IsClear) {
EXPECT_TRUE(f.IsClear(eFlag0));
EXPECT_TRUE(f.IsClear(eFlag1));
}
-
-TEST(Flags, ClearCount) {
- Flags f;
- EXPECT_EQ(32U, f.ClearCount());
-
- f.Set(eFlag0);
- EXPECT_EQ(31U, f.ClearCount());
-
- f.Set(eFlag0);
- EXPECT_EQ(31U, f.ClearCount());
-
- f.Set(eFlag1);
- EXPECT_EQ(30U, f.ClearCount());
-
- f.Set(eAllFlags);
- EXPECT_EQ(29U, f.ClearCount());
-}
-
-TEST(Flags, SetCount) {
- Flags f;
- EXPECT_EQ(0U, f.SetCount());
-
- f.Set(eFlag0);
- EXPECT_EQ(1U, f.SetCount());
-
- f.Set(eFlag0);
- EXPECT_EQ(1U, f.SetCount());
-
- f.Set(eFlag1);
- EXPECT_EQ(2U, f.SetCount());
-
- f.Set(eAllFlags);
- EXPECT_EQ(3U, f.SetCount());
-}
OpenPOWER on IntegriCloud