diff --git a/llvm/include/llvm/ADT/SparseBitVector.h b/llvm/include/llvm/ADT/SparseBitVector.h index 7151af6146e6e..35b3c25db5077 100644 --- a/llvm/include/llvm/ADT/SparseBitVector.h +++ b/llvm/include/llvm/ADT/SparseBitVector.h @@ -119,8 +119,8 @@ template struct SparseBitVectorElement { size_type count() const { unsigned NumBits = 0; - for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i) - NumBits += llvm::popcount(Bits[i]); + for (BitWord Bit : Bits) + NumBits += llvm::popcount(Bit); return NumBits; } @@ -799,11 +799,8 @@ class SparseBitVector { unsigned count() const { unsigned BitCount = 0; - for (ElementListConstIter Iter = Elements.begin(); - Iter != Elements.end(); - ++Iter) - BitCount += Iter->count(); - + for (const auto &Elem : Elements) + BitCount += Elem.count(); return BitCount; }