Update prebuilt Clang to match Android kernel.
Bug: 132428451
Change-Id: I8f6e2cb23f381fc0c02ddea99b867e58e925e5be
diff --git a/linux-x64/clang/include/llvm/ADT/SmallBitVector.h b/linux-x64/clang/include/llvm/ADT/SmallBitVector.h
index f86bebd..742450e 100644
--- a/linux-x64/clang/include/llvm/ADT/SmallBitVector.h
+++ b/linux-x64/clang/include/llvm/ADT/SmallBitVector.h
@@ -1,9 +1,8 @@
//===- llvm/ADT/SmallBitVector.h - 'Normally small' bit vectors -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -92,10 +91,6 @@
};
private:
- bool isSmall() const {
- return X & uintptr_t(1);
- }
-
BitVector *getPointer() const {
assert(!isSmall());
return reinterpret_cast<BitVector *>(X);
@@ -186,6 +181,8 @@
return make_range(set_bits_begin(), set_bits_end());
}
+ bool isSmall() const { return X & uintptr_t(1); }
+
/// Tests whether there are no bits in this bitvector.
bool empty() const {
return isSmall() ? getSmallSize() == 0 : getPointer()->empty();
@@ -242,7 +239,7 @@
uintptr_t Bits = getSmallBits();
if (Bits == 0)
return -1;
- return NumBaseBits - countLeadingZeros(Bits);
+ return NumBaseBits - countLeadingZeros(Bits) - 1;
}
return getPointer()->find_last();
}
@@ -265,7 +262,9 @@
return -1;
uintptr_t Bits = getSmallBits();
- return NumBaseBits - countLeadingOnes(Bits);
+ // Set unused bits.
+ Bits |= ~uintptr_t(0) << getSmallSize();
+ return NumBaseBits - countLeadingOnes(Bits) - 1;
}
return getPointer()->find_last_unset();
}
@@ -487,10 +486,17 @@
bool operator==(const SmallBitVector &RHS) const {
if (size() != RHS.size())
return false;
- if (isSmall())
+ if (isSmall() && RHS.isSmall())
return getSmallBits() == RHS.getSmallBits();
- else
+ 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])
+ return false;
+ }
+ return true;
+ }
}
bool operator!=(const SmallBitVector &RHS) const {
@@ -498,16 +504,19 @@
}
// Intersection, union, disjoint union.
+ // FIXME BitVector::operator&= does not resize the LHS but this does
SmallBitVector &operator&=(const SmallBitVector &RHS) {
resize(std::max(size(), RHS.size()));
- if (isSmall())
+ if (isSmall() && RHS.isSmall())
setSmallBits(getSmallBits() & RHS.getSmallBits());
- else if (!RHS.isSmall())
+ else if (!isSmall() && !RHS.isSmall())
getPointer()->operator&=(*RHS.getPointer());
else {
- SmallBitVector Copy = RHS;
- Copy.resize(size());
- getPointer()->operator&=(*Copy.getPointer());
+ 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);
}
return *this;
}
@@ -547,28 +556,26 @@
SmallBitVector &operator|=(const SmallBitVector &RHS) {
resize(std::max(size(), RHS.size()));
- if (isSmall())
+ if (isSmall() && RHS.isSmall())
setSmallBits(getSmallBits() | RHS.getSmallBits());
- else if (!RHS.isSmall())
+ else if (!isSmall() && !RHS.isSmall())
getPointer()->operator|=(*RHS.getPointer());
else {
- SmallBitVector Copy = RHS;
- Copy.resize(size());
- getPointer()->operator|=(*Copy.getPointer());
+ for (size_t i = 0, e = RHS.size(); i != e; ++i)
+ (*this)[i] = test(i) || RHS.test(i);
}
return *this;
}
SmallBitVector &operator^=(const SmallBitVector &RHS) {
resize(std::max(size(), RHS.size()));
- if (isSmall())
+ if (isSmall() && RHS.isSmall())
setSmallBits(getSmallBits() ^ RHS.getSmallBits());
- else if (!RHS.isSmall())
+ else if (!isSmall() && !RHS.isSmall())
getPointer()->operator^=(*RHS.getPointer());
else {
- SmallBitVector Copy = RHS;
- Copy.resize(size());
- getPointer()->operator^=(*Copy.getPointer());
+ for (size_t i = 0, e = RHS.size(); i != e; ++i)
+ (*this)[i] = test(i) != RHS.test(i);
}
return *this;
}