mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-26 06:04:47 +00:00
Fix a bug in the set(I,E)/reset(I,E) methods that I recently added. The boundary condition for checking if I and E were in the same word were incorrect, and, beyond that, the mask computation was not using a wide enough constant.
llvm-svn: 166015
This commit is contained in:
parent
3d4f7d96ea
commit
cb8d1f6815
@ -244,9 +244,9 @@ public:
|
||||
|
||||
if (I == E) return *this;
|
||||
|
||||
if (I / BITWORD_SIZE == (E-1) / BITWORD_SIZE) {
|
||||
BitWord EMask = 1 << (E % BITWORD_SIZE);
|
||||
BitWord IMask = 1 << (I % BITWORD_SIZE);
|
||||
if (I / BITWORD_SIZE == E / BITWORD_SIZE) {
|
||||
BitWord EMask = 1UL << (E % BITWORD_SIZE);
|
||||
BitWord IMask = 1UL << (I % BITWORD_SIZE);
|
||||
BitWord Mask = EMask - IMask;
|
||||
Bits[I / BITWORD_SIZE] |= Mask;
|
||||
return *this;
|
||||
@ -282,9 +282,9 @@ public:
|
||||
|
||||
if (I == E) return *this;
|
||||
|
||||
if (I / BITWORD_SIZE == (E-1) / BITWORD_SIZE) {
|
||||
BitWord EMask = 1 << (E % BITWORD_SIZE);
|
||||
BitWord IMask = 1 << (I % BITWORD_SIZE);
|
||||
if (I / BITWORD_SIZE == E / BITWORD_SIZE) {
|
||||
BitWord EMask = 1UL << (E % BITWORD_SIZE);
|
||||
BitWord IMask = 1UL << (I % BITWORD_SIZE);
|
||||
BitWord Mask = EMask - IMask;
|
||||
Bits[I / BITWORD_SIZE] &= ~Mask;
|
||||
return *this;
|
||||
|
@ -322,6 +322,16 @@ TYPED_TEST(BitVectorTest, RangeOps) {
|
||||
EXPECT_FALSE(D.test(0));
|
||||
EXPECT_TRUE( D.test(1));
|
||||
EXPECT_TRUE( D.test(2));
|
||||
|
||||
TypeParam E;
|
||||
E.resize(128);
|
||||
E.reset();
|
||||
E.set(1, 33);
|
||||
|
||||
EXPECT_FALSE(E.test(0));
|
||||
EXPECT_TRUE( E.test(1));
|
||||
EXPECT_TRUE( E.test(32));
|
||||
EXPECT_FALSE(E.test(33));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user