diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-02-15 08:15:58 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-02-15 08:15:58 +0000 |
commit | 506e89949024a055fb9fc7258e96bf4b581135e4 (patch) | |
tree | 84f26a1ca7039fedfa7f060734cc5898d8e4fda9 /include/llvm/ADT/BitVector.h | |
parent | b04973edfaffb12905f58379d632f0d7e4bb5d9b (diff) | |
download | external_llvm-506e89949024a055fb9fc7258e96bf4b581135e4.zip external_llvm-506e89949024a055fb9fc7258e96bf4b581135e4.tar.gz external_llvm-506e89949024a055fb9fc7258e96bf4b581135e4.tar.bz2 |
Bug fixes: assignment operator forgot to copy over size; copy ctor forgot to clear unused top bits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34305 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/BitVector.h')
-rw-r--r-- | include/llvm/ADT/BitVector.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 88a175c..2ac4a82 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -86,6 +86,7 @@ public: Capacity = NumBitWords(s); Bits = new BitWord[Capacity]; init_words(Bits, Capacity, t); + clear_unused_bits(); } /// BitVector copy ctor. @@ -175,6 +176,7 @@ public: init_words(&Bits[OldCapacity], (Capacity-OldCapacity), t); } Size = N; + clear_unused_bits(); } void reserve(unsigned N) { @@ -274,17 +276,16 @@ public: const BitVector &operator=(const BitVector &RHS) { if (this == &RHS) return *this; - unsigned RHSWords = NumBitWords(RHS.size()); - unsigned NewSize = RHS.size(); - if (NewSize <= Capacity * BITS_PER_WORD) { + Size = RHS.size(); + unsigned RHSWords = NumBitWords(Size); + if (Size > Capacity * BITS_PER_WORD) { std::copy(RHS.Bits, &RHS.Bits[RHSWords], Bits); - Size = NewSize; clear_unused_bits(); return *this; } // Grow the bitvector to have enough elements. - Capacity = NumBitWords(NewSize); + Capacity = NumBitWords(Size); BitWord *NewBits = new BitWord[Capacity]; std::copy(RHS.Bits, &RHS.Bits[RHSWords], NewBits); |