diff options
author | Daniel Sanders <daniel_l_sanders@apple.com> | 2018-10-31 20:05:32 +0000 |
---|---|---|
committer | Daniel Sanders <daniel_l_sanders@apple.com> | 2018-10-31 20:05:32 +0000 |
commit | 792c305d691df9aeb9268bd048121f5a13da6c99 (patch) | |
tree | 6514fa152f6a280f8d503637c70279d1e3a45292 /unittests | |
parent | cd627aacb4c4b981bb7a74d42c3ef20d36be201b (diff) |
[adt] SparseBitVector::test() should be const
Summary:
Re-worked SparseBitVector's most-recently-used-word caching (CurrElementIter)
such that SparseBitVector::test() can be made const. This came up when
attempting to test individual bits in a SparseBitVector which was a member of a
const object.
The cached iterator has no bearing on the externally visible state, it's merely
a performance optimization. Therefore it has been made mutable and
FindLowerBound() has been split into a const and non-const function
(FindLowerBound/FindLowerBoundConst) for the const/non-const
interfaces.
Reviewers: rtereshin
Reviewed By: rtereshin
Subscribers: rtereshin, dexonsmith, kristina, llvm-commits
Differential Revision: https://reviews.llvm.org/D53447
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/SparseBitVectorTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/unittests/ADT/SparseBitVectorTest.cpp b/unittests/ADT/SparseBitVectorTest.cpp index 9d6f4f1665d..097f4a0b737 100644 --- a/unittests/ADT/SparseBitVectorTest.cpp +++ b/unittests/ADT/SparseBitVectorTest.cpp @@ -31,6 +31,11 @@ TEST(SparseBitVectorTest, TrivialOperation) { EXPECT_TRUE(Vec.test(17)); Vec.clear(); EXPECT_FALSE(Vec.test(17)); + + Vec.set(5); + const SparseBitVector<> ConstVec = Vec; + EXPECT_TRUE(ConstVec.test(5)); + EXPECT_FALSE(ConstVec.test(17)); } TEST(SparseBitVectorTest, IntersectWith) { |