aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-30 13:40:27 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-30 13:40:27 +0000
commit6340722d1751841a00e791a44d8f2f5e481b8c61 (patch)
tree51e405f2c764ddff80415733d74e5d0d6d34aedf /include/llvm
parentb252fbd179c494b3c6220f6f7e42f3ff5d15bda6 (diff)
downloadexternal_llvm-6340722d1751841a00e791a44d8f2f5e481b8c61.zip
external_llvm-6340722d1751841a00e791a44d8f2f5e481b8c61.tar.gz
external_llvm-6340722d1751841a00e791a44d8f2f5e481b8c61.tar.bz2
SmallBitVector: Rework find_first/find_next and tweak test to test them (at least on 64 bit platforms).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102712 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/SmallBitVector.h26
1 files changed, 12 insertions, 14 deletions
diff --git a/include/llvm/ADT/SmallBitVector.h b/include/llvm/ADT/SmallBitVector.h
index 884e631..3441d0a 100644
--- a/include/llvm/ADT/SmallBitVector.h
+++ b/include/llvm/ADT/SmallBitVector.h
@@ -199,13 +199,12 @@ public:
int find_first() const {
if (isSmall()) {
uintptr_t Bits = getSmallBits();
- if (sizeof(uintptr_t) * CHAR_BIT == 32) {
- size_t FirstBit = CountTrailingZeros_32(Bits);
- return FirstBit == 32 ? -1 : FirstBit;
- } else if (sizeof(uintptr_t) * CHAR_BIT == 64) {
- size_t FirstBit = CountTrailingZeros_64(Bits);
- return FirstBit == 64 ? -1 : FirstBit;
- }
+ if (Bits == 0)
+ return -1;
+ if (sizeof(uintptr_t) * CHAR_BIT == 32)
+ return CountTrailingZeros_32(Bits);
+ if (sizeof(uintptr_t) * CHAR_BIT == 64)
+ return CountTrailingZeros_64(Bits);
assert(0 && "Unsupported!");
}
return getPointer()->find_first();
@@ -218,13 +217,12 @@ public:
uintptr_t Bits = getSmallBits();
// Mask off previous bits.
Bits &= ~uintptr_t(0) << (Prev + 1);
- if (sizeof(uintptr_t) * CHAR_BIT == 32) {
- size_t FirstBit = CountTrailingZeros_32(Bits);
- return FirstBit == 32 ? -1 : FirstBit;
- } else if (sizeof(uintptr_t) * CHAR_BIT == 64) {
- size_t FirstBit = CountTrailingZeros_64(Bits);
- return FirstBit == 64 ? -1 : FirstBit;
- }
+ if (Bits == 0 || Prev + 1 >= getSmallSize())
+ return -1;
+ if (sizeof(uintptr_t) * CHAR_BIT == 32)
+ return CountTrailingZeros_32(Bits);
+ if (sizeof(uintptr_t) * CHAR_BIT == 64)
+ return CountTrailingZeros_64(Bits);
assert(0 && "Unsupported!");
}
return getPointer()->find_next(Prev);