llvm.org GIT mirror llvm / e3f7be3
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166015 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 6 years ago
2 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
243243
244244 if (I == E) return *this;
245245
246 if (I / BITWORD_SIZE == (E-1) / BITWORD_SIZE) {
247 BitWord EMask = 1 << (E % BITWORD_SIZE);
248 BitWord IMask = 1 << (I % BITWORD_SIZE);
246 if (I / BITWORD_SIZE == E / BITWORD_SIZE) {
247 BitWord EMask = 1UL << (E % BITWORD_SIZE);
248 BitWord IMask = 1UL << (I % BITWORD_SIZE);
249249 BitWord Mask = EMask - IMask;
250250 Bits[I / BITWORD_SIZE] |= Mask;
251251 return *this;
281281
282282 if (I == E) return *this;
283283
284 if (I / BITWORD_SIZE == (E-1) / BITWORD_SIZE) {
285 BitWord EMask = 1 << (E % BITWORD_SIZE);
286 BitWord IMask = 1 << (I % BITWORD_SIZE);
284 if (I / BITWORD_SIZE == E / BITWORD_SIZE) {
285 BitWord EMask = 1UL << (E % BITWORD_SIZE);
286 BitWord IMask = 1UL << (I % BITWORD_SIZE);
287287 BitWord Mask = EMask - IMask;
288288 Bits[I / BITWORD_SIZE] &= ~Mask;
289289 return *this;
321321 EXPECT_FALSE(D.test(0));
322322 EXPECT_TRUE( D.test(1));
323323 EXPECT_TRUE( D.test(2));
324
325 TypeParam E;
326 E.resize(128);
327 E.reset();
328 E.set(1, 33);
329
330 EXPECT_FALSE(E.test(0));
331 EXPECT_TRUE( E.test(1));
332 EXPECT_TRUE( E.test(32));
333 EXPECT_FALSE(E.test(33));
324334 }
325335 }
326336 #endif