aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-02-15 21:38:15 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-02-15 21:38:15 +0000
commitb5aabee33073068f1f6bb71c1da9000b03b16181 (patch)
treeed25b2e23a8f3566b9508d03f0214a1930cedfcc
parent15005154069d43927e474e78d6bb5960112b9052 (diff)
Proper fix for the off-by-one bug in clear_unused_bits().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34328 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ADT/BitVector.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h
index 79c3f58567..269621313f 100644
--- a/include/llvm/ADT/BitVector.h
+++ b/include/llvm/ADT/BitVector.h
@@ -290,12 +290,10 @@ private:
// Clear the unused top bits in the high word.
void clear_unused_bits() {
- if (Size) {
- unsigned ExtraBits = Size % BITS_PER_WORD;
+ unsigned ExtraBits = Size % BITS_PER_WORD;
+ if (ExtraBits) {
unsigned index = Size / BITS_PER_WORD;
- if (Size % BITS_PER_WORD == 0)
- index--;
- Bits[index] &= ~(~0 << ExtraBits);
+ Bits[index] &= ~(~0L << ExtraBits);
}
}