1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

make bitvector &= do the right thing if vectors have mismatched length.

llvm-svn: 42860
This commit is contained in:
Chris Lattner 2007-10-11 06:12:33 +00:00
parent ba2ff1f992
commit 0330d81fcf

View File

@ -274,9 +274,18 @@ public:
// Intersection, union, disjoint union.
BitVector operator&=(const BitVector &RHS) {
assert(Size == RHS.Size && "Illegal operation!");
for (unsigned i = 0; i < NumBitWords(size()); ++i)
unsigned ThisWords = NumBitWords(size());
unsigned RHSWords = NumBitWords(RHS.size());
unsigned i;
for (i = 0; i != std::min(ThisWords, RHSWords); ++i)
Bits[i] &= RHS.Bits[i];
// Any bits that are just in this bitvector become zero, because they aren't
// in the RHS bit vector. Any words only in RHS are ignored because they
// are already zero in the LHS.
for (; i != ThisWords; ++i)
Bits[i] = 0;
return *this;
}