diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h --- a/llvm/include/llvm/ADT/BitVector.h +++ b/llvm/include/llvm/ADT/BitVector.h @@ -85,7 +85,7 @@ unsigned Size; // Size of bitvector in bits. public: - typedef unsigned size_type; + using size_type = unsigned; // Encapsulation of a single bit. class reference { @@ -536,8 +536,8 @@ [&Arg](auto const &BV) { return Arg.size() == BV; }) && "consistent sizes"); Out.resize(Arg.size()); - for (size_t i = 0, e = Arg.Bits.size(); i != e; ++i) - Out.Bits[i] = f(Arg.Bits[i], Args.Bits[i]...); + for (size_type I = 0, E = Arg.Bits.size(); I != E; ++I) + Out.Bits[I] = f(Arg.Bits[I], Args.Bits[I]...); Out.clear_unused_bits(); return Out; } @@ -545,16 +545,16 @@ BitVector &operator|=(const BitVector &RHS) { if (size() < RHS.size()) resize(RHS.size()); - for (size_t i = 0, e = RHS.Bits.size(); i != e; ++i) - Bits[i] |= RHS.Bits[i]; + for (size_type I = 0, E = RHS.Bits.size(); I != E; ++I) + Bits[I] |= RHS.Bits[I]; return *this; } BitVector &operator^=(const BitVector &RHS) { if (size() < RHS.size()) resize(RHS.size()); - for (size_t i = 0, e = RHS.Bits.size(); i != e; ++i) - Bits[i] ^= RHS.Bits[i]; + for (size_type I = 0, E = RHS.Bits.size(); I != E; ++I) + Bits[I] ^= RHS.Bits[I]; return *this; } @@ -808,11 +808,11 @@ public: /// Return the size (in bytes) of the bit vector. - size_t getMemorySize() const { return Bits.size() * sizeof(BitWord); } - size_t getBitCapacity() const { return Bits.size() * BITWORD_SIZE; } + size_type getMemorySize() const { return Bits.size() * sizeof(BitWord); } + size_type getBitCapacity() const { return Bits.size() * BITWORD_SIZE; } }; -inline size_t capacity_in_bytes(const BitVector &X) { +inline BitVector::size_type capacity_in_bytes(const BitVector &X) { return X.getMemorySize(); } @@ -824,8 +824,8 @@ return V; } static unsigned getHashValue(const BitVector &V) { - return DenseMapInfo>>::getHashValue( - std::make_pair(V.size(), V.getData())); + return DenseMapInfo>>:: + getHashValue(std::make_pair(V.size(), V.getData())); } static bool isEqual(const BitVector &LHS, const BitVector &RHS) { if (LHS.isInvalid() || RHS.isInvalid()) diff --git a/llvm/include/llvm/ADT/SmallBitVector.h b/llvm/include/llvm/ADT/SmallBitVector.h --- a/llvm/include/llvm/ADT/SmallBitVector.h +++ b/llvm/include/llvm/ADT/SmallBitVector.h @@ -60,7 +60,7 @@ "Unsupported word size"); public: - using size_type = unsigned; + using size_type = uintptr_t; // Encapsulation of a single bit. class reference { @@ -96,7 +96,7 @@ return reinterpret_cast(X); } - void switchToSmall(uintptr_t NewSmallBits, size_t NewSize) { + void switchToSmall(uintptr_t NewSmallBits, size_type NewSize) { X = 1; setSmallSize(NewSize); setSmallBits(NewSmallBits); @@ -120,9 +120,11 @@ } // Return the size. - size_t getSmallSize() const { return getSmallRawBits() >> SmallNumDataBits; } + size_type getSmallSize() const { + return getSmallRawBits() >> SmallNumDataBits; + } - void setSmallSize(size_t Size) { + void setSmallSize(size_type Size) { setSmallRawBits(getSmallBits() | (Size << SmallNumDataBits)); } @@ -189,7 +191,7 @@ } /// Returns the number of bits in this bitvector. - size_t size() const { + size_type size() const { return isSmall() ? getSmallSize() : getPointer()->size(); } @@ -336,8 +338,8 @@ } else { BitVector *BV = new BitVector(N, t); uintptr_t OldBits = getSmallBits(); - for (size_t i = 0, e = getSmallSize(); i != e; ++i) - (*BV)[i] = (OldBits >> i) & 1; + for (size_type I = 0, E = getSmallSize(); I != E; ++I) + (*BV)[I] = (OldBits >> I) & 1; switchToLarge(BV); } } @@ -346,11 +348,11 @@ if (isSmall()) { if (N > SmallNumDataBits) { uintptr_t OldBits = getSmallRawBits(); - size_t SmallSize = getSmallSize(); + size_type SmallSize = getSmallSize(); BitVector *BV = new BitVector(SmallSize); - for (size_t i = 0; i < SmallSize; ++i) - if ((OldBits >> i) & 1) - BV->set(i); + for (size_type I = 0; I < SmallSize; ++I) + if ((OldBits >> I) & 1) + BV->set(I); BV->reserve(N); switchToLarge(BV); } @@ -491,8 +493,8 @@ else if (!isSmall() && !RHS.isSmall()) return *getPointer() == *RHS.getPointer(); else { - for (size_t i = 0, e = size(); i != e; ++i) { - if ((*this)[i] != RHS[i]) + for (size_type I = 0, E = size(); I != E; ++I) { + if ((*this)[I] != RHS[I]) return false; } return true; @@ -512,11 +514,11 @@ else if (!isSmall() && !RHS.isSmall()) getPointer()->operator&=(*RHS.getPointer()); else { - size_t i, e; - for (i = 0, e = std::min(size(), RHS.size()); i != e; ++i) - (*this)[i] = test(i) && RHS.test(i); - for (e = size(); i != e; ++i) - reset(i); + size_type I, E; + for (I = 0, E = std::min(size(), RHS.size()); I != E; ++I) + (*this)[I] = test(I) && RHS.test(I); + for (E = size(); I != E; ++I) + reset(I); } return *this; } @@ -561,8 +563,8 @@ else if (!isSmall() && !RHS.isSmall()) getPointer()->operator|=(*RHS.getPointer()); else { - for (size_t i = 0, e = RHS.size(); i != e; ++i) - (*this)[i] = test(i) || RHS.test(i); + for (size_type I = 0, E = RHS.size(); I != E; ++I) + (*this)[I] = test(I) || RHS.test(I); } return *this; } @@ -574,8 +576,8 @@ else if (!isSmall() && !RHS.isSmall()) getPointer()->operator^=(*RHS.getPointer()); else { - for (size_t i = 0, e = RHS.size(); i != e; ++i) - (*this)[i] = test(i) != RHS.test(i); + for (size_type I = 0, E = RHS.size(); I != E; ++I) + (*this)[I] = test(I) != RHS.test(I); } return *this; } @@ -721,8 +723,9 @@ } static unsigned getHashValue(const SmallBitVector &V) { uintptr_t Store; - return DenseMapInfo>>::getHashValue( - std::make_pair(V.size(), V.getData(Store))); + return DenseMapInfo< + std::pair>>:: + getHashValue(std::make_pair(V.size(), V.getData(Store))); } static bool isEqual(const SmallBitVector &LHS, const SmallBitVector &RHS) { if (LHS.isInvalid() || RHS.isInvalid())