diff options
-rw-r--r-- | include/llvm/ADT/BitVector.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/llvm/ADT/BitVector.h b/include/llvm/ADT/BitVector.h index 927cfa9f78..38436993c5 100644 --- a/include/llvm/ADT/BitVector.h +++ b/include/llvm/ADT/BitVector.h @@ -245,10 +245,12 @@ public: // Indexing. reference operator[](unsigned Idx) { + assert (Idx < Size && "Out-of-bounds Bit access."); return reference(*this, Idx); } bool operator[](unsigned Idx) const { + assert (Idx < Size && "Out-of-bounds Bit access."); BitWord Mask = 1L << (Idx % BITWORD_SIZE); return (Bits[Idx / BITWORD_SIZE] & Mask) != 0; } @@ -375,6 +377,8 @@ private: // Destroy the old bits. delete[] Bits; Bits = NewBits; + + clear_unused_bits(); } void init_words(BitWord *B, unsigned NumWords, bool t) { |