Update clang to r339409.
Change-Id: I800772d2d838223be1f6b40d490c4591b937fca2
diff --git a/linux-x64/clang/include/llvm/ADT/APFloat.h b/linux-x64/clang/include/llvm/ADT/APFloat.h
index 6c0b6ae..5c59af4 100644
--- a/linux-x64/clang/include/llvm/ADT/APFloat.h
+++ b/linux-x64/clang/include/llvm/ADT/APFloat.h
@@ -1215,7 +1215,7 @@
return X;
}
-/// \brief Returns the negated value of the argument.
+/// Returns the negated value of the argument.
inline APFloat neg(APFloat X) {
X.changeSign();
return X;
diff --git a/linux-x64/clang/include/llvm/ADT/APInt.h b/linux-x64/clang/include/llvm/ADT/APInt.h
index 118c62e..684a257 100644
--- a/linux-x64/clang/include/llvm/ADT/APInt.h
+++ b/linux-x64/clang/include/llvm/ADT/APInt.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
///
/// \file
-/// \brief This file implements a class to represent arbitrary precision
+/// This file implements a class to represent arbitrary precision
/// integral constant values and operations on them.
///
//===----------------------------------------------------------------------===//
@@ -31,6 +31,7 @@
template <typename T> class SmallVectorImpl;
template <typename T> class ArrayRef;
+template <typename T> class Optional;
class APInt;
@@ -40,7 +41,7 @@
// APInt Class
//===----------------------------------------------------------------------===//
-/// \brief Class for arbitrary precision integers.
+/// Class for arbitrary precision integers.
///
/// APInt is a functional replacement for common case unsigned integer type like
/// "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width
@@ -78,6 +79,12 @@
APINT_BITS_PER_WORD = APINT_WORD_SIZE * CHAR_BIT
};
+ enum class Rounding {
+ DOWN,
+ TOWARD_ZERO,
+ UP,
+ };
+
static const WordType WORD_MAX = ~WordType(0);
private:
@@ -94,7 +101,7 @@
friend class APSInt;
- /// \brief Fast internal constructor
+ /// Fast internal constructor
///
/// This constructor is used only internally for speed of construction of
/// temporaries. It is unsafe for general use so it is not public.
@@ -102,19 +109,19 @@
U.pVal = val;
}
- /// \brief Determine if this APInt just has one word to store value.
+ /// Determine if this APInt just has one word to store value.
///
/// \returns true if the number of bits <= 64, false otherwise.
bool isSingleWord() const { return BitWidth <= APINT_BITS_PER_WORD; }
- /// \brief Determine which word a bit is in.
+ /// Determine which word a bit is in.
///
/// \returns the word position for the specified bit position.
static unsigned whichWord(unsigned bitPosition) {
return bitPosition / APINT_BITS_PER_WORD;
}
- /// \brief Determine which bit in a word a bit is in.
+ /// Determine which bit in a word a bit is in.
///
/// \returns the bit position in a word for the specified bit position
/// in the APInt.
@@ -122,7 +129,7 @@
return bitPosition % APINT_BITS_PER_WORD;
}
- /// \brief Get a single bit mask.
+ /// Get a single bit mask.
///
/// \returns a uint64_t with only bit at "whichBit(bitPosition)" set
/// This method generates and returns a uint64_t (word) mask for a single
@@ -132,7 +139,7 @@
return 1ULL << whichBit(bitPosition);
}
- /// \brief Clear unused high order bits
+ /// Clear unused high order bits
///
/// This method is used internally to clear the top "N" bits in the high order
/// word that are not used by the APInt. This is needed after the most
@@ -151,7 +158,7 @@
return *this;
}
- /// \brief Get the word corresponding to a bit position
+ /// Get the word corresponding to a bit position
/// \returns the corresponding word for the specified bit position.
uint64_t getWord(unsigned bitPosition) const {
return isSingleWord() ? U.VAL : U.pVal[whichWord(bitPosition)];
@@ -162,7 +169,7 @@
/// value of any bits upon return. Caller should populate the bits after.
void reallocate(unsigned NewBitWidth);
- /// \brief Convert a char array into an APInt
+ /// Convert a char array into an APInt
///
/// \param radix 2, 8, 10, 16, or 36
/// Converts a string into a number. The string must be non-empty
@@ -176,7 +183,7 @@
/// result to hold the input.
void fromString(unsigned numBits, StringRef str, uint8_t radix);
- /// \brief An internal division function for dividing APInts.
+ /// An internal division function for dividing APInts.
///
/// This is used by the toString method to divide by the radix. It simply
/// provides a more convenient form of divide for internal use since KnuthDiv
@@ -258,7 +265,7 @@
/// \name Constructors
/// @{
- /// \brief Create a new APInt of numBits width, initialized as val.
+ /// Create a new APInt of numBits width, initialized as val.
///
/// If isSigned is true then val is treated as if it were a signed value
/// (i.e. as an int64_t) and the appropriate sign extension to the bit width
@@ -279,7 +286,7 @@
}
}
- /// \brief Construct an APInt of numBits width, initialized as bigVal[].
+ /// Construct an APInt of numBits width, initialized as bigVal[].
///
/// Note that bigVal.size() can be smaller or larger than the corresponding
/// bit width but any extraneous bits will be dropped.
@@ -297,7 +304,7 @@
/// constructor.
APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[]);
- /// \brief Construct an APInt from a string representation.
+ /// Construct an APInt from a string representation.
///
/// This constructor interprets the string \p str in the given radix. The
/// interpretation stops when the first character that is not suitable for the
@@ -311,7 +318,7 @@
APInt(unsigned numBits, StringRef str, uint8_t radix);
/// Simply makes *this a copy of that.
- /// @brief Copy Constructor.
+ /// Copy Constructor.
APInt(const APInt &that) : BitWidth(that.BitWidth) {
if (isSingleWord())
U.VAL = that.U.VAL;
@@ -319,26 +326,26 @@
initSlowCase(that);
}
- /// \brief Move Constructor.
+ /// Move Constructor.
APInt(APInt &&that) : BitWidth(that.BitWidth) {
memcpy(&U, &that.U, sizeof(U));
that.BitWidth = 0;
}
- /// \brief Destructor.
+ /// Destructor.
~APInt() {
if (needsCleanup())
delete[] U.pVal;
}
- /// \brief Default constructor that creates an uninteresting APInt
+ /// Default constructor that creates an uninteresting APInt
/// representing a 1-bit zero value.
///
/// This is useful for object deserialization (pair this with the static
/// method Read).
explicit APInt() : BitWidth(1) { U.VAL = 0; }
- /// \brief Returns whether this instance allocated memory.
+ /// Returns whether this instance allocated memory.
bool needsCleanup() const { return !isSingleWord(); }
/// Used to insert APInt objects, or objects that contain APInt objects, into
@@ -349,33 +356,33 @@
/// \name Value Tests
/// @{
- /// \brief Determine sign of this APInt.
+ /// Determine sign of this APInt.
///
/// This tests the high bit of this APInt to determine if it is set.
///
/// \returns true if this APInt is negative, false otherwise
bool isNegative() const { return (*this)[BitWidth - 1]; }
- /// \brief Determine if this APInt Value is non-negative (>= 0)
+ /// Determine if this APInt Value is non-negative (>= 0)
///
/// This tests the high bit of the APInt to determine if it is unset.
bool isNonNegative() const { return !isNegative(); }
- /// \brief Determine if sign bit of this APInt is set.
+ /// Determine if sign bit of this APInt is set.
///
/// This tests the high bit of this APInt to determine if it is set.
///
/// \returns true if this APInt has its sign bit set, false otherwise.
bool isSignBitSet() const { return (*this)[BitWidth-1]; }
- /// \brief Determine if sign bit of this APInt is clear.
+ /// Determine if sign bit of this APInt is clear.
///
/// This tests the high bit of this APInt to determine if it is clear.
///
/// \returns true if this APInt has its sign bit clear, false otherwise.
bool isSignBitClear() const { return !isSignBitSet(); }
- /// \brief Determine if this APInt Value is positive.
+ /// Determine if this APInt Value is positive.
///
/// This tests if the value of this APInt is positive (> 0). Note
/// that 0 is not a positive value.
@@ -383,7 +390,7 @@
/// \returns true if this APInt is positive.
bool isStrictlyPositive() const { return isNonNegative() && !isNullValue(); }
- /// \brief Determine if all bits are set
+ /// Determine if all bits are set
///
/// This checks to see if the value has all bits of the APInt are set or not.
bool isAllOnesValue() const {
@@ -392,13 +399,13 @@
return countTrailingOnesSlowCase() == BitWidth;
}
- /// \brief Determine if all bits are clear
+ /// Determine if all bits are clear
///
/// This checks to see if the value has all bits of the APInt are clear or
/// not.
bool isNullValue() const { return !*this; }
- /// \brief Determine if this is a value of 1.
+ /// Determine if this is a value of 1.
///
/// This checks to see if the value of this APInt is one.
bool isOneValue() const {
@@ -407,13 +414,13 @@
return countLeadingZerosSlowCase() == BitWidth - 1;
}
- /// \brief Determine if this is the largest unsigned value.
+ /// Determine if this is the largest unsigned value.
///
/// This checks to see if the value of this APInt is the maximum unsigned
/// value for the APInt's bit width.
bool isMaxValue() const { return isAllOnesValue(); }
- /// \brief Determine if this is the largest signed value.
+ /// Determine if this is the largest signed value.
///
/// This checks to see if the value of this APInt is the maximum signed
/// value for the APInt's bit width.
@@ -423,13 +430,13 @@
return !isNegative() && countTrailingOnesSlowCase() == BitWidth - 1;
}
- /// \brief Determine if this is the smallest unsigned value.
+ /// Determine if this is the smallest unsigned value.
///
/// This checks to see if the value of this APInt is the minimum unsigned
/// value for the APInt's bit width.
bool isMinValue() const { return isNullValue(); }
- /// \brief Determine if this is the smallest signed value.
+ /// Determine if this is the smallest signed value.
///
/// This checks to see if the value of this APInt is the minimum signed
/// value for the APInt's bit width.
@@ -439,19 +446,19 @@
return isNegative() && countTrailingZerosSlowCase() == BitWidth - 1;
}
- /// \brief Check if this APInt has an N-bits unsigned integer value.
+ /// Check if this APInt has an N-bits unsigned integer value.
bool isIntN(unsigned N) const {
assert(N && "N == 0 ???");
return getActiveBits() <= N;
}
- /// \brief Check if this APInt has an N-bits signed integer value.
+ /// Check if this APInt has an N-bits signed integer value.
bool isSignedIntN(unsigned N) const {
assert(N && "N == 0 ???");
return getMinSignedBits() <= N;
}
- /// \brief Check if this APInt's value is a power of two greater than zero.
+ /// Check if this APInt's value is a power of two greater than zero.
///
/// \returns true if the argument APInt value is a power of two > 0.
bool isPowerOf2() const {
@@ -460,12 +467,12 @@
return countPopulationSlowCase() == 1;
}
- /// \brief Check if the APInt's value is returned by getSignMask.
+ /// Check if the APInt's value is returned by getSignMask.
///
/// \returns true if this is the value returned by getSignMask.
bool isSignMask() const { return isMinSignedValue(); }
- /// \brief Convert APInt to a boolean value.
+ /// Convert APInt to a boolean value.
///
/// This converts the APInt to a boolean value as a test against zero.
bool getBoolValue() const { return !!*this; }
@@ -476,7 +483,7 @@
return ugt(Limit) ? Limit : getZExtValue();
}
- /// \brief Check if the APInt consists of a repeated bit pattern.
+ /// Check if the APInt consists of a repeated bit pattern.
///
/// e.g. 0x01010101 satisfies isSplat(8).
/// \param SplatSizeInBits The size of the pattern in bits. Must divide bit
@@ -505,7 +512,7 @@
return (Ones > 0) && ((Ones + countLeadingZerosSlowCase()) == BitWidth);
}
- /// \brief Return true if this APInt value contains a sequence of ones with
+ /// Return true if this APInt value contains a sequence of ones with
/// the remainder zero.
bool isShiftedMask() const {
if (isSingleWord())
@@ -519,29 +526,29 @@
/// \name Value Generators
/// @{
- /// \brief Gets maximum unsigned value of APInt for specific bit width.
+ /// Gets maximum unsigned value of APInt for specific bit width.
static APInt getMaxValue(unsigned numBits) {
return getAllOnesValue(numBits);
}
- /// \brief Gets maximum signed value of APInt for a specific bit width.
+ /// Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMaxValue(unsigned numBits) {
APInt API = getAllOnesValue(numBits);
API.clearBit(numBits - 1);
return API;
}
- /// \brief Gets minimum unsigned value of APInt for a specific bit width.
+ /// Gets minimum unsigned value of APInt for a specific bit width.
static APInt getMinValue(unsigned numBits) { return APInt(numBits, 0); }
- /// \brief Gets minimum signed value of APInt for a specific bit width.
+ /// Gets minimum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits) {
APInt API(numBits, 0);
API.setBit(numBits - 1);
return API;
}
- /// \brief Get the SignMask for a specific bit width.
+ /// Get the SignMask for a specific bit width.
///
/// This is just a wrapper function of getSignedMinValue(), and it helps code
/// readability when we want to get a SignMask.
@@ -549,19 +556,19 @@
return getSignedMinValue(BitWidth);
}
- /// \brief Get the all-ones value.
+ /// Get the all-ones value.
///
/// \returns the all-ones value for an APInt of the specified bit-width.
static APInt getAllOnesValue(unsigned numBits) {
return APInt(numBits, WORD_MAX, true);
}
- /// \brief Get the '0' value.
+ /// Get the '0' value.
///
/// \returns the '0' value for an APInt of the specified bit-width.
static APInt getNullValue(unsigned numBits) { return APInt(numBits, 0); }
- /// \brief Compute an APInt containing numBits highbits from this APInt.
+ /// Compute an APInt containing numBits highbits from this APInt.
///
/// Get an APInt with the same BitWidth as this APInt, just zero mask
/// the low bits and right shift to the least significant bit.
@@ -569,7 +576,7 @@
/// \returns the high "numBits" bits of this APInt.
APInt getHiBits(unsigned numBits) const;
- /// \brief Compute an APInt containing numBits lowbits from this APInt.
+ /// Compute an APInt containing numBits lowbits from this APInt.
///
/// Get an APInt with the same BitWidth as this APInt, just zero mask
/// the high bits.
@@ -577,14 +584,14 @@
/// \returns the low "numBits" bits of this APInt.
APInt getLoBits(unsigned numBits) const;
- /// \brief Return an APInt with exactly one bit set in the result.
+ /// Return an APInt with exactly one bit set in the result.
static APInt getOneBitSet(unsigned numBits, unsigned BitNo) {
APInt Res(numBits, 0);
Res.setBit(BitNo);
return Res;
}
- /// \brief Get a value with a block of bits set.
+ /// Get a value with a block of bits set.
///
/// Constructs an APInt value that has a contiguous range of bits set. The
/// bits from loBit (inclusive) to hiBit (exclusive) will be set. All other
@@ -603,7 +610,7 @@
return Res;
}
- /// \brief Get a value with upper bits starting at loBit set.
+ /// Get a value with upper bits starting at loBit set.
///
/// Constructs an APInt value that has a contiguous range of bits set. The
/// bits from loBit (inclusive) to numBits (exclusive) will be set. All other
@@ -620,7 +627,7 @@
return Res;
}
- /// \brief Get a value with high bits set
+ /// Get a value with high bits set
///
/// Constructs an APInt value that has the top hiBitsSet bits set.
///
@@ -632,7 +639,7 @@
return Res;
}
- /// \brief Get a value with low bits set
+ /// Get a value with low bits set
///
/// Constructs an APInt value that has the bottom loBitsSet bits set.
///
@@ -644,10 +651,10 @@
return Res;
}
- /// \brief Return a value containing V broadcasted over NewLen bits.
+ /// Return a value containing V broadcasted over NewLen bits.
static APInt getSplat(unsigned NewLen, const APInt &V);
- /// \brief Determine if two APInts have the same value, after zero-extending
+ /// Determine if two APInts have the same value, after zero-extending
/// one of them (if needed!) to ensure that the bit-widths match.
static bool isSameValue(const APInt &I1, const APInt &I2) {
if (I1.getBitWidth() == I2.getBitWidth())
@@ -659,7 +666,7 @@
return I1.zext(I2.getBitWidth()) == I2;
}
- /// \brief Overload to compute a hash_code for an APInt value.
+ /// Overload to compute a hash_code for an APInt value.
friend hash_code hash_value(const APInt &Arg);
/// This function returns a pointer to the internal storage of the APInt.
@@ -675,7 +682,7 @@
/// \name Unary Operators
/// @{
- /// \brief Postfix increment operator.
+ /// Postfix increment operator.
///
/// Increments *this by 1.
///
@@ -686,12 +693,12 @@
return API;
}
- /// \brief Prefix increment operator.
+ /// Prefix increment operator.
///
/// \returns *this incremented by one
APInt &operator++();
- /// \brief Postfix decrement operator.
+ /// Postfix decrement operator.
///
/// Decrements *this by 1.
///
@@ -702,12 +709,12 @@
return API;
}
- /// \brief Prefix decrement operator.
+ /// Prefix decrement operator.
///
/// \returns *this decremented by one.
APInt &operator--();
- /// \brief Logical negation operator.
+ /// Logical negation operator.
///
/// Performs logical negation operation on this APInt.
///
@@ -722,7 +729,7 @@
/// \name Assignment Operators
/// @{
- /// \brief Copy assignment operator.
+ /// Copy assignment operator.
///
/// \returns *this after assignment of RHS.
APInt &operator=(const APInt &RHS) {
@@ -737,8 +744,13 @@
return *this;
}
- /// @brief Move assignment operator.
+ /// Move assignment operator.
APInt &operator=(APInt &&that) {
+#ifdef _MSC_VER
+ // The MSVC std::shuffle implementation still does self-assignment.
+ if (this == &that)
+ return *this;
+#endif
assert(this != &that && "Self-move not supported");
if (!isSingleWord())
delete[] U.pVal;
@@ -753,7 +765,7 @@
return *this;
}
- /// \brief Assignment operator.
+ /// Assignment operator.
///
/// The RHS value is assigned to *this. If the significant bits in RHS exceed
/// the bit width, the excess bits are truncated. If the bit width is larger
@@ -771,7 +783,7 @@
return *this;
}
- /// \brief Bitwise AND assignment operator.
+ /// Bitwise AND assignment operator.
///
/// Performs a bitwise AND operation on this APInt and RHS. The result is
/// assigned to *this.
@@ -786,7 +798,7 @@
return *this;
}
- /// \brief Bitwise AND assignment operator.
+ /// Bitwise AND assignment operator.
///
/// Performs a bitwise AND operation on this APInt and RHS. RHS is
/// logically zero-extended or truncated to match the bit-width of
@@ -801,7 +813,7 @@
return *this;
}
- /// \brief Bitwise OR assignment operator.
+ /// Bitwise OR assignment operator.
///
/// Performs a bitwise OR operation on this APInt and RHS. The result is
/// assigned *this;
@@ -816,7 +828,7 @@
return *this;
}
- /// \brief Bitwise OR assignment operator.
+ /// Bitwise OR assignment operator.
///
/// Performs a bitwise OR operation on this APInt and RHS. RHS is
/// logically zero-extended or truncated to match the bit-width of
@@ -831,7 +843,7 @@
return *this;
}
- /// \brief Bitwise XOR assignment operator.
+ /// Bitwise XOR assignment operator.
///
/// Performs a bitwise XOR operation on this APInt and RHS. The result is
/// assigned to *this.
@@ -846,7 +858,7 @@
return *this;
}
- /// \brief Bitwise XOR assignment operator.
+ /// Bitwise XOR assignment operator.
///
/// Performs a bitwise XOR operation on this APInt and RHS. RHS is
/// logically zero-extended or truncated to match the bit-width of
@@ -861,7 +873,7 @@
return *this;
}
- /// \brief Multiplication assignment operator.
+ /// Multiplication assignment operator.
///
/// Multiplies this APInt by RHS and assigns the result to *this.
///
@@ -869,7 +881,7 @@
APInt &operator*=(const APInt &RHS);
APInt &operator*=(uint64_t RHS);
- /// \brief Addition assignment operator.
+ /// Addition assignment operator.
///
/// Adds RHS to *this and assigns the result to *this.
///
@@ -877,7 +889,7 @@
APInt &operator+=(const APInt &RHS);
APInt &operator+=(uint64_t RHS);
- /// \brief Subtraction assignment operator.
+ /// Subtraction assignment operator.
///
/// Subtracts RHS from *this and assigns the result to *this.
///
@@ -885,7 +897,7 @@
APInt &operator-=(const APInt &RHS);
APInt &operator-=(uint64_t RHS);
- /// \brief Left-shift assignment function.
+ /// Left-shift assignment function.
///
/// Shifts *this left by shiftAmt and assigns the result to *this.
///
@@ -903,7 +915,7 @@
return *this;
}
- /// \brief Left-shift assignment function.
+ /// Left-shift assignment function.
///
/// Shifts *this left by shiftAmt and assigns the result to *this.
///
@@ -914,22 +926,22 @@
/// \name Binary Operators
/// @{
- /// \brief Multiplication operator.
+ /// Multiplication operator.
///
/// Multiplies this APInt by RHS and returns the result.
APInt operator*(const APInt &RHS) const;
- /// \brief Left logical shift operator.
+ /// Left logical shift operator.
///
/// Shifts this APInt left by \p Bits and returns the result.
APInt operator<<(unsigned Bits) const { return shl(Bits); }
- /// \brief Left logical shift operator.
+ /// Left logical shift operator.
///
/// Shifts this APInt left by \p Bits and returns the result.
APInt operator<<(const APInt &Bits) const { return shl(Bits); }
- /// \brief Arithmetic right-shift function.
+ /// Arithmetic right-shift function.
///
/// Arithmetic right-shift this APInt by shiftAmt.
APInt ashr(unsigned ShiftAmt) const {
@@ -953,7 +965,7 @@
ashrSlowCase(ShiftAmt);
}
- /// \brief Logical right-shift function.
+ /// Logical right-shift function.
///
/// Logical right-shift this APInt by shiftAmt.
APInt lshr(unsigned shiftAmt) const {
@@ -975,7 +987,7 @@
lshrSlowCase(ShiftAmt);
}
- /// \brief Left-shift function.
+ /// Left-shift function.
///
/// Left-shift this APInt by shiftAmt.
APInt shl(unsigned shiftAmt) const {
@@ -984,13 +996,13 @@
return R;
}
- /// \brief Rotate left by rotateAmt.
+ /// Rotate left by rotateAmt.
APInt rotl(unsigned rotateAmt) const;
- /// \brief Rotate right by rotateAmt.
+ /// Rotate right by rotateAmt.
APInt rotr(unsigned rotateAmt) const;
- /// \brief Arithmetic right-shift function.
+ /// Arithmetic right-shift function.
///
/// Arithmetic right-shift this APInt by shiftAmt.
APInt ashr(const APInt &ShiftAmt) const {
@@ -1002,7 +1014,7 @@
/// Arithmetic right-shift this APInt by shiftAmt in place.
void ashrInPlace(const APInt &shiftAmt);
- /// \brief Logical right-shift function.
+ /// Logical right-shift function.
///
/// Logical right-shift this APInt by shiftAmt.
APInt lshr(const APInt &ShiftAmt) const {
@@ -1014,7 +1026,7 @@
/// Logical right-shift this APInt by ShiftAmt in place.
void lshrInPlace(const APInt &ShiftAmt);
- /// \brief Left-shift function.
+ /// Left-shift function.
///
/// Left-shift this APInt by shiftAmt.
APInt shl(const APInt &ShiftAmt) const {
@@ -1023,28 +1035,31 @@
return R;
}
- /// \brief Rotate left by rotateAmt.
+ /// Rotate left by rotateAmt.
APInt rotl(const APInt &rotateAmt) const;
- /// \brief Rotate right by rotateAmt.
+ /// Rotate right by rotateAmt.
APInt rotr(const APInt &rotateAmt) const;
- /// \brief Unsigned division operation.
+ /// Unsigned division operation.
///
/// Perform an unsigned divide operation on this APInt by RHS. Both this and
/// RHS are treated as unsigned quantities for purposes of this division.
///
- /// \returns a new APInt value containing the division result
+ /// \returns a new APInt value containing the division result, rounded towards
+ /// zero.
APInt udiv(const APInt &RHS) const;
APInt udiv(uint64_t RHS) const;
- /// \brief Signed division function for APInt.
+ /// Signed division function for APInt.
///
/// Signed divide this APInt by APInt RHS.
+ ///
+ /// The result is rounded towards zero.
APInt sdiv(const APInt &RHS) const;
APInt sdiv(int64_t RHS) const;
- /// \brief Unsigned remainder operation.
+ /// Unsigned remainder operation.
///
/// Perform an unsigned remainder operation on this APInt with RHS being the
/// divisor. Both this and RHS are treated as unsigned quantities for purposes
@@ -1056,13 +1071,13 @@
APInt urem(const APInt &RHS) const;
uint64_t urem(uint64_t RHS) const;
- /// \brief Function for signed remainder operation.
+ /// Function for signed remainder operation.
///
/// Signed remainder operation on APInt.
APInt srem(const APInt &RHS) const;
int64_t srem(int64_t RHS) const;
- /// \brief Dual division/remainder interface.
+ /// Dual division/remainder interface.
///
/// Sometimes it is convenient to divide two APInt values and obtain both the
/// quotient and remainder. This function does both operations in the same
@@ -1090,7 +1105,7 @@
APInt sshl_ov(const APInt &Amt, bool &Overflow) const;
APInt ushl_ov(const APInt &Amt, bool &Overflow) const;
- /// \brief Array-indexing support.
+ /// Array-indexing support.
///
/// \returns the bit value at bitPosition
bool operator[](unsigned bitPosition) const {
@@ -1102,7 +1117,7 @@
/// \name Comparison Operators
/// @{
- /// \brief Equality operator.
+ /// Equality operator.
///
/// Compares this APInt with RHS for the validity of the equality
/// relationship.
@@ -1113,7 +1128,7 @@
return EqualSlowCase(RHS);
}
- /// \brief Equality operator.
+ /// Equality operator.
///
/// Compares this APInt with a uint64_t for the validity of the equality
/// relationship.
@@ -1123,7 +1138,7 @@
return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() == Val;
}
- /// \brief Equality comparison.
+ /// Equality comparison.
///
/// Compares this APInt with RHS for the validity of the equality
/// relationship.
@@ -1131,7 +1146,7 @@
/// \returns true if *this == Val
bool eq(const APInt &RHS) const { return (*this) == RHS; }
- /// \brief Inequality operator.
+ /// Inequality operator.
///
/// Compares this APInt with RHS for the validity of the inequality
/// relationship.
@@ -1139,7 +1154,7 @@
/// \returns true if *this != Val
bool operator!=(const APInt &RHS) const { return !((*this) == RHS); }
- /// \brief Inequality operator.
+ /// Inequality operator.
///
/// Compares this APInt with a uint64_t for the validity of the inequality
/// relationship.
@@ -1147,7 +1162,7 @@
/// \returns true if *this != Val
bool operator!=(uint64_t Val) const { return !((*this) == Val); }
- /// \brief Inequality comparison
+ /// Inequality comparison
///
/// Compares this APInt with RHS for the validity of the inequality
/// relationship.
@@ -1155,7 +1170,7 @@
/// \returns true if *this != Val
bool ne(const APInt &RHS) const { return !((*this) == RHS); }
- /// \brief Unsigned less than comparison
+ /// Unsigned less than comparison
///
/// Regards both *this and RHS as unsigned quantities and compares them for
/// the validity of the less-than relationship.
@@ -1163,7 +1178,7 @@
/// \returns true if *this < RHS when both are considered unsigned.
bool ult(const APInt &RHS) const { return compare(RHS) < 0; }
- /// \brief Unsigned less than comparison
+ /// Unsigned less than comparison
///
/// Regards both *this as an unsigned quantity and compares it with RHS for
/// the validity of the less-than relationship.
@@ -1174,7 +1189,7 @@
return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() < RHS;
}
- /// \brief Signed less than comparison
+ /// Signed less than comparison
///
/// Regards both *this and RHS as signed quantities and compares them for
/// validity of the less-than relationship.
@@ -1182,7 +1197,7 @@
/// \returns true if *this < RHS when both are considered signed.
bool slt(const APInt &RHS) const { return compareSigned(RHS) < 0; }
- /// \brief Signed less than comparison
+ /// Signed less than comparison
///
/// Regards both *this as a signed quantity and compares it with RHS for
/// the validity of the less-than relationship.
@@ -1193,7 +1208,7 @@
: getSExtValue() < RHS;
}
- /// \brief Unsigned less or equal comparison
+ /// Unsigned less or equal comparison
///
/// Regards both *this and RHS as unsigned quantities and compares them for
/// validity of the less-or-equal relationship.
@@ -1201,7 +1216,7 @@
/// \returns true if *this <= RHS when both are considered unsigned.
bool ule(const APInt &RHS) const { return compare(RHS) <= 0; }
- /// \brief Unsigned less or equal comparison
+ /// Unsigned less or equal comparison
///
/// Regards both *this as an unsigned quantity and compares it with RHS for
/// the validity of the less-or-equal relationship.
@@ -1209,7 +1224,7 @@
/// \returns true if *this <= RHS when considered unsigned.
bool ule(uint64_t RHS) const { return !ugt(RHS); }
- /// \brief Signed less or equal comparison
+ /// Signed less or equal comparison
///
/// Regards both *this and RHS as signed quantities and compares them for
/// validity of the less-or-equal relationship.
@@ -1217,7 +1232,7 @@
/// \returns true if *this <= RHS when both are considered signed.
bool sle(const APInt &RHS) const { return compareSigned(RHS) <= 0; }
- /// \brief Signed less or equal comparison
+ /// Signed less or equal comparison
///
/// Regards both *this as a signed quantity and compares it with RHS for the
/// validity of the less-or-equal relationship.
@@ -1225,7 +1240,7 @@
/// \returns true if *this <= RHS when considered signed.
bool sle(uint64_t RHS) const { return !sgt(RHS); }
- /// \brief Unsigned greather than comparison
+ /// Unsigned greather than comparison
///
/// Regards both *this and RHS as unsigned quantities and compares them for
/// the validity of the greater-than relationship.
@@ -1233,7 +1248,7 @@
/// \returns true if *this > RHS when both are considered unsigned.
bool ugt(const APInt &RHS) const { return !ule(RHS); }
- /// \brief Unsigned greater than comparison
+ /// Unsigned greater than comparison
///
/// Regards both *this as an unsigned quantity and compares it with RHS for
/// the validity of the greater-than relationship.
@@ -1244,7 +1259,7 @@
return (!isSingleWord() && getActiveBits() > 64) || getZExtValue() > RHS;
}
- /// \brief Signed greather than comparison
+ /// Signed greather than comparison
///
/// Regards both *this and RHS as signed quantities and compares them for the
/// validity of the greater-than relationship.
@@ -1252,7 +1267,7 @@
/// \returns true if *this > RHS when both are considered signed.
bool sgt(const APInt &RHS) const { return !sle(RHS); }
- /// \brief Signed greater than comparison
+ /// Signed greater than comparison
///
/// Regards both *this as a signed quantity and compares it with RHS for
/// the validity of the greater-than relationship.
@@ -1263,7 +1278,7 @@
: getSExtValue() > RHS;
}
- /// \brief Unsigned greater or equal comparison
+ /// Unsigned greater or equal comparison
///
/// Regards both *this and RHS as unsigned quantities and compares them for
/// validity of the greater-or-equal relationship.
@@ -1271,7 +1286,7 @@
/// \returns true if *this >= RHS when both are considered unsigned.
bool uge(const APInt &RHS) const { return !ult(RHS); }
- /// \brief Unsigned greater or equal comparison
+ /// Unsigned greater or equal comparison
///
/// Regards both *this as an unsigned quantity and compares it with RHS for
/// the validity of the greater-or-equal relationship.
@@ -1279,7 +1294,7 @@
/// \returns true if *this >= RHS when considered unsigned.
bool uge(uint64_t RHS) const { return !ult(RHS); }
- /// \brief Signed greater or equal comparison
+ /// Signed greater or equal comparison
///
/// Regards both *this and RHS as signed quantities and compares them for
/// validity of the greater-or-equal relationship.
@@ -1287,7 +1302,7 @@
/// \returns true if *this >= RHS when both are considered signed.
bool sge(const APInt &RHS) const { return !slt(RHS); }
- /// \brief Signed greater or equal comparison
+ /// Signed greater or equal comparison
///
/// Regards both *this as a signed quantity and compares it with RHS for
/// the validity of the greater-or-equal relationship.
@@ -1316,13 +1331,13 @@
/// \name Resizing Operators
/// @{
- /// \brief Truncate to new width.
+ /// Truncate to new width.
///
/// Truncate the APInt to a specified width. It is an error to specify a width
/// that is greater than or equal to the current width.
APInt trunc(unsigned width) const;
- /// \brief Sign extend to a new width.
+ /// Sign extend to a new width.
///
/// This operation sign extends the APInt to a new width. If the high order
/// bit is set, the fill on the left will be done with 1 bits, otherwise zero.
@@ -1330,32 +1345,32 @@
/// current width.
APInt sext(unsigned width) const;
- /// \brief Zero extend to a new width.
+ /// Zero extend to a new width.
///
/// This operation zero extends the APInt to a new width. The high order bits
/// are filled with 0 bits. It is an error to specify a width that is less
/// than or equal to the current width.
APInt zext(unsigned width) const;
- /// \brief Sign extend or truncate to width
+ /// Sign extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is sign
/// extended, truncated, or left alone to make it that width.
APInt sextOrTrunc(unsigned width) const;
- /// \brief Zero extend or truncate to width
+ /// Zero extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is zero
/// extended, truncated, or left alone to make it that width.
APInt zextOrTrunc(unsigned width) const;
- /// \brief Sign extend or truncate to width
+ /// Sign extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is sign
/// extended, or left alone to make it that width.
APInt sextOrSelf(unsigned width) const;
- /// \brief Zero extend or truncate to width
+ /// Zero extend or truncate to width
///
/// Make this APInt have the bit width given by \p width. The value is zero
/// extended, or left alone to make it that width.
@@ -1365,7 +1380,7 @@
/// \name Bit Manipulation Operators
/// @{
- /// \brief Set every bit to 1.
+ /// Set every bit to 1.
void setAllBits() {
if (isSingleWord())
U.VAL = WORD_MAX;
@@ -1376,7 +1391,7 @@
clearUnusedBits();
}
- /// \brief Set a given bit to 1.
+ /// Set a given bit to 1.
///
/// Set the given bit to 1 whose position is given as "bitPosition".
void setBit(unsigned BitPosition) {
@@ -1427,7 +1442,7 @@
return setBits(BitWidth - hiBits, BitWidth);
}
- /// \brief Set every bit to 0.
+ /// Set every bit to 0.
void clearAllBits() {
if (isSingleWord())
U.VAL = 0;
@@ -1435,7 +1450,7 @@
memset(U.pVal, 0, getNumWords() * APINT_WORD_SIZE);
}
- /// \brief Set a given bit to 0.
+ /// Set a given bit to 0.
///
/// Set the given bit to 0 whose position is given as "bitPosition".
void clearBit(unsigned BitPosition) {
@@ -1452,7 +1467,7 @@
clearBit(BitWidth - 1);
}
- /// \brief Toggle every bit to its opposite value.
+ /// Toggle every bit to its opposite value.
void flipAllBits() {
if (isSingleWord()) {
U.VAL ^= WORD_MAX;
@@ -1462,7 +1477,7 @@
}
}
- /// \brief Toggles a given bit to its opposite value.
+ /// Toggles a given bit to its opposite value.
///
/// Toggle a given bit to its opposite value whose position is given
/// as "bitPosition".
@@ -1484,17 +1499,17 @@
/// \name Value Characterization Functions
/// @{
- /// \brief Return the number of bits in the APInt.
+ /// Return the number of bits in the APInt.
unsigned getBitWidth() const { return BitWidth; }
- /// \brief Get the number of words.
+ /// Get the number of words.
///
/// Here one word's bitwidth equals to that of uint64_t.
///
/// \returns the number of words to hold the integer value of this APInt.
unsigned getNumWords() const { return getNumWords(BitWidth); }
- /// \brief Get the number of words.
+ /// Get the number of words.
///
/// *NOTE* Here one word's bitwidth equals to that of uint64_t.
///
@@ -1504,14 +1519,14 @@
return ((uint64_t)BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD;
}
- /// \brief Compute the number of active bits in the value
+ /// Compute the number of active bits in the value
///
/// This function returns the number of active bits which is defined as the
/// bit width minus the number of leading zeros. This is used in several
/// computations to see how "wide" the value is.
unsigned getActiveBits() const { return BitWidth - countLeadingZeros(); }
- /// \brief Compute the number of active words in the value of this APInt.
+ /// Compute the number of active words in the value of this APInt.
///
/// This is used in conjunction with getActiveData to extract the raw value of
/// the APInt.
@@ -1520,7 +1535,7 @@
return numActiveBits ? whichWord(numActiveBits - 1) + 1 : 1;
}
- /// \brief Get the minimum bit size for this signed APInt
+ /// Get the minimum bit size for this signed APInt
///
/// Computes the minimum bit width for this APInt while considering it to be a
/// signed (and probably negative) value. If the value is not negative, this
@@ -1534,7 +1549,7 @@
return getActiveBits() + 1;
}
- /// \brief Get zero extended value
+ /// Get zero extended value
///
/// This method attempts to return the value of this APInt as a zero extended
/// uint64_t. The bitwidth must be <= 64 or the value must fit within a
@@ -1546,7 +1561,7 @@
return U.pVal[0];
}
- /// \brief Get sign extended value
+ /// Get sign extended value
///
/// This method attempts to return the value of this APInt as a sign extended
/// int64_t. The bit width must be <= 64 or the value must fit within an
@@ -1558,13 +1573,13 @@
return int64_t(U.pVal[0]);
}
- /// \brief Get bits required for string value.
+ /// Get bits required for string value.
///
/// This method determines how many bits are required to hold the APInt
/// equivalent of the string given by \p str.
static unsigned getBitsNeeded(StringRef str, uint8_t radix);
- /// \brief The APInt version of the countLeadingZeros functions in
+ /// The APInt version of the countLeadingZeros functions in
/// MathExtras.h.
///
/// It counts the number of zeros from the most significant bit to the first
@@ -1580,7 +1595,7 @@
return countLeadingZerosSlowCase();
}
- /// \brief Count the number of leading one bits.
+ /// Count the number of leading one bits.
///
/// This function is an APInt version of the countLeadingOnes
/// functions in MathExtras.h. It counts the number of ones from the most
@@ -1600,7 +1615,7 @@
return isNegative() ? countLeadingOnes() : countLeadingZeros();
}
- /// \brief Count the number of trailing zero bits.
+ /// Count the number of trailing zero bits.
///
/// This function is an APInt version of the countTrailingZeros
/// functions in MathExtras.h. It counts the number of zeros from the least
@@ -1614,7 +1629,7 @@
return countTrailingZerosSlowCase();
}
- /// \brief Count the number of trailing one bits.
+ /// Count the number of trailing one bits.
///
/// This function is an APInt version of the countTrailingOnes
/// functions in MathExtras.h. It counts the number of ones from the least
@@ -1628,7 +1643,7 @@
return countTrailingOnesSlowCase();
}
- /// \brief Count the number of bits set.
+ /// Count the number of bits set.
///
/// This function is an APInt version of the countPopulation functions
/// in MathExtras.h. It counts the number of 1 bits in the APInt value.
@@ -1662,7 +1677,7 @@
toString(Str, Radix, true, false);
}
- /// \brief Return the APInt as a std::string.
+ /// Return the APInt as a std::string.
///
/// Note that this is an inefficient method. It is better to pass in a
/// SmallVector/SmallString to the methods above to avoid thrashing the heap
@@ -1676,16 +1691,16 @@
/// Value.
APInt reverseBits() const;
- /// \brief Converts this APInt to a double value.
+ /// Converts this APInt to a double value.
double roundToDouble(bool isSigned) const;
- /// \brief Converts this unsigned APInt to a double value.
+ /// Converts this unsigned APInt to a double value.
double roundToDouble() const { return roundToDouble(false); }
- /// \brief Converts this signed APInt to a double value.
+ /// Converts this signed APInt to a double value.
double signedRoundToDouble() const { return roundToDouble(true); }
- /// \brief Converts APInt bits to a double
+ /// Converts APInt bits to a double
///
/// The conversion does not do a translation from integer to double, it just
/// re-interprets the bits as a double. Note that it is valid to do this on
@@ -1694,7 +1709,7 @@
return BitsToDouble(getWord(0));
}
- /// \brief Converts APInt bits to a double
+ /// Converts APInt bits to a double
///
/// The conversion does not do a translation from integer to float, it just
/// re-interprets the bits as a float. Note that it is valid to do this on
@@ -1703,7 +1718,7 @@
return BitsToFloat(getWord(0));
}
- /// \brief Converts a double to APInt bits.
+ /// Converts a double to APInt bits.
///
/// The conversion does not do a translation from double to integer, it just
/// re-interprets the bits of the double.
@@ -1711,7 +1726,7 @@
return APInt(sizeof(double) * CHAR_BIT, DoubleToBits(V));
}
- /// \brief Converts a float to APInt bits.
+ /// Converts a float to APInt bits.
///
/// The conversion does not do a translation from float to integer, it just
/// re-interprets the bits of the float.
@@ -1770,10 +1785,10 @@
return logBase2();
}
- /// \brief Compute the square root
+ /// Compute the square root
APInt sqrt() const;
- /// \brief Get the absolute value;
+ /// Get the absolute value;
///
/// If *this is < 0 then return -(*this), otherwise *this;
APInt abs() const {
@@ -1924,7 +1939,7 @@
/// Set the least significant BITS and clear the rest.
static void tcSetLeastSignificantBits(WordType *, unsigned, unsigned bits);
- /// \brief debug method
+ /// debug method
void dump() const;
/// @}
@@ -1947,7 +1962,7 @@
inline bool operator!=(uint64_t V1, const APInt &V2) { return V2 != V1; }
-/// \brief Unary bitwise complement operator.
+/// Unary bitwise complement operator.
///
/// \returns an APInt that is the bitwise complement of \p v.
inline APInt operator~(APInt v) {
@@ -2080,27 +2095,27 @@
namespace APIntOps {
-/// \brief Determine the smaller of two APInts considered to be signed.
+/// Determine the smaller of two APInts considered to be signed.
inline const APInt &smin(const APInt &A, const APInt &B) {
return A.slt(B) ? A : B;
}
-/// \brief Determine the larger of two APInts considered to be signed.
+/// Determine the larger of two APInts considered to be signed.
inline const APInt &smax(const APInt &A, const APInt &B) {
return A.sgt(B) ? A : B;
}
-/// \brief Determine the smaller of two APInts considered to be signed.
+/// Determine the smaller of two APInts considered to be signed.
inline const APInt &umin(const APInt &A, const APInt &B) {
return A.ult(B) ? A : B;
}
-/// \brief Determine the larger of two APInts considered to be unsigned.
+/// Determine the larger of two APInts considered to be unsigned.
inline const APInt &umax(const APInt &A, const APInt &B) {
return A.ugt(B) ? A : B;
}
-/// \brief Compute GCD of two unsigned APInt values.
+/// Compute GCD of two unsigned APInt values.
///
/// This function returns the greatest common divisor of the two APInt values
/// using Stein's algorithm.
@@ -2108,44 +2123,85 @@
/// \returns the greatest common divisor of A and B.
APInt GreatestCommonDivisor(APInt A, APInt B);
-/// \brief Converts the given APInt to a double value.
+/// Converts the given APInt to a double value.
///
/// Treats the APInt as an unsigned value for conversion purposes.
inline double RoundAPIntToDouble(const APInt &APIVal) {
return APIVal.roundToDouble();
}
-/// \brief Converts the given APInt to a double value.
+/// Converts the given APInt to a double value.
///
/// Treats the APInt as a signed value for conversion purposes.
inline double RoundSignedAPIntToDouble(const APInt &APIVal) {
return APIVal.signedRoundToDouble();
}
-/// \brief Converts the given APInt to a float vlalue.
+/// Converts the given APInt to a float vlalue.
inline float RoundAPIntToFloat(const APInt &APIVal) {
return float(RoundAPIntToDouble(APIVal));
}
-/// \brief Converts the given APInt to a float value.
+/// Converts the given APInt to a float value.
///
/// Treast the APInt as a signed value for conversion purposes.
inline float RoundSignedAPIntToFloat(const APInt &APIVal) {
return float(APIVal.signedRoundToDouble());
}
-/// \brief Converts the given double value into a APInt.
+/// Converts the given double value into a APInt.
///
/// This function convert a double value to an APInt value.
APInt RoundDoubleToAPInt(double Double, unsigned width);
-/// \brief Converts a float value into a APInt.
+/// Converts a float value into a APInt.
///
/// Converts a float value into an APInt value.
inline APInt RoundFloatToAPInt(float Float, unsigned width) {
return RoundDoubleToAPInt(double(Float), width);
}
+/// Return A unsign-divided by B, rounded by the given rounding mode.
+APInt RoundingUDiv(const APInt &A, const APInt &B, APInt::Rounding RM);
+
+/// Return A sign-divided by B, rounded by the given rounding mode.
+APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM);
+
+/// Let q(n) = An^2 + Bn + C, and BW = bit width of the value range
+/// (e.g. 32 for i32).
+/// This function finds the smallest number n, such that
+/// (a) n >= 0 and q(n) = 0, or
+/// (b) n >= 1 and q(n-1) and q(n), when evaluated in the set of all
+/// integers, belong to two different intervals [Rk, Rk+R),
+/// where R = 2^BW, and k is an integer.
+/// The idea here is to find when q(n) "overflows" 2^BW, while at the
+/// same time "allowing" subtraction. In unsigned modulo arithmetic a
+/// subtraction (treated as addition of negated numbers) would always
+/// count as an overflow, but here we want to allow values to decrease
+/// and increase as long as they are within the same interval.
+/// Specifically, adding of two negative numbers should not cause an
+/// overflow (as long as the magnitude does not exceed the bith width).
+/// On the other hand, given a positive number, adding a negative
+/// number to it can give a negative result, which would cause the
+/// value to go from [-2^BW, 0) to [0, 2^BW). In that sense, zero is
+/// treated as a special case of an overflow.
+///
+/// This function returns None if after finding k that minimizes the
+/// positive solution to q(n) = kR, both solutions are contained between
+/// two consecutive integers.
+///
+/// There are cases where q(n) > T, and q(n+1) < T (assuming evaluation
+/// in arithmetic modulo 2^BW, and treating the values as signed) by the
+/// virtue of *signed* overflow. This function will *not* find such an n,
+/// however it may find a value of n satisfying the inequalities due to
+/// an *unsigned* overflow (if the values are treated as unsigned).
+/// To find a solution for a signed overflow, treat it as a problem of
+/// finding an unsigned overflow with a range with of BW-1.
+///
+/// The returned value may have a different bit width from the input
+/// coefficients.
+Optional<APInt> SolveQuadraticEquationWrap(APInt A, APInt B, APInt C,
+ unsigned RangeWidth);
} // End of APIntOps namespace
// See friend declaration above. This additional declaration is required in
diff --git a/linux-x64/clang/include/llvm/ADT/APSInt.h b/linux-x64/clang/include/llvm/ADT/APSInt.h
index dabbf33..7ee2c4c 100644
--- a/linux-x64/clang/include/llvm/ADT/APSInt.h
+++ b/linux-x64/clang/include/llvm/ADT/APSInt.h
@@ -72,7 +72,7 @@
}
using APInt::toString;
- /// \brief Get the correctly-extended \c int64_t value.
+ /// Get the correctly-extended \c int64_t value.
int64_t getExtValue() const {
assert(getMinSignedBits() <= 64 && "Too many bits for int64_t");
return isSigned() ? getSExtValue() : getZExtValue();
@@ -279,13 +279,13 @@
: APInt::getSignedMinValue(numBits), Unsigned);
}
- /// \brief Determine if two APSInts have the same value, zero- or
+ /// Determine if two APSInts have the same value, zero- or
/// sign-extending as needed.
static bool isSameValue(const APSInt &I1, const APSInt &I2) {
return !compareValues(I1, I2);
}
- /// \brief Compare underlying values of two numbers.
+ /// Compare underlying values of two numbers.
static int compareValues(const APSInt &I1, const APSInt &I2) {
if (I1.getBitWidth() == I2.getBitWidth() && I1.isSigned() == I2.isSigned())
return I1.IsUnsigned ? I1.compare(I2) : I1.compareSigned(I2);
diff --git a/linux-x64/clang/include/llvm/ADT/Any.h b/linux-x64/clang/include/llvm/ADT/Any.h
new file mode 100644
index 0000000..c64c399
--- /dev/null
+++ b/linux-x64/clang/include/llvm/ADT/Any.h
@@ -0,0 +1,150 @@
+//===- Any.h - Generic type erased holder of any type -----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides Any, a non-template class modeled in the spirit of
+// std::any. The idea is to provide a type-safe replacement for C's void*.
+// It can hold a value of any copy-constructible copy-assignable type
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ADT_ANY_H
+#define LLVM_ADT_ANY_H
+
+#include "llvm/ADT/STLExtras.h"
+
+#include <cassert>
+#include <memory>
+#include <type_traits>
+
+namespace llvm {
+
+class Any {
+ template <typename T> struct TypeId { static const char Id; };
+
+ struct StorageBase {
+ virtual ~StorageBase() = default;
+ virtual std::unique_ptr<StorageBase> clone() const = 0;
+ virtual const void *id() const = 0;
+ };
+
+ template <typename T> struct StorageImpl : public StorageBase {
+ explicit StorageImpl(const T &Value) : Value(Value) {}
+
+ explicit StorageImpl(T &&Value) : Value(std::move(Value)) {}
+
+ std::unique_ptr<StorageBase> clone() const override {
+ return llvm::make_unique<StorageImpl<T>>(Value);
+ }
+
+ const void *id() const override { return &TypeId<T>::Id; }
+
+ T Value;
+
+ private:
+ StorageImpl &operator=(const StorageImpl &Other) = delete;
+ StorageImpl(const StorageImpl &Other) = delete;
+ };
+
+public:
+ Any() = default;
+
+ Any(const Any &Other)
+ : Storage(Other.Storage ? Other.Storage->clone() : nullptr) {}
+
+ // When T is Any or T is not copy-constructible we need to explicitly disable
+ // the forwarding constructor so that the copy constructor gets selected
+ // instead.
+ template <
+ typename T,
+ typename std::enable_if<
+ llvm::conjunction<
+ llvm::negation<std::is_same<typename std::decay<T>::type, Any>>,
+ std::is_copy_constructible<typename std::decay<T>::type>>::value,
+ int>::type = 0>
+ Any(T &&Value) {
+ using U = typename std::decay<T>::type;
+ Storage = llvm::make_unique<StorageImpl<U>>(std::forward<T>(Value));
+ }
+
+ Any(Any &&Other) : Storage(std::move(Other.Storage)) {}
+
+ Any &swap(Any &Other) {
+ std::swap(Storage, Other.Storage);
+ return *this;
+ }
+
+ Any &operator=(Any Other) {
+ Storage = std::move(Other.Storage);
+ return *this;
+ }
+
+ bool hasValue() const { return !!Storage; }
+
+ void reset() { Storage.reset(); }
+
+private:
+ template <class T> friend T any_cast(const Any &Value);
+ template <class T> friend T any_cast(Any &Value);
+ template <class T> friend T any_cast(Any &&Value);
+ template <class T> friend const T *any_cast(const Any *Value);
+ template <class T> friend T *any_cast(Any *Value);
+ template <typename T> friend bool any_isa(const Any &Value);
+
+ std::unique_ptr<StorageBase> Storage;
+};
+
+template <typename T> const char Any::TypeId<T>::Id = 0;
+
+
+template <typename T> bool any_isa(const Any &Value) {
+ if (!Value.Storage)
+ return false;
+ using U =
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+ return Value.Storage->id() == &Any::TypeId<U>::Id;
+}
+
+template <class T> T any_cast(const Any &Value) {
+ using U =
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+ return static_cast<T>(*any_cast<U>(&Value));
+}
+
+template <class T> T any_cast(Any &Value) {
+ using U =
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+ return static_cast<T>(*any_cast<U>(&Value));
+}
+
+template <class T> T any_cast(Any &&Value) {
+ using U =
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+ return static_cast<T>(std::move(*any_cast<U>(&Value)));
+}
+
+template <class T> const T *any_cast(const Any *Value) {
+ using U =
+ typename std::remove_cv<typename std::remove_reference<T>::type>::type;
+ assert(Value && any_isa<T>(*Value) && "Bad any cast!");
+ if (!Value || !any_isa<U>(*Value))
+ return nullptr;
+ return &static_cast<Any::StorageImpl<U> &>(*Value->Storage).Value;
+}
+
+template <class T> T *any_cast(Any *Value) {
+ using U = typename std::decay<T>::type;
+ assert(Value && any_isa<U>(*Value) && "Bad any cast!");
+ if (!Value || !any_isa<U>(*Value))
+ return nullptr;
+ return &static_cast<Any::StorageImpl<U> &>(*Value->Storage).Value;
+}
+
+} // end namespace llvm
+
+#endif // LLVM_ADT_ANY_H
diff --git a/linux-x64/clang/include/llvm/ADT/ArrayRef.h b/linux-x64/clang/include/llvm/ADT/ArrayRef.h
index 5f7a769..9cb25b0 100644
--- a/linux-x64/clang/include/llvm/ADT/ArrayRef.h
+++ b/linux-x64/clang/include/llvm/ADT/ArrayRef.h
@@ -184,51 +184,51 @@
/// slice(n) - Chop off the first N elements of the array.
ArrayRef<T> slice(size_t N) const { return slice(N, size() - N); }
- /// \brief Drop the first \p N elements of the array.
+ /// Drop the first \p N elements of the array.
ArrayRef<T> drop_front(size_t N = 1) const {
assert(size() >= N && "Dropping more elements than exist");
return slice(N, size() - N);
}
- /// \brief Drop the last \p N elements of the array.
+ /// Drop the last \p N elements of the array.
ArrayRef<T> drop_back(size_t N = 1) const {
assert(size() >= N && "Dropping more elements than exist");
return slice(0, size() - N);
}
- /// \brief Return a copy of *this with the first N elements satisfying the
+ /// Return a copy of *this with the first N elements satisfying the
/// given predicate removed.
template <class PredicateT> ArrayRef<T> drop_while(PredicateT Pred) const {
return ArrayRef<T>(find_if_not(*this, Pred), end());
}
- /// \brief Return a copy of *this with the first N elements not satisfying
+ /// Return a copy of *this with the first N elements not satisfying
/// the given predicate removed.
template <class PredicateT> ArrayRef<T> drop_until(PredicateT Pred) const {
return ArrayRef<T>(find_if(*this, Pred), end());
}
- /// \brief Return a copy of *this with only the first \p N elements.
+ /// Return a copy of *this with only the first \p N elements.
ArrayRef<T> take_front(size_t N = 1) const {
if (N >= size())
return *this;
return drop_back(size() - N);
}
- /// \brief Return a copy of *this with only the last \p N elements.
+ /// Return a copy of *this with only the last \p N elements.
ArrayRef<T> take_back(size_t N = 1) const {
if (N >= size())
return *this;
return drop_front(size() - N);
}
- /// \brief Return the first N elements of this Array that satisfy the given
+ /// Return the first N elements of this Array that satisfy the given
/// predicate.
template <class PredicateT> ArrayRef<T> take_while(PredicateT Pred) const {
return ArrayRef<T>(begin(), find_if_not(*this, Pred));
}
- /// \brief Return the first N elements of this Array that don't satisfy the
+ /// Return the first N elements of this Array that don't satisfy the
/// given predicate.
template <class PredicateT> ArrayRef<T> take_until(PredicateT Pred) const {
return ArrayRef<T>(begin(), find_if(*this, Pred));
@@ -358,7 +358,7 @@
return slice(N, this->size() - N);
}
- /// \brief Drop the first \p N elements of the array.
+ /// Drop the first \p N elements of the array.
MutableArrayRef<T> drop_front(size_t N = 1) const {
assert(this->size() >= N && "Dropping more elements than exist");
return slice(N, this->size() - N);
@@ -369,42 +369,42 @@
return slice(0, this->size() - N);
}
- /// \brief Return a copy of *this with the first N elements satisfying the
+ /// Return a copy of *this with the first N elements satisfying the
/// given predicate removed.
template <class PredicateT>
MutableArrayRef<T> drop_while(PredicateT Pred) const {
return MutableArrayRef<T>(find_if_not(*this, Pred), end());
}
- /// \brief Return a copy of *this with the first N elements not satisfying
+ /// Return a copy of *this with the first N elements not satisfying
/// the given predicate removed.
template <class PredicateT>
MutableArrayRef<T> drop_until(PredicateT Pred) const {
return MutableArrayRef<T>(find_if(*this, Pred), end());
}
- /// \brief Return a copy of *this with only the first \p N elements.
+ /// Return a copy of *this with only the first \p N elements.
MutableArrayRef<T> take_front(size_t N = 1) const {
if (N >= this->size())
return *this;
return drop_back(this->size() - N);
}
- /// \brief Return a copy of *this with only the last \p N elements.
+ /// Return a copy of *this with only the last \p N elements.
MutableArrayRef<T> take_back(size_t N = 1) const {
if (N >= this->size())
return *this;
return drop_front(this->size() - N);
}
- /// \brief Return the first N elements of this Array that satisfy the given
+ /// Return the first N elements of this Array that satisfy the given
/// predicate.
template <class PredicateT>
MutableArrayRef<T> take_while(PredicateT Pred) const {
return MutableArrayRef<T>(begin(), find_if_not(*this, Pred));
}
- /// \brief Return the first N elements of this Array that don't satisfy the
+ /// Return the first N elements of this Array that don't satisfy the
/// given predicate.
template <class PredicateT>
MutableArrayRef<T> take_until(PredicateT Pred) const {
diff --git a/linux-x64/clang/include/llvm/ADT/BitVector.h b/linux-x64/clang/include/llvm/ADT/BitVector.h
index 124c2a8..438c7d8 100644
--- a/linux-x64/clang/include/llvm/ADT/BitVector.h
+++ b/linux-x64/clang/include/llvm/ADT/BitVector.h
@@ -779,7 +779,7 @@
}
private:
- /// \brief Perform a logical left shift of \p Count words by moving everything
+ /// Perform a logical left shift of \p Count words by moving everything
/// \p Count words to the right in memory.
///
/// While confusing, words are stored from least significant at Bits[0] to
@@ -810,7 +810,7 @@
clear_unused_bits();
}
- /// \brief Perform a logical right shift of \p Count words by moving those
+ /// Perform a logical right shift of \p Count words by moving those
/// words to the left in memory. See wordShl for more information.
///
void wordShr(uint32_t Count) {
diff --git a/linux-x64/clang/include/llvm/ADT/CachedHashString.h b/linux-x64/clang/include/llvm/ADT/CachedHashString.h
index a56a621..d8f0e7a 100644
--- a/linux-x64/clang/include/llvm/ADT/CachedHashString.h
+++ b/linux-x64/clang/include/llvm/ADT/CachedHashString.h
@@ -43,6 +43,7 @@
}
StringRef val() const { return StringRef(P, Size); }
+ const char *data() const { return P; }
uint32_t size() const { return Size; }
uint32_t hash() const { return Hash; }
};
diff --git a/linux-x64/clang/include/llvm/ADT/DenseMap.h b/linux-x64/clang/include/llvm/ADT/DenseMap.h
index ba60b79..380f1db 100644
--- a/linux-x64/clang/include/llvm/ADT/DenseMap.h
+++ b/linux-x64/clang/include/llvm/ADT/DenseMap.h
@@ -393,7 +393,7 @@
setNumTombstones(other.getNumTombstones());
if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
- memcpy(getBuckets(), other.getBuckets(),
+ memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
getNumBuckets() * sizeof(BucketT));
else
for (size_t i = 0; i < getNumBuckets(); ++i) {
diff --git a/linux-x64/clang/include/llvm/ADT/DenseMapInfo.h b/linux-x64/clang/include/llvm/ADT/DenseMapInfo.h
index a96904c..5d12b42 100644
--- a/linux-x64/clang/include/llvm/ADT/DenseMapInfo.h
+++ b/linux-x64/clang/include/llvm/ADT/DenseMapInfo.h
@@ -262,6 +262,13 @@
}
};
+template <> struct DenseMapInfo<hash_code> {
+ static inline hash_code getEmptyKey() { return hash_code(-1); }
+ static inline hash_code getTombstoneKey() { return hash_code(-2); }
+ static unsigned getHashValue(hash_code val) { return val; }
+ static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
+};
+
} // end namespace llvm
#endif // LLVM_ADT_DENSEMAPINFO_H
diff --git a/linux-x64/clang/include/llvm/ADT/DenseSet.h b/linux-x64/clang/include/llvm/ADT/DenseSet.h
index 7e5171c..b495e25 100644
--- a/linux-x64/clang/include/llvm/ADT/DenseSet.h
+++ b/linux-x64/clang/include/llvm/ADT/DenseSet.h
@@ -17,7 +17,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/type_traits.h"
-#include <algorithm>
+#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <iterator>
diff --git a/linux-x64/clang/include/llvm/ADT/DepthFirstIterator.h b/linux-x64/clang/include/llvm/ADT/DepthFirstIterator.h
index e964d7f..1f3766d 100644
--- a/linux-x64/clang/include/llvm/ADT/DepthFirstIterator.h
+++ b/linux-x64/clang/include/llvm/ADT/DepthFirstIterator.h
@@ -177,7 +177,7 @@
return *this;
}
- /// \brief Skips all children of the current node and traverses to next node
+ /// Skips all children of the current node and traverses to next node
///
/// Note: This function takes care of incrementing the iterator. If you
/// always increment and call this function, you risk walking off the end.
diff --git a/linux-x64/clang/include/llvm/ADT/EpochTracker.h b/linux-x64/clang/include/llvm/ADT/EpochTracker.h
index db39ba4..49ef192 100644
--- a/linux-x64/clang/include/llvm/ADT/EpochTracker.h
+++ b/linux-x64/clang/include/llvm/ADT/EpochTracker.h
@@ -17,7 +17,6 @@
#define LLVM_ADT_EPOCH_TRACKER_H
#include "llvm/Config/abi-breaking.h"
-#include "llvm/Config/llvm-config.h"
#include <cstdint>
@@ -25,7 +24,7 @@
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
-/// \brief A base class for data structure classes wishing to make iterators
+/// A base class for data structure classes wishing to make iterators
/// ("handles") pointing into themselves fail-fast. When building without
/// asserts, this class is empty and does nothing.
///
@@ -40,15 +39,15 @@
public:
DebugEpochBase() : Epoch(0) {}
- /// \brief Calling incrementEpoch invalidates all handles pointing into the
+ /// Calling incrementEpoch invalidates all handles pointing into the
/// calling instance.
void incrementEpoch() { ++Epoch; }
- /// \brief The destructor calls incrementEpoch to make use-after-free bugs
+ /// The destructor calls incrementEpoch to make use-after-free bugs
/// more likely to crash deterministically.
~DebugEpochBase() { incrementEpoch(); }
- /// \brief A base class for iterator classes ("handles") that wish to poll for
+ /// A base class for iterator classes ("handles") that wish to poll for
/// iterator invalidating modifications in the underlying data structure.
/// When LLVM is built without asserts, this class is empty and does nothing.
///
@@ -66,12 +65,12 @@
explicit HandleBase(const DebugEpochBase *Parent)
: EpochAddress(&Parent->Epoch), EpochAtCreation(Parent->Epoch) {}
- /// \brief Returns true if the DebugEpochBase this Handle is linked to has
+ /// Returns true if the DebugEpochBase this Handle is linked to has
/// not called incrementEpoch on itself since the creation of this
/// HandleBase instance.
bool isHandleInSync() const { return *EpochAddress == EpochAtCreation; }
- /// \brief Returns a pointer to the epoch word stored in the data structure
+ /// Returns a pointer to the epoch word stored in the data structure
/// this handle points into. Can be used to check if two iterators point
/// into the same data structure.
const void *getEpochAddress() const { return EpochAddress; }
diff --git a/linux-x64/clang/include/llvm/ADT/FunctionExtras.h b/linux-x64/clang/include/llvm/ADT/FunctionExtras.h
new file mode 100644
index 0000000..2b75dc6
--- /dev/null
+++ b/linux-x64/clang/include/llvm/ADT/FunctionExtras.h
@@ -0,0 +1,293 @@
+//===- FunctionExtras.h - Function type erasure utilities -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// This file provides a collection of function (or more generally, callable)
+/// type erasure utilities supplementing those provided by the standard library
+/// in `<function>`.
+///
+/// It provides `unique_function`, which works like `std::function` but supports
+/// move-only callable objects.
+///
+/// Future plans:
+/// - Add a `function` that provides const, volatile, and ref-qualified support,
+/// which doesn't work with `std::function`.
+/// - Provide support for specifying multiple signatures to type erase callable
+/// objects with an overload set, such as those produced by generic lambdas.
+/// - Expand to include a copyable utility that directly replaces std::function
+/// but brings the above improvements.
+///
+/// Note that LLVM's utilities are greatly simplified by not supporting
+/// allocators.
+///
+/// If the standard library ever begins to provide comparable facilities we can
+/// consider switching to those.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_ADT_FUNCTION_EXTRAS_H
+#define LLVM_ADT_FUNCTION_EXTRAS_H
+
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "llvm/Support/type_traits.h"
+#include <memory>
+
+namespace llvm {
+
+template <typename FunctionT> class unique_function;
+
+template <typename ReturnT, typename... ParamTs>
+class unique_function<ReturnT(ParamTs...)> {
+ static constexpr size_t InlineStorageSize = sizeof(void *) * 3;
+
+ // MSVC has a bug and ICEs if we give it a particular dependent value
+ // expression as part of the `std::conditional` below. To work around this,
+ // we build that into a template struct's constexpr bool.
+ template <typename T> struct IsSizeLessThanThresholdT {
+ static constexpr bool value = sizeof(T) <= (2 * sizeof(void *));
+ };
+
+ // Provide a type function to map parameters that won't observe extra copies
+ // or moves and which are small enough to likely pass in register to values
+ // and all other types to l-value reference types. We use this to compute the
+ // types used in our erased call utility to minimize copies and moves unless
+ // doing so would force things unnecessarily into memory.
+ //
+ // The heuristic used is related to common ABI register passing conventions.
+ // It doesn't have to be exact though, and in one way it is more strict
+ // because we want to still be able to observe either moves *or* copies.
+ template <typename T>
+ using AdjustedParamT = typename std::conditional<
+ !std::is_reference<T>::value &&
+ llvm::is_trivially_copy_constructible<T>::value &&
+ llvm::is_trivially_move_constructible<T>::value &&
+ IsSizeLessThanThresholdT<T>::value,
+ T, T &>::type;
+
+ // The type of the erased function pointer we use as a callback to dispatch to
+ // the stored callable when it is trivial to move and destroy.
+ using CallPtrT = ReturnT (*)(void *CallableAddr,
+ AdjustedParamT<ParamTs>... Params);
+ using MovePtrT = void (*)(void *LHSCallableAddr, void *RHSCallableAddr);
+ using DestroyPtrT = void (*)(void *CallableAddr);
+
+ /// A struct to hold a single trivial callback with sufficient alignment for
+ /// our bitpacking.
+ struct alignas(8) TrivialCallback {
+ CallPtrT CallPtr;
+ };
+
+ /// A struct we use to aggregate three callbacks when we need full set of
+ /// operations.
+ struct alignas(8) NonTrivialCallbacks {
+ CallPtrT CallPtr;
+ MovePtrT MovePtr;
+ DestroyPtrT DestroyPtr;
+ };
+
+ // Create a pointer union between either a pointer to a static trivial call
+ // pointer in a struct or a pointer to a static struct of the call, move, and
+ // destroy pointers.
+ using CallbackPointerUnionT =
+ PointerUnion<TrivialCallback *, NonTrivialCallbacks *>;
+
+ // The main storage buffer. This will either have a pointer to out-of-line
+ // storage or an inline buffer storing the callable.
+ union StorageUnionT {
+ // For out-of-line storage we keep a pointer to the underlying storage and
+ // the size. This is enough to deallocate the memory.
+ struct OutOfLineStorageT {
+ void *StoragePtr;
+ size_t Size;
+ size_t Alignment;
+ } OutOfLineStorage;
+ static_assert(
+ sizeof(OutOfLineStorageT) <= InlineStorageSize,
+ "Should always use all of the out-of-line storage for inline storage!");
+
+ // For in-line storage, we just provide an aligned character buffer. We
+ // provide three pointers worth of storage here.
+ typename std::aligned_storage<InlineStorageSize, alignof(void *)>::type
+ InlineStorage;
+ } StorageUnion;
+
+ // A compressed pointer to either our dispatching callback or our table of
+ // dispatching callbacks and the flag for whether the callable itself is
+ // stored inline or not.
+ PointerIntPair<CallbackPointerUnionT, 1, bool> CallbackAndInlineFlag;
+
+ bool isInlineStorage() const { return CallbackAndInlineFlag.getInt(); }
+
+ bool isTrivialCallback() const {
+ return CallbackAndInlineFlag.getPointer().template is<TrivialCallback *>();
+ }
+
+ CallPtrT getTrivialCallback() const {
+ return CallbackAndInlineFlag.getPointer().template get<TrivialCallback *>()->CallPtr;
+ }
+
+ NonTrivialCallbacks *getNonTrivialCallbacks() const {
+ return CallbackAndInlineFlag.getPointer()
+ .template get<NonTrivialCallbacks *>();
+ }
+
+ void *getInlineStorage() { return &StorageUnion.InlineStorage; }
+
+ void *getOutOfLineStorage() {
+ return StorageUnion.OutOfLineStorage.StoragePtr;
+ }
+ size_t getOutOfLineStorageSize() const {
+ return StorageUnion.OutOfLineStorage.Size;
+ }
+ size_t getOutOfLineStorageAlignment() const {
+ return StorageUnion.OutOfLineStorage.Alignment;
+ }
+
+ void setOutOfLineStorage(void *Ptr, size_t Size, size_t Alignment) {
+ StorageUnion.OutOfLineStorage = {Ptr, Size, Alignment};
+ }
+
+ template <typename CallableT>
+ static ReturnT CallImpl(void *CallableAddr, AdjustedParamT<ParamTs>... Params) {
+ return (*reinterpret_cast<CallableT *>(CallableAddr))(
+ std::forward<ParamTs>(Params)...);
+ }
+
+ template <typename CallableT>
+ static void MoveImpl(void *LHSCallableAddr, void *RHSCallableAddr) noexcept {
+ new (LHSCallableAddr)
+ CallableT(std::move(*reinterpret_cast<CallableT *>(RHSCallableAddr)));
+ }
+
+ template <typename CallableT>
+ static void DestroyImpl(void *CallableAddr) noexcept {
+ reinterpret_cast<CallableT *>(CallableAddr)->~CallableT();
+ }
+
+public:
+ unique_function() = default;
+ unique_function(std::nullptr_t /*null_callable*/) {}
+
+ ~unique_function() {
+ if (!CallbackAndInlineFlag.getPointer())
+ return;
+
+ // Cache this value so we don't re-check it after type-erased operations.
+ bool IsInlineStorage = isInlineStorage();
+
+ if (!isTrivialCallback())
+ getNonTrivialCallbacks()->DestroyPtr(
+ IsInlineStorage ? getInlineStorage() : getOutOfLineStorage());
+
+ if (!IsInlineStorage)
+ deallocate_buffer(getOutOfLineStorage(), getOutOfLineStorageSize(),
+ getOutOfLineStorageAlignment());
+ }
+
+ unique_function(unique_function &&RHS) noexcept {
+ // Copy the callback and inline flag.
+ CallbackAndInlineFlag = RHS.CallbackAndInlineFlag;
+
+ // If the RHS is empty, just copying the above is sufficient.
+ if (!RHS)
+ return;
+
+ if (!isInlineStorage()) {
+ // The out-of-line case is easiest to move.
+ StorageUnion.OutOfLineStorage = RHS.StorageUnion.OutOfLineStorage;
+ } else if (isTrivialCallback()) {
+ // Move is trivial, just memcpy the bytes across.
+ memcpy(getInlineStorage(), RHS.getInlineStorage(), InlineStorageSize);
+ } else {
+ // Non-trivial move, so dispatch to a type-erased implementation.
+ getNonTrivialCallbacks()->MovePtr(getInlineStorage(),
+ RHS.getInlineStorage());
+ }
+
+ // Clear the old callback and inline flag to get back to as-if-null.
+ RHS.CallbackAndInlineFlag = {};
+
+#ifndef NDEBUG
+ // In debug builds, we also scribble across the rest of the storage.
+ memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize);
+#endif
+ }
+
+ unique_function &operator=(unique_function &&RHS) noexcept {
+ if (this == &RHS)
+ return *this;
+
+ // Because we don't try to provide any exception safety guarantees we can
+ // implement move assignment very simply by first destroying the current
+ // object and then move-constructing over top of it.
+ this->~unique_function();
+ new (this) unique_function(std::move(RHS));
+ return *this;
+ }
+
+ template <typename CallableT> unique_function(CallableT Callable) {
+ bool IsInlineStorage = true;
+ void *CallableAddr = getInlineStorage();
+ if (sizeof(CallableT) > InlineStorageSize ||
+ alignof(CallableT) > alignof(decltype(StorageUnion.InlineStorage))) {
+ IsInlineStorage = false;
+ // Allocate out-of-line storage. FIXME: Use an explicit alignment
+ // parameter in C++17 mode.
+ auto Size = sizeof(CallableT);
+ auto Alignment = alignof(CallableT);
+ CallableAddr = allocate_buffer(Size, Alignment);
+ setOutOfLineStorage(CallableAddr, Size, Alignment);
+ }
+
+ // Now move into the storage.
+ new (CallableAddr) CallableT(std::move(Callable));
+
+ // See if we can create a trivial callback. We need the callable to be
+ // trivially moved and trivially destroyed so that we don't have to store
+ // type erased callbacks for those operations.
+ //
+ // FIXME: We should use constexpr if here and below to avoid instantiating
+ // the non-trivial static objects when unnecessary. While the linker should
+ // remove them, it is still wasteful.
+ if (llvm::is_trivially_move_constructible<CallableT>::value &&
+ std::is_trivially_destructible<CallableT>::value) {
+ // We need to create a nicely aligned object. We use a static variable
+ // for this because it is a trivial struct.
+ static TrivialCallback Callback = { &CallImpl<CallableT> };
+
+ CallbackAndInlineFlag = {&Callback, IsInlineStorage};
+ return;
+ }
+
+ // Otherwise, we need to point at an object that contains all the different
+ // type erased behaviors needed. Create a static instance of the struct type
+ // here and then use a pointer to that.
+ static NonTrivialCallbacks Callbacks = {
+ &CallImpl<CallableT>, &MoveImpl<CallableT>, &DestroyImpl<CallableT>};
+
+ CallbackAndInlineFlag = {&Callbacks, IsInlineStorage};
+ }
+
+ ReturnT operator()(ParamTs... Params) {
+ void *CallableAddr =
+ isInlineStorage() ? getInlineStorage() : getOutOfLineStorage();
+
+ return (isTrivialCallback()
+ ? getTrivialCallback()
+ : getNonTrivialCallbacks()->CallPtr)(CallableAddr, Params...);
+ }
+
+ explicit operator bool() const {
+ return (bool)CallbackAndInlineFlag.getPointer();
+ }
+};
+
+} // end namespace llvm
+
+#endif // LLVM_ADT_FUNCTION_H
diff --git a/linux-x64/clang/include/llvm/ADT/GraphTraits.h b/linux-x64/clang/include/llvm/ADT/GraphTraits.h
index 27c647f..d39b50f 100644
--- a/linux-x64/clang/include/llvm/ADT/GraphTraits.h
+++ b/linux-x64/clang/include/llvm/ADT/GraphTraits.h
@@ -25,6 +25,13 @@
// GraphTraits - This class should be specialized by different graph types...
// which is why the default version is empty.
//
+// This template evolved from supporting `BasicBlock` to also later supporting
+// more complex types (e.g. CFG and DomTree).
+//
+// GraphTraits can be used to create a view over a graph interpreting it
+// differently without requiring a copy of the original graph. This could
+// be achieved by carrying more data in NodeRef. See LoopBodyTraits for one
+// example.
template<class GraphType>
struct GraphTraits {
// Elements to provide:
diff --git a/linux-x64/clang/include/llvm/ADT/Hashing.h b/linux-x64/clang/include/llvm/ADT/Hashing.h
index c3b5741..9f830ba 100644
--- a/linux-x64/clang/include/llvm/ADT/Hashing.h
+++ b/linux-x64/clang/include/llvm/ADT/Hashing.h
@@ -57,7 +57,7 @@
namespace llvm {
-/// \brief An opaque object representing a hash code.
+/// An opaque object representing a hash code.
///
/// This object represents the result of hashing some entity. It is intended to
/// be used to implement hashtables or other hashing-based data structures.
@@ -73,14 +73,14 @@
size_t value;
public:
- /// \brief Default construct a hash_code.
+ /// Default construct a hash_code.
/// Note that this leaves the value uninitialized.
hash_code() = default;
- /// \brief Form a hash code directly from a numerical value.
+ /// Form a hash code directly from a numerical value.
hash_code(size_t value) : value(value) {}
- /// \brief Convert the hash code to its numerical value for use.
+ /// Convert the hash code to its numerical value for use.
/*explicit*/ operator size_t() const { return value; }
friend bool operator==(const hash_code &lhs, const hash_code &rhs) {
@@ -90,11 +90,11 @@
return lhs.value != rhs.value;
}
- /// \brief Allow a hash_code to be directly run through hash_value.
+ /// Allow a hash_code to be directly run through hash_value.
friend size_t hash_value(const hash_code &code) { return code.value; }
};
-/// \brief Compute a hash_code for any integer value.
+/// Compute a hash_code for any integer value.
///
/// Note that this function is intended to compute the same hash_code for
/// a particular value without regard to the pre-promotion type. This is in
@@ -105,21 +105,21 @@
typename std::enable_if<is_integral_or_enum<T>::value, hash_code>::type
hash_value(T value);
-/// \brief Compute a hash_code for a pointer's address.
+/// Compute a hash_code for a pointer's address.
///
/// N.B.: This hashes the *address*. Not the value and not the type.
template <typename T> hash_code hash_value(const T *ptr);
-/// \brief Compute a hash_code for a pair of objects.
+/// Compute a hash_code for a pair of objects.
template <typename T, typename U>
hash_code hash_value(const std::pair<T, U> &arg);
-/// \brief Compute a hash_code for a standard string.
+/// Compute a hash_code for a standard string.
template <typename T>
hash_code hash_value(const std::basic_string<T> &arg);
-/// \brief Override the execution seed with a fixed value.
+/// Override the execution seed with a fixed value.
///
/// This hashing library uses a per-execution seed designed to change on each
/// run with high probability in order to ensure that the hash codes are not
@@ -164,7 +164,7 @@
static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
static const uint64_t k3 = 0xc949d7c7509e6557ULL;
-/// \brief Bitwise right rotate.
+/// Bitwise right rotate.
/// Normally this will compile to a single instruction, especially if the
/// shift is a manifest constant.
inline uint64_t rotate(uint64_t val, size_t shift) {
@@ -254,13 +254,13 @@
return k2 ^ seed;
}
-/// \brief The intermediate state used during hashing.
+/// The intermediate state used during hashing.
/// Currently, the algorithm for computing hash codes is based on CityHash and
/// keeps 56 bytes of arbitrary state.
struct hash_state {
uint64_t h0, h1, h2, h3, h4, h5, h6;
- /// \brief Create a new hash_state structure and initialize it based on the
+ /// Create a new hash_state structure and initialize it based on the
/// seed and the first 64-byte chunk.
/// This effectively performs the initial mix.
static hash_state create(const char *s, uint64_t seed) {
@@ -272,7 +272,7 @@
return state;
}
- /// \brief Mix 32-bytes from the input sequence into the 16-bytes of 'a'
+ /// Mix 32-bytes from the input sequence into the 16-bytes of 'a'
/// and 'b', including whatever is already in 'a' and 'b'.
static void mix_32_bytes(const char *s, uint64_t &a, uint64_t &b) {
a += fetch64(s);
@@ -284,7 +284,7 @@
a += c;
}
- /// \brief Mix in a 64-byte buffer of data.
+ /// Mix in a 64-byte buffer of data.
/// We mix all 64 bytes even when the chunk length is smaller, but we
/// record the actual length.
void mix(const char *s) {
@@ -302,7 +302,7 @@
std::swap(h2, h0);
}
- /// \brief Compute the final 64-bit hash code value based on the current
+ /// Compute the final 64-bit hash code value based on the current
/// state and the length of bytes hashed.
uint64_t finalize(size_t length) {
return hash_16_bytes(hash_16_bytes(h3, h5) + shift_mix(h1) * k1 + h2,
@@ -311,7 +311,7 @@
};
-/// \brief A global, fixed seed-override variable.
+/// A global, fixed seed-override variable.
///
/// This variable can be set using the \see llvm::set_fixed_execution_seed
/// function. See that function for details. Do not, under any circumstances,
@@ -332,7 +332,7 @@
}
-/// \brief Trait to indicate whether a type's bits can be hashed directly.
+/// Trait to indicate whether a type's bits can be hashed directly.
///
/// A type trait which is true if we want to combine values for hashing by
/// reading the underlying data. It is false if values of this type must
@@ -359,14 +359,14 @@
(sizeof(T) + sizeof(U)) ==
sizeof(std::pair<T, U>))> {};
-/// \brief Helper to get the hashable data representation for a type.
+/// Helper to get the hashable data representation for a type.
/// This variant is enabled when the type itself can be used.
template <typename T>
typename std::enable_if<is_hashable_data<T>::value, T>::type
get_hashable_data(const T &value) {
return value;
}
-/// \brief Helper to get the hashable data representation for a type.
+/// Helper to get the hashable data representation for a type.
/// This variant is enabled when we must first call hash_value and use the
/// result as our data.
template <typename T>
@@ -376,7 +376,7 @@
return hash_value(value);
}
-/// \brief Helper to store data from a value into a buffer and advance the
+/// Helper to store data from a value into a buffer and advance the
/// pointer into that buffer.
///
/// This routine first checks whether there is enough space in the provided
@@ -395,7 +395,7 @@
return true;
}
-/// \brief Implement the combining of integral values into a hash_code.
+/// Implement the combining of integral values into a hash_code.
///
/// This overload is selected when the value type of the iterator is
/// integral. Rather than computing a hash_code for each object and then
@@ -435,7 +435,7 @@
return state.finalize(length);
}
-/// \brief Implement the combining of integral values into a hash_code.
+/// Implement the combining of integral values into a hash_code.
///
/// This overload is selected when the value type of the iterator is integral
/// and when the input iterator is actually a pointer. Rather than computing
@@ -470,7 +470,7 @@
} // namespace hashing
-/// \brief Compute a hash_code for a sequence of values.
+/// Compute a hash_code for a sequence of values.
///
/// This hashes a sequence of values. It produces the same hash_code as
/// 'hash_combine(a, b, c, ...)', but can run over arbitrary sized sequences
@@ -486,7 +486,7 @@
namespace hashing {
namespace detail {
-/// \brief Helper class to manage the recursive combining of hash_combine
+/// Helper class to manage the recursive combining of hash_combine
/// arguments.
///
/// This class exists to manage the state and various calls involved in the
@@ -499,14 +499,14 @@
const size_t seed;
public:
- /// \brief Construct a recursive hash combining helper.
+ /// Construct a recursive hash combining helper.
///
/// This sets up the state for a recursive hash combine, including getting
/// the seed and buffer setup.
hash_combine_recursive_helper()
: seed(get_execution_seed()) {}
- /// \brief Combine one chunk of data into the current in-flight hash.
+ /// Combine one chunk of data into the current in-flight hash.
///
/// This merges one chunk of data into the hash. First it tries to buffer
/// the data. If the buffer is full, it hashes the buffer into its
@@ -547,7 +547,7 @@
return buffer_ptr;
}
- /// \brief Recursive, variadic combining method.
+ /// Recursive, variadic combining method.
///
/// This function recurses through each argument, combining that argument
/// into a single hash.
@@ -560,7 +560,7 @@
return combine(length, buffer_ptr, buffer_end, args...);
}
- /// \brief Base case for recursive, variadic combining.
+ /// Base case for recursive, variadic combining.
///
/// The base case when combining arguments recursively is reached when all
/// arguments have been handled. It flushes the remaining buffer and
@@ -588,7 +588,7 @@
} // namespace detail
} // namespace hashing
-/// \brief Combine values into a single hash_code.
+/// Combine values into a single hash_code.
///
/// This routine accepts a varying number of arguments of any type. It will
/// attempt to combine them into a single hash_code. For user-defined types it
@@ -610,7 +610,7 @@
namespace hashing {
namespace detail {
-/// \brief Helper to hash the value of a single integer.
+/// Helper to hash the value of a single integer.
///
/// Overloads for smaller integer types are not provided to ensure consistent
/// behavior in the presence of integral promotions. Essentially,
diff --git a/linux-x64/clang/include/llvm/ADT/ImmutableList.h b/linux-x64/clang/include/llvm/ADT/ImmutableList.h
index 60d63e0..1f5e981 100644
--- a/linux-x64/clang/include/llvm/ADT/ImmutableList.h
+++ b/linux-x64/clang/include/llvm/ADT/ImmutableList.h
@@ -166,7 +166,7 @@
if (ownsAllocator()) delete &getAllocator();
}
- ImmutableList<T> concat(const T& Head, ImmutableList<T> Tail) {
+ LLVM_NODISCARD ImmutableList<T> concat(const T &Head, ImmutableList<T> Tail) {
// Profile the new list to see if it already exists in our cache.
FoldingSetNodeID ID;
void* InsertPos;
@@ -188,7 +188,7 @@
return L;
}
- ImmutableList<T> add(const T& D, ImmutableList<T> L) {
+ LLVM_NODISCARD ImmutableList<T> add(const T& D, ImmutableList<T> L) {
return concat(D, L);
}
diff --git a/linux-x64/clang/include/llvm/ADT/ImmutableMap.h b/linux-x64/clang/include/llvm/ADT/ImmutableMap.h
index 10d1e1f..cbc27ff 100644
--- a/linux-x64/clang/include/llvm/ADT/ImmutableMap.h
+++ b/linux-x64/clang/include/llvm/ADT/ImmutableMap.h
@@ -114,12 +114,13 @@
ImmutableMap getEmptyMap() { return ImmutableMap(F.getEmptyTree()); }
- ImmutableMap add(ImmutableMap Old, key_type_ref K, data_type_ref D) {
+ LLVM_NODISCARD ImmutableMap add(ImmutableMap Old, key_type_ref K,
+ data_type_ref D) {
TreeTy *T = F.add(Old.Root, std::pair<key_type,data_type>(K,D));
return ImmutableMap(Canonicalize ? F.getCanonicalTree(T): T);
}
- ImmutableMap remove(ImmutableMap Old, key_type_ref K) {
+ LLVM_NODISCARD ImmutableMap remove(ImmutableMap Old, key_type_ref K) {
TreeTy *T = F.remove(Old.Root,K);
return ImmutableMap(Canonicalize ? F.getCanonicalTree(T): T);
}
diff --git a/linux-x64/clang/include/llvm/ADT/ImmutableSet.h b/linux-x64/clang/include/llvm/ADT/ImmutableSet.h
index 9d580c5..b1d5f4a 100644
--- a/linux-x64/clang/include/llvm/ADT/ImmutableSet.h
+++ b/linux-x64/clang/include/llvm/ADT/ImmutableSet.h
@@ -1017,7 +1017,7 @@
/// of this operation is logarithmic in the size of the original set.
/// The memory allocated to represent the set is released when the
/// factory object that created the set is destroyed.
- ImmutableSet add(ImmutableSet Old, value_type_ref V) {
+ LLVM_NODISCARD ImmutableSet add(ImmutableSet Old, value_type_ref V) {
TreeTy *NewT = F.add(Old.Root, V);
return ImmutableSet(Canonicalize ? F.getCanonicalTree(NewT) : NewT);
}
@@ -1029,7 +1029,7 @@
/// of this operation is logarithmic in the size of the original set.
/// The memory allocated to represent the set is released when the
/// factory object that created the set is destroyed.
- ImmutableSet remove(ImmutableSet Old, value_type_ref V) {
+ LLVM_NODISCARD ImmutableSet remove(ImmutableSet Old, value_type_ref V) {
TreeTy *NewT = F.remove(Old.Root, V);
return ImmutableSet(Canonicalize ? F.getCanonicalTree(NewT) : NewT);
}
diff --git a/linux-x64/clang/include/llvm/ADT/MapVector.h b/linux-x64/clang/include/llvm/ADT/MapVector.h
index f69f8fd..47b4987 100644
--- a/linux-x64/clang/include/llvm/ADT/MapVector.h
+++ b/linux-x64/clang/include/llvm/ADT/MapVector.h
@@ -39,6 +39,10 @@
MapType Map;
VectorType Vector;
+ static_assert(
+ std::is_integral<typename MapType::mapped_type>::value,
+ "The mapped_type of the specified Map must be an integral type");
+
public:
using value_type = typename VectorType::value_type;
using size_type = typename VectorType::size_type;
@@ -93,9 +97,9 @@
}
ValueT &operator[](const KeyT &Key) {
- std::pair<KeyT, unsigned> Pair = std::make_pair(Key, 0);
+ std::pair<KeyT, typename MapType::mapped_type> Pair = std::make_pair(Key, 0);
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);
- unsigned &I = Result.first->second;
+ auto &I = Result.first->second;
if (Result.second) {
Vector.push_back(std::make_pair(Key, ValueT()));
I = Vector.size() - 1;
@@ -112,9 +116,9 @@
}
std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) {
- std::pair<KeyT, unsigned> Pair = std::make_pair(KV.first, 0);
+ std::pair<KeyT, typename MapType::mapped_type> Pair = std::make_pair(KV.first, 0);
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);
- unsigned &I = Result.first->second;
+ auto &I = Result.first->second;
if (Result.second) {
Vector.push_back(std::make_pair(KV.first, KV.second));
I = Vector.size() - 1;
@@ -125,9 +129,9 @@
std::pair<iterator, bool> insert(std::pair<KeyT, ValueT> &&KV) {
// Copy KV.first into the map, then move it into the vector.
- std::pair<KeyT, unsigned> Pair = std::make_pair(KV.first, 0);
+ std::pair<KeyT, typename MapType::mapped_type> Pair = std::make_pair(KV.first, 0);
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);
- unsigned &I = Result.first->second;
+ auto &I = Result.first->second;
if (Result.second) {
Vector.push_back(std::move(KV));
I = Vector.size() - 1;
@@ -153,14 +157,14 @@
(Vector.begin() + Pos->second);
}
- /// \brief Remove the last element from the vector.
+ /// Remove the last element from the vector.
void pop_back() {
typename MapType::iterator Pos = Map.find(Vector.back().first);
Map.erase(Pos);
Vector.pop_back();
}
- /// \brief Remove the element given by Iterator.
+ /// Remove the element given by Iterator.
///
/// Returns an iterator to the element following the one which was removed,
/// which may be end().
@@ -183,7 +187,7 @@
return Next;
}
- /// \brief Remove all elements with the key value Key.
+ /// Remove all elements with the key value Key.
///
/// Returns the number of elements removed.
size_type erase(const KeyT &Key) {
@@ -194,7 +198,7 @@
return 1;
}
- /// \brief Remove the elements that match the predicate.
+ /// Remove the elements that match the predicate.
///
/// Erase all elements that match \c Pred in a single pass. Takes linear
/// time.
@@ -223,7 +227,7 @@
Vector.erase(O, Vector.end());
}
-/// \brief A MapVector that performs no allocations if smaller than a certain
+/// A MapVector that performs no allocations if smaller than a certain
/// size.
template <typename KeyT, typename ValueT, unsigned N>
struct SmallMapVector
diff --git a/linux-x64/clang/include/llvm/ADT/None.h b/linux-x64/clang/include/llvm/ADT/None.h
index c7a99c6..4b6bc1e 100644
--- a/linux-x64/clang/include/llvm/ADT/None.h
+++ b/linux-x64/clang/include/llvm/ADT/None.h
@@ -17,7 +17,7 @@
#define LLVM_ADT_NONE_H
namespace llvm {
-/// \brief A simple null object to allow implicit construction of Optional<T>
+/// A simple null object to allow implicit construction of Optional<T>
/// and similar types without having to spell out the specialization's name.
// (constant value 1 in an attempt to workaround MSVC build issue... )
enum class NoneType { None = 1 };
diff --git a/linux-x64/clang/include/llvm/ADT/PackedVector.h b/linux-x64/clang/include/llvm/ADT/PackedVector.h
index 95adc29..3d53c49 100644
--- a/linux-x64/clang/include/llvm/ADT/PackedVector.h
+++ b/linux-x64/clang/include/llvm/ADT/PackedVector.h
@@ -65,7 +65,7 @@
}
};
-/// \brief Store a vector of values using a specific number of bits for each
+/// Store a vector of values using a specific number of bits for each
/// value. Both signed and unsigned types can be used, e.g
/// @code
/// PackedVector<signed, 2> vec;
diff --git a/linux-x64/clang/include/llvm/ADT/SCCIterator.h b/linux-x64/clang/include/llvm/ADT/SCCIterator.h
index 784a58d..ab1dc46 100644
--- a/linux-x64/clang/include/llvm/ADT/SCCIterator.h
+++ b/linux-x64/clang/include/llvm/ADT/SCCIterator.h
@@ -33,7 +33,7 @@
namespace llvm {
-/// \brief Enumerate the SCCs of a directed graph in reverse topological order
+/// Enumerate the SCCs of a directed graph in reverse topological order
/// of the SCC DAG.
///
/// This is implemented using Tarjan's DFS algorithm using an internal stack to
@@ -104,7 +104,7 @@
}
static scc_iterator end(const GraphT &) { return scc_iterator(); }
- /// \brief Direct loop termination test which is more efficient than
+ /// Direct loop termination test which is more efficient than
/// comparison with \c end().
bool isAtEnd() const {
assert(!CurrentSCC.empty() || VisitStack.empty());
@@ -125,7 +125,7 @@
return CurrentSCC;
}
- /// \brief Test if the current SCC has a loop.
+ /// Test if the current SCC has a loop.
///
/// If the SCC has more than one node, this is trivially true. If not, it may
/// still contain a loop if the node has an edge back to itself.
@@ -222,12 +222,12 @@
return false;
}
-/// \brief Construct the begin iterator for a deduced graph type T.
+/// Construct the begin iterator for a deduced graph type T.
template <class T> scc_iterator<T> scc_begin(const T &G) {
return scc_iterator<T>::begin(G);
}
-/// \brief Construct the end iterator for a deduced graph type T.
+/// Construct the end iterator for a deduced graph type T.
template <class T> scc_iterator<T> scc_end(const T &G) {
return scc_iterator<T>::end(G);
}
diff --git a/linux-x64/clang/include/llvm/ADT/STLExtras.h b/linux-x64/clang/include/llvm/ADT/STLExtras.h
index 051b900..03109a0 100644
--- a/linux-x64/clang/include/llvm/ADT/STLExtras.h
+++ b/linux-x64/clang/include/llvm/ADT/STLExtras.h
@@ -21,6 +21,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
+#include "llvm/Config/abi-breaking.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <cassert>
@@ -58,6 +59,19 @@
} // end namespace detail
//===----------------------------------------------------------------------===//
+// Extra additions to <type_traits>
+//===----------------------------------------------------------------------===//
+
+template <typename T>
+struct negation : std::integral_constant<bool, !bool(T::value)> {};
+
+template <typename...> struct conjunction : std::true_type {};
+template <typename B1> struct conjunction<B1> : B1 {};
+template <typename B1, typename... Bn>
+struct conjunction<B1, Bn...>
+ : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
+
+//===----------------------------------------------------------------------===//
// Extra additions to <functional>
//===----------------------------------------------------------------------===//
@@ -271,60 +285,121 @@
/// auto R = make_filter_range(A, [](int N) { return N % 2 == 1; });
/// // R contains { 1, 3 }.
/// \endcode
-template <typename WrappedIteratorT, typename PredicateT>
-class filter_iterator
+///
+/// Note: filter_iterator_base implements support for forward iteration.
+/// filter_iterator_impl exists to provide support for bidirectional iteration,
+/// conditional on whether the wrapped iterator supports it.
+template <typename WrappedIteratorT, typename PredicateT, typename IterTag>
+class filter_iterator_base
: public iterator_adaptor_base<
- filter_iterator<WrappedIteratorT, PredicateT>, WrappedIteratorT,
+ filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
+ WrappedIteratorT,
typename std::common_type<
- std::forward_iterator_tag,
- typename std::iterator_traits<
- WrappedIteratorT>::iterator_category>::type> {
+ IterTag, typename std::iterator_traits<
+ WrappedIteratorT>::iterator_category>::type> {
using BaseT = iterator_adaptor_base<
- filter_iterator<WrappedIteratorT, PredicateT>, WrappedIteratorT,
+ filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>,
+ WrappedIteratorT,
typename std::common_type<
- std::forward_iterator_tag,
- typename std::iterator_traits<WrappedIteratorT>::iterator_category>::
- type>;
+ IterTag, typename std::iterator_traits<
+ WrappedIteratorT>::iterator_category>::type>;
- struct PayloadType {
- WrappedIteratorT End;
- PredicateT Pred;
- };
-
- Optional<PayloadType> Payload;
+protected:
+ WrappedIteratorT End;
+ PredicateT Pred;
void findNextValid() {
- assert(Payload && "Payload should be engaged when findNextValid is called");
- while (this->I != Payload->End && !Payload->Pred(*this->I))
+ while (this->I != End && !Pred(*this->I))
BaseT::operator++();
}
- // Construct the begin iterator. The begin iterator requires to know where end
- // is, so that it can properly stop when it hits end.
- filter_iterator(WrappedIteratorT Begin, WrappedIteratorT End, PredicateT Pred)
- : BaseT(std::move(Begin)),
- Payload(PayloadType{std::move(End), std::move(Pred)}) {
+ // Construct the iterator. The begin iterator needs to know where the end
+ // is, so that it can properly stop when it gets there. The end iterator only
+ // needs the predicate to support bidirectional iteration.
+ filter_iterator_base(WrappedIteratorT Begin, WrappedIteratorT End,
+ PredicateT Pred)
+ : BaseT(Begin), End(End), Pred(Pred) {
findNextValid();
}
- // Construct the end iterator. It's not incrementable, so Payload doesn't
- // have to be engaged.
- filter_iterator(WrappedIteratorT End) : BaseT(End) {}
-
public:
using BaseT::operator++;
- filter_iterator &operator++() {
+ filter_iterator_base &operator++() {
BaseT::operator++();
findNextValid();
return *this;
}
-
- template <typename RT, typename PT>
- friend iterator_range<filter_iterator<detail::IterOfRange<RT>, PT>>
- make_filter_range(RT &&, PT);
};
+/// Specialization of filter_iterator_base for forward iteration only.
+template <typename WrappedIteratorT, typename PredicateT,
+ typename IterTag = std::forward_iterator_tag>
+class filter_iterator_impl
+ : public filter_iterator_base<WrappedIteratorT, PredicateT, IterTag> {
+ using BaseT = filter_iterator_base<WrappedIteratorT, PredicateT, IterTag>;
+
+public:
+ filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End,
+ PredicateT Pred)
+ : BaseT(Begin, End, Pred) {}
+};
+
+/// Specialization of filter_iterator_base for bidirectional iteration.
+template <typename WrappedIteratorT, typename PredicateT>
+class filter_iterator_impl<WrappedIteratorT, PredicateT,
+ std::bidirectional_iterator_tag>
+ : public filter_iterator_base<WrappedIteratorT, PredicateT,
+ std::bidirectional_iterator_tag> {
+ using BaseT = filter_iterator_base<WrappedIteratorT, PredicateT,
+ std::bidirectional_iterator_tag>;
+ void findPrevValid() {
+ while (!this->Pred(*this->I))
+ BaseT::operator--();
+ }
+
+public:
+ using BaseT::operator--;
+
+ filter_iterator_impl(WrappedIteratorT Begin, WrappedIteratorT End,
+ PredicateT Pred)
+ : BaseT(Begin, End, Pred) {}
+
+ filter_iterator_impl &operator--() {
+ BaseT::operator--();
+ findPrevValid();
+ return *this;
+ }
+};
+
+namespace detail {
+
+template <bool is_bidirectional> struct fwd_or_bidi_tag_impl {
+ using type = std::forward_iterator_tag;
+};
+
+template <> struct fwd_or_bidi_tag_impl<true> {
+ using type = std::bidirectional_iterator_tag;
+};
+
+/// Helper which sets its type member to forward_iterator_tag if the category
+/// of \p IterT does not derive from bidirectional_iterator_tag, and to
+/// bidirectional_iterator_tag otherwise.
+template <typename IterT> struct fwd_or_bidi_tag {
+ using type = typename fwd_or_bidi_tag_impl<std::is_base_of<
+ std::bidirectional_iterator_tag,
+ typename std::iterator_traits<IterT>::iterator_category>::value>::type;
+};
+
+} // namespace detail
+
+/// Defines filter_iterator to a suitable specialization of
+/// filter_iterator_impl, based on the underlying iterator's category.
+template <typename WrappedIteratorT, typename PredicateT>
+using filter_iterator = filter_iterator_impl<
+ WrappedIteratorT, PredicateT,
+ typename detail::fwd_or_bidi_tag<WrappedIteratorT>::type>;
+
/// Convenience function that takes a range of elements and a predicate,
/// and return a new filter_iterator range.
///
@@ -337,10 +412,94 @@
make_filter_range(RangeT &&Range, PredicateT Pred) {
using FilterIteratorT =
filter_iterator<detail::IterOfRange<RangeT>, PredicateT>;
- return make_range(FilterIteratorT(std::begin(std::forward<RangeT>(Range)),
- std::end(std::forward<RangeT>(Range)),
- std::move(Pred)),
- FilterIteratorT(std::end(std::forward<RangeT>(Range))));
+ return make_range(
+ FilterIteratorT(std::begin(std::forward<RangeT>(Range)),
+ std::end(std::forward<RangeT>(Range)), Pred),
+ FilterIteratorT(std::end(std::forward<RangeT>(Range)),
+ std::end(std::forward<RangeT>(Range)), Pred));
+}
+
+/// A pseudo-iterator adaptor that is designed to implement "early increment"
+/// style loops.
+///
+/// This is *not a normal iterator* and should almost never be used directly. It
+/// is intended primarily to be used with range based for loops and some range
+/// algorithms.
+///
+/// The iterator isn't quite an `OutputIterator` or an `InputIterator` but
+/// somewhere between them. The constraints of these iterators are:
+///
+/// - On construction or after being incremented, it is comparable and
+/// dereferencable. It is *not* incrementable.
+/// - After being dereferenced, it is neither comparable nor dereferencable, it
+/// is only incrementable.
+///
+/// This means you can only dereference the iterator once, and you can only
+/// increment it once between dereferences.
+template <typename WrappedIteratorT>
+class early_inc_iterator_impl
+ : public iterator_adaptor_base<early_inc_iterator_impl<WrappedIteratorT>,
+ WrappedIteratorT, std::input_iterator_tag> {
+ using BaseT =
+ iterator_adaptor_base<early_inc_iterator_impl<WrappedIteratorT>,
+ WrappedIteratorT, std::input_iterator_tag>;
+
+ using PointerT = typename std::iterator_traits<WrappedIteratorT>::pointer;
+
+protected:
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ bool IsEarlyIncremented = false;
+#endif
+
+public:
+ early_inc_iterator_impl(WrappedIteratorT I) : BaseT(I) {}
+
+ using BaseT::operator*;
+ typename BaseT::reference operator*() {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ assert(!IsEarlyIncremented && "Cannot dereference twice!");
+ IsEarlyIncremented = true;
+#endif
+ return *(this->I)++;
+ }
+
+ using BaseT::operator++;
+ early_inc_iterator_impl &operator++() {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ assert(IsEarlyIncremented && "Cannot increment before dereferencing!");
+ IsEarlyIncremented = false;
+#endif
+ return *this;
+ }
+
+ using BaseT::operator==;
+ bool operator==(const early_inc_iterator_impl &RHS) const {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ assert(!IsEarlyIncremented && "Cannot compare after dereferencing!");
+#endif
+ return BaseT::operator==(RHS);
+ }
+};
+
+/// Make a range that does early increment to allow mutation of the underlying
+/// range without disrupting iteration.
+///
+/// The underlying iterator will be incremented immediately after it is
+/// dereferenced, allowing deletion of the current node or insertion of nodes to
+/// not disrupt iteration provided they do not invalidate the *next* iterator --
+/// the current iterator can be invalidated.
+///
+/// This requires a very exact pattern of use that is only really suitable to
+/// range based for loops and other range algorithms that explicitly guarantee
+/// to dereference exactly once each element, and to increment exactly once each
+/// element.
+template <typename RangeT>
+iterator_range<early_inc_iterator_impl<detail::IterOfRange<RangeT>>>
+make_early_inc_range(RangeT &&Range) {
+ using EarlyIncIteratorT =
+ early_inc_iterator_impl<detail::IterOfRange<RangeT>>;
+ return make_range(EarlyIncIteratorT(std::begin(std::forward<RangeT>(Range))),
+ EarlyIncIteratorT(std::end(std::forward<RangeT>(Range))));
}
// forward declarations required by zip_shortest/zip_first
@@ -649,7 +808,7 @@
// Extra additions to <utility>
//===----------------------------------------------------------------------===//
-/// \brief Function object to check whether the first component of a std::pair
+/// Function object to check whether the first component of a std::pair
/// compares less than the first component of another std::pair.
struct less_first {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
@@ -657,7 +816,7 @@
}
};
-/// \brief Function object to check whether the second component of a std::pair
+/// Function object to check whether the second component of a std::pair
/// compares less than the second component of another std::pair.
struct less_second {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
@@ -665,16 +824,29 @@
}
};
+/// \brief Function object to apply a binary function to the first component of
+/// a std::pair.
+template<typename FuncTy>
+struct on_first {
+ FuncTy func;
+
+ template <typename T>
+ auto operator()(const T &lhs, const T &rhs) const
+ -> decltype(func(lhs.first, rhs.first)) {
+ return func(lhs.first, rhs.first);
+ }
+};
+
// A subset of N3658. More stuff can be added as-needed.
-/// \brief Represents a compile-time sequence of integers.
+/// Represents a compile-time sequence of integers.
template <class T, T... I> struct integer_sequence {
using value_type = T;
static constexpr size_t size() { return sizeof...(I); }
};
-/// \brief Alias for the common case of a sequence of size_ts.
+/// Alias for the common case of a sequence of size_ts.
template <size_t... I>
struct index_sequence : integer_sequence<std::size_t, I...> {};
@@ -683,7 +855,7 @@
template <std::size_t... I>
struct build_index_impl<0, I...> : index_sequence<I...> {};
-/// \brief Creates a compile-time integer sequence for a parameter pack.
+/// Creates a compile-time integer sequence for a parameter pack.
template <class... Ts>
struct index_sequence_for : build_index_impl<sizeof...(Ts)> {};
@@ -692,7 +864,7 @@
template <int N> struct rank : rank<N - 1> {};
template <> struct rank<0> {};
-/// \brief traits class for checking whether type T is one of any of the given
+/// traits class for checking whether type T is one of any of the given
/// types in the variadic list.
template <typename T, typename... Ts> struct is_one_of {
static const bool value = false;
@@ -704,7 +876,7 @@
std::is_same<T, U>::value || is_one_of<T, Ts...>::value;
};
-/// \brief traits class for checking whether type T is a base class for all
+/// traits class for checking whether type T is a base class for all
/// the given types in the variadic list.
template <typename T, typename... Ts> struct are_base_of {
static const bool value = true;
@@ -943,7 +1115,7 @@
return std::lower_bound(adl_begin(Range), adl_end(Range), I);
}
-/// \brief Given a range of type R, iterate the entire range and return a
+/// Given a range of type R, iterate the entire range and return a
/// SmallVector with elements of the vector. This is useful, for example,
/// when you want to iterate a range and then sort the results.
template <unsigned Size, typename R>
@@ -964,13 +1136,25 @@
C.erase(remove_if(C, P), C.end());
}
+/// Get the size of a range. This is a wrapper function around std::distance
+/// which is only enabled when the operation is O(1).
+template <typename R>
+auto size(R &&Range, typename std::enable_if<
+ std::is_same<typename std::iterator_traits<decltype(
+ Range.begin())>::iterator_category,
+ std::random_access_iterator_tag>::value,
+ void>::type * = nullptr)
+ -> decltype(std::distance(Range.begin(), Range.end())) {
+ return std::distance(Range.begin(), Range.end());
+}
+
//===----------------------------------------------------------------------===//
// Extra additions to <memory>
//===----------------------------------------------------------------------===//
// Implement make_unique according to N3656.
-/// \brief Constructs a `new T()` with the given args and returns a
+/// Constructs a `new T()` with the given args and returns a
/// `unique_ptr<T>` which owns the object.
///
/// Example:
@@ -983,7 +1167,7 @@
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
-/// \brief Constructs a `new T[n]` with the given args and returns a
+/// Constructs a `new T[n]` with the given args and returns a
/// `unique_ptr<T[]>` which owns the object.
///
/// \param n size of the new array.
diff --git a/linux-x64/clang/include/llvm/ADT/SetVector.h b/linux-x64/clang/include/llvm/ADT/SetVector.h
index 04ed52f..3d67810 100644
--- a/linux-x64/clang/include/llvm/ADT/SetVector.h
+++ b/linux-x64/clang/include/llvm/ADT/SetVector.h
@@ -31,7 +31,7 @@
namespace llvm {
-/// \brief A vector that has set insertion semantics.
+/// A vector that has set insertion semantics.
///
/// This adapter class provides a way to keep a set of things that also has the
/// property of a deterministic iteration order. The order of iteration is the
@@ -52,10 +52,10 @@
using const_reverse_iterator = typename vector_type::const_reverse_iterator;
using size_type = typename vector_type::size_type;
- /// \brief Construct an empty SetVector
+ /// Construct an empty SetVector
SetVector() = default;
- /// \brief Initialize a SetVector with a range of elements
+ /// Initialize a SetVector with a range of elements
template<typename It>
SetVector(It Start, It End) {
insert(Start, End);
@@ -69,75 +69,75 @@
return std::move(vector_);
}
- /// \brief Determine if the SetVector is empty or not.
+ /// Determine if the SetVector is empty or not.
bool empty() const {
return vector_.empty();
}
- /// \brief Determine the number of elements in the SetVector.
+ /// Determine the number of elements in the SetVector.
size_type size() const {
return vector_.size();
}
- /// \brief Get an iterator to the beginning of the SetVector.
+ /// Get an iterator to the beginning of the SetVector.
iterator begin() {
return vector_.begin();
}
- /// \brief Get a const_iterator to the beginning of the SetVector.
+ /// Get a const_iterator to the beginning of the SetVector.
const_iterator begin() const {
return vector_.begin();
}
- /// \brief Get an iterator to the end of the SetVector.
+ /// Get an iterator to the end of the SetVector.
iterator end() {
return vector_.end();
}
- /// \brief Get a const_iterator to the end of the SetVector.
+ /// Get a const_iterator to the end of the SetVector.
const_iterator end() const {
return vector_.end();
}
- /// \brief Get an reverse_iterator to the end of the SetVector.
+ /// Get an reverse_iterator to the end of the SetVector.
reverse_iterator rbegin() {
return vector_.rbegin();
}
- /// \brief Get a const_reverse_iterator to the end of the SetVector.
+ /// Get a const_reverse_iterator to the end of the SetVector.
const_reverse_iterator rbegin() const {
return vector_.rbegin();
}
- /// \brief Get a reverse_iterator to the beginning of the SetVector.
+ /// Get a reverse_iterator to the beginning of the SetVector.
reverse_iterator rend() {
return vector_.rend();
}
- /// \brief Get a const_reverse_iterator to the beginning of the SetVector.
+ /// Get a const_reverse_iterator to the beginning of the SetVector.
const_reverse_iterator rend() const {
return vector_.rend();
}
- /// \brief Return the first element of the SetVector.
+ /// Return the first element of the SetVector.
const T &front() const {
assert(!empty() && "Cannot call front() on empty SetVector!");
return vector_.front();
}
- /// \brief Return the last element of the SetVector.
+ /// Return the last element of the SetVector.
const T &back() const {
assert(!empty() && "Cannot call back() on empty SetVector!");
return vector_.back();
}
- /// \brief Index into the SetVector.
+ /// Index into the SetVector.
const_reference operator[](size_type n) const {
assert(n < vector_.size() && "SetVector access out of range!");
return vector_[n];
}
- /// \brief Insert a new element into the SetVector.
+ /// Insert a new element into the SetVector.
/// \returns true if the element was inserted into the SetVector.
bool insert(const value_type &X) {
bool result = set_.insert(X).second;
@@ -146,7 +146,7 @@
return result;
}
- /// \brief Insert a range of elements into the SetVector.
+ /// Insert a range of elements into the SetVector.
template<typename It>
void insert(It Start, It End) {
for (; Start != End; ++Start)
@@ -154,7 +154,7 @@
vector_.push_back(*Start);
}
- /// \brief Remove an item from the set vector.
+ /// Remove an item from the set vector.
bool remove(const value_type& X) {
if (set_.erase(X)) {
typename vector_type::iterator I = find(vector_, X);
@@ -183,7 +183,7 @@
return vector_.erase(NI);
}
- /// \brief Remove items from the set vector based on a predicate function.
+ /// Remove items from the set vector based on a predicate function.
///
/// This is intended to be equivalent to the following code, if we could
/// write it:
@@ -206,19 +206,19 @@
return true;
}
- /// \brief Count the number of elements of a given key in the SetVector.
+ /// Count the number of elements of a given key in the SetVector.
/// \returns 0 if the element is not in the SetVector, 1 if it is.
size_type count(const key_type &key) const {
return set_.count(key);
}
- /// \brief Completely clear the SetVector
+ /// Completely clear the SetVector
void clear() {
set_.clear();
vector_.clear();
}
- /// \brief Remove the last element of the SetVector.
+ /// Remove the last element of the SetVector.
void pop_back() {
assert(!empty() && "Cannot remove an element from an empty SetVector!");
set_.erase(back());
@@ -239,7 +239,7 @@
return vector_ != that.vector_;
}
- /// \brief Compute This := This u S, return whether 'This' changed.
+ /// Compute This := This u S, return whether 'This' changed.
/// TODO: We should be able to use set_union from SetOperations.h, but
/// SetVector interface is inconsistent with DenseSet.
template <class STy>
@@ -254,7 +254,7 @@
return Changed;
}
- /// \brief Compute This := This - B
+ /// Compute This := This - B
/// TODO: We should be able to use set_subtract from SetOperations.h, but
/// SetVector interface is inconsistent with DenseSet.
template <class STy>
@@ -265,7 +265,7 @@
}
private:
- /// \brief A wrapper predicate designed for use with std::remove_if.
+ /// A wrapper predicate designed for use with std::remove_if.
///
/// This predicate wraps a predicate suitable for use with std::remove_if to
/// call set_.erase(x) on each element which is slated for removal.
@@ -292,7 +292,7 @@
vector_type vector_; ///< The vector.
};
-/// \brief A SetVector that performs no allocations if smaller than
+/// A SetVector that performs no allocations if smaller than
/// a certain size.
template <typename T, unsigned N>
class SmallSetVector
@@ -300,7 +300,7 @@
public:
SmallSetVector() = default;
- /// \brief Initialize a SmallSetVector with a range of elements
+ /// Initialize a SmallSetVector with a range of elements
template<typename It>
SmallSetVector(It Start, It End) {
this->insert(Start, End);
diff --git a/linux-x64/clang/include/llvm/ADT/SmallPtrSet.h b/linux-x64/clang/include/llvm/ADT/SmallPtrSet.h
index 78ea613..db08e40 100644
--- a/linux-x64/clang/include/llvm/ADT/SmallPtrSet.h
+++ b/linux-x64/clang/include/llvm/ADT/SmallPtrSet.h
@@ -335,7 +335,7 @@
enum { Val = RoundUpToPowerOfTwoH<N, (N&(N-1)) == 0>::Val };
};
-/// \brief A templated base class for \c SmallPtrSet which provides the
+/// A templated base class for \c SmallPtrSet which provides the
/// typesafe interface that is common across all small sizes.
///
/// This is particularly useful for passing around between interface boundaries
diff --git a/linux-x64/clang/include/llvm/ADT/SmallSet.h b/linux-x64/clang/include/llvm/ADT/SmallSet.h
index d52d0f0..5d84627 100644
--- a/linux-x64/clang/include/llvm/ADT/SmallSet.h
+++ b/linux-x64/clang/include/llvm/ADT/SmallSet.h
@@ -17,21 +17,120 @@
#include "llvm/ADT/None.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/type_traits.h"
#include <cstddef>
#include <functional>
#include <set>
+#include <type_traits>
#include <utility>
namespace llvm {
+/// SmallSetIterator - This class implements a const_iterator for SmallSet by
+/// delegating to the underlying SmallVector or Set iterators.
+template <typename T, unsigned N, typename C>
+class SmallSetIterator
+ : public iterator_facade_base<SmallSetIterator<T, N, C>,
+ std::forward_iterator_tag, T> {
+private:
+ using SetIterTy = typename std::set<T, C>::const_iterator;
+ using VecIterTy = typename SmallVector<T, N>::const_iterator;
+ using SelfTy = SmallSetIterator<T, N, C>;
+
+ /// Iterators to the parts of the SmallSet containing the data. They are set
+ /// depending on isSmall.
+ union {
+ SetIterTy SetIter;
+ VecIterTy VecIter;
+ };
+
+ bool isSmall;
+
+public:
+ SmallSetIterator(SetIterTy SetIter) : SetIter(SetIter), isSmall(false) {}
+
+ SmallSetIterator(VecIterTy VecIter) : VecIter(VecIter), isSmall(true) {}
+
+ // Spell out destructor, copy/move constructor and assignment operators for
+ // MSVC STL, where set<T>::const_iterator is not trivially copy constructible.
+ ~SmallSetIterator() {
+ if (isSmall)
+ VecIter.~VecIterTy();
+ else
+ SetIter.~SetIterTy();
+ }
+
+ SmallSetIterator(const SmallSetIterator &Other) : isSmall(Other.isSmall) {
+ if (isSmall)
+ VecIter = Other.VecIter;
+ else
+ // Use placement new, to make sure SetIter is properly constructed, even
+ // if it is not trivially copy-able (e.g. in MSVC).
+ new (&SetIter) SetIterTy(Other.SetIter);
+ }
+
+ SmallSetIterator(SmallSetIterator &&Other) : isSmall(Other.isSmall) {
+ if (isSmall)
+ VecIter = std::move(Other.VecIter);
+ else
+ // Use placement new, to make sure SetIter is properly constructed, even
+ // if it is not trivially copy-able (e.g. in MSVC).
+ new (&SetIter) SetIterTy(std::move(Other.SetIter));
+ }
+
+ SmallSetIterator& operator=(const SmallSetIterator& Other) {
+ // Call destructor for SetIter, so it gets properly destroyed if it is
+ // not trivially destructible in case we are setting VecIter.
+ if (!isSmall)
+ SetIter.~SetIterTy();
+
+ isSmall = Other.isSmall;
+ if (isSmall)
+ VecIter = Other.VecIter;
+ else
+ new (&SetIter) SetIterTy(Other.SetIter);
+ return *this;
+ }
+
+ SmallSetIterator& operator=(SmallSetIterator&& Other) {
+ // Call destructor for SetIter, so it gets properly destroyed if it is
+ // not trivially destructible in case we are setting VecIter.
+ if (!isSmall)
+ SetIter.~SetIterTy();
+
+ isSmall = Other.isSmall;
+ if (isSmall)
+ VecIter = std::move(Other.VecIter);
+ else
+ new (&SetIter) SetIterTy(std::move(Other.SetIter));
+ return *this;
+ }
+
+ bool operator==(const SmallSetIterator &RHS) const {
+ if (isSmall != RHS.isSmall)
+ return false;
+ if (isSmall)
+ return VecIter == RHS.VecIter;
+ return SetIter == RHS.SetIter;
+ }
+
+ SmallSetIterator &operator++() { // Preincrement
+ if (isSmall)
+ VecIter++;
+ else
+ SetIter++;
+ return *this;
+ }
+
+ const T &operator*() const { return isSmall ? *VecIter : *SetIter; }
+};
+
/// SmallSet - This maintains a set of unique values, optimizing for the case
/// when the set is small (less than N). In this case, the set can be
/// maintained with no mallocs. If the set gets large, we expand to using an
/// std::set to maintain reasonable lookup times.
-///
-/// Note that this set does not provide a way to iterate over members in the
-/// set.
template <typename T, unsigned N, typename C = std::less<T>>
class SmallSet {
/// Use a SmallVector to hold the elements here (even though it will never
@@ -50,6 +149,7 @@
public:
using size_type = size_t;
+ using const_iterator = SmallSetIterator<T, N, C>;
SmallSet() = default;
@@ -121,6 +221,18 @@
Set.clear();
}
+ const_iterator begin() const {
+ if (isSmall())
+ return {Vector.begin()};
+ return {Set.begin()};
+ }
+
+ const_iterator end() const {
+ if (isSmall())
+ return {Vector.end()};
+ return {Set.end()};
+ }
+
private:
bool isSmall() const { return Set.empty(); }
diff --git a/linux-x64/clang/include/llvm/ADT/SmallVector.h b/linux-x64/clang/include/llvm/ADT/SmallVector.h
index 3d17e70..e4ddd12 100644
--- a/linux-x64/clang/include/llvm/ADT/SmallVector.h
+++ b/linux-x64/clang/include/llvm/ADT/SmallVector.h
@@ -18,6 +18,7 @@
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/MemAlloc.h"
#include "llvm/Support/type_traits.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@@ -37,28 +38,42 @@
/// This is all the non-templated stuff common to all SmallVectors.
class SmallVectorBase {
protected:
- void *BeginX, *EndX, *CapacityX;
+ void *BeginX;
+ unsigned Size = 0, Capacity;
-protected:
- SmallVectorBase(void *FirstEl, size_t Size)
- : BeginX(FirstEl), EndX(FirstEl), CapacityX((char*)FirstEl+Size) {}
+ SmallVectorBase() = delete;
+ SmallVectorBase(void *FirstEl, size_t Capacity)
+ : BeginX(FirstEl), Capacity(Capacity) {}
/// This is an implementation of the grow() method which only works
/// on POD-like data types and is out of line to reduce code duplication.
- void grow_pod(void *FirstEl, size_t MinSizeInBytes, size_t TSize);
+ void grow_pod(void *FirstEl, size_t MinCapacity, size_t TSize);
public:
- /// This returns size()*sizeof(T).
- size_t size_in_bytes() const {
- return size_t((char*)EndX - (char*)BeginX);
- }
+ size_t size() const { return Size; }
+ size_t capacity() const { return Capacity; }
- /// capacity_in_bytes - This returns capacity()*sizeof(T).
- size_t capacity_in_bytes() const {
- return size_t((char*)CapacityX - (char*)BeginX);
- }
+ LLVM_NODISCARD bool empty() const { return !Size; }
- LLVM_NODISCARD bool empty() const { return BeginX == EndX; }
+ /// Set the array size to \p N, which the current array must have enough
+ /// capacity for.
+ ///
+ /// This does not construct or destroy any elements in the vector.
+ ///
+ /// Clients can use this in conjunction with capacity() to write past the end
+ /// of the buffer when they know that more elements are available, and only
+ /// update the size later. This avoids the cost of value initializing elements
+ /// which will only be overwritten.
+ void set_size(size_t Size) {
+ assert(Size <= capacity());
+ this->Size = Size;
+ }
+};
+
+/// Figure out the offset of the first element.
+template <class T, typename = void> struct SmallVectorAlignmentAndSize {
+ AlignedCharArrayUnion<SmallVectorBase> Base;
+ AlignedCharArrayUnion<T> FirstEl;
};
/// This is the part of SmallVectorTemplateBase which does not depend on whether
@@ -66,36 +81,34 @@
/// to avoid unnecessarily requiring T to be complete.
template <typename T, typename = void>
class SmallVectorTemplateCommon : public SmallVectorBase {
-private:
- template <typename, unsigned> friend struct SmallVectorStorage;
-
- // Allocate raw space for N elements of type T. If T has a ctor or dtor, we
- // don't want it to be automatically run, so we need to represent the space as
- // something else. Use an array of char of sufficient alignment.
- using U = AlignedCharArrayUnion<T>;
- U FirstEl;
+ /// Find the address of the first element. For this pointer math to be valid
+ /// with small-size of 0 for T with lots of alignment, it's important that
+ /// SmallVectorStorage is properly-aligned even for small-size of 0.
+ void *getFirstEl() const {
+ return const_cast<void *>(reinterpret_cast<const void *>(
+ reinterpret_cast<const char *>(this) +
+ offsetof(SmallVectorAlignmentAndSize<T>, FirstEl)));
+ }
// Space after 'FirstEl' is clobbered, do not add any instance vars after it.
protected:
- SmallVectorTemplateCommon(size_t Size) : SmallVectorBase(&FirstEl, Size) {}
+ SmallVectorTemplateCommon(size_t Size)
+ : SmallVectorBase(getFirstEl(), Size) {}
- void grow_pod(size_t MinSizeInBytes, size_t TSize) {
- SmallVectorBase::grow_pod(&FirstEl, MinSizeInBytes, TSize);
+ void grow_pod(size_t MinCapacity, size_t TSize) {
+ SmallVectorBase::grow_pod(getFirstEl(), MinCapacity, TSize);
}
/// Return true if this is a smallvector which has not had dynamic
/// memory allocated for it.
- bool isSmall() const {
- return BeginX == static_cast<const void*>(&FirstEl);
- }
+ bool isSmall() const { return BeginX == getFirstEl(); }
/// Put this vector in a state of being small.
void resetToSmall() {
- BeginX = EndX = CapacityX = &FirstEl;
+ BeginX = getFirstEl();
+ Size = Capacity = 0; // FIXME: Setting Capacity to 0 is suspect.
}
- void setEnd(T *P) { this->EndX = P; }
-
public:
using size_type = size_t;
using difference_type = ptrdiff_t;
@@ -117,27 +130,20 @@
LLVM_ATTRIBUTE_ALWAYS_INLINE
const_iterator begin() const { return (const_iterator)this->BeginX; }
LLVM_ATTRIBUTE_ALWAYS_INLINE
- iterator end() { return (iterator)this->EndX; }
+ iterator end() { return begin() + size(); }
LLVM_ATTRIBUTE_ALWAYS_INLINE
- const_iterator end() const { return (const_iterator)this->EndX; }
+ const_iterator end() const { return begin() + size(); }
-protected:
- iterator capacity_ptr() { return (iterator)this->CapacityX; }
- const_iterator capacity_ptr() const { return (const_iterator)this->CapacityX;}
-
-public:
// reverse iterator creation methods.
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin());}
- LLVM_ATTRIBUTE_ALWAYS_INLINE
- size_type size() const { return end()-begin(); }
+ size_type size_in_bytes() const { return size() * sizeof(T); }
size_type max_size() const { return size_type(-1) / sizeof(T); }
- /// Return the total number of elements in the currently allocated buffer.
- size_t capacity() const { return capacity_ptr() - begin(); }
+ size_t capacity_in_bytes() const { return capacity() * sizeof(T); }
/// Return a pointer to the vector's buffer, even if empty().
pointer data() { return pointer(begin()); }
@@ -210,21 +216,21 @@
public:
void push_back(const T &Elt) {
- if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
+ if (LLVM_UNLIKELY(this->size() >= this->capacity()))
this->grow();
::new ((void*) this->end()) T(Elt);
- this->setEnd(this->end()+1);
+ this->set_size(this->size() + 1);
}
void push_back(T &&Elt) {
- if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
+ if (LLVM_UNLIKELY(this->size() >= this->capacity()))
this->grow();
::new ((void*) this->end()) T(::std::move(Elt));
- this->setEnd(this->end()+1);
+ this->set_size(this->size() + 1);
}
void pop_back() {
- this->setEnd(this->end()-1);
+ this->set_size(this->size() - 1);
this->end()->~T();
}
};
@@ -232,15 +238,13 @@
// Define this out-of-line to dissuade the C++ compiler from inlining it.
template <typename T, bool isPodLike>
void SmallVectorTemplateBase<T, isPodLike>::grow(size_t MinSize) {
- size_t CurCapacity = this->capacity();
- size_t CurSize = this->size();
+ if (MinSize > UINT32_MAX)
+ report_bad_alloc_error("SmallVector capacity overflow during allocation");
+
// Always grow, even from zero.
- size_t NewCapacity = size_t(NextPowerOf2(CurCapacity+2));
- if (NewCapacity < MinSize)
- NewCapacity = MinSize;
- T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T)));
- if (NewElts == nullptr)
- report_bad_alloc_error("Allocation of SmallVector element failed.");
+ size_t NewCapacity = size_t(NextPowerOf2(this->capacity() + 2));
+ NewCapacity = std::min(std::max(NewCapacity, MinSize), size_t(UINT32_MAX));
+ T *NewElts = static_cast<T*>(llvm::safe_malloc(NewCapacity*sizeof(T)));
// Move the elements over.
this->uninitialized_move(this->begin(), this->end(), NewElts);
@@ -252,9 +256,8 @@
if (!this->isSmall())
free(this->begin());
- this->setEnd(NewElts+CurSize);
this->BeginX = NewElts;
- this->CapacityX = this->begin()+NewCapacity;
+ this->Capacity = NewCapacity;
}
@@ -296,26 +299,22 @@
// use memcpy here. Note that I and E are iterators and thus might be
// invalid for memcpy if they are equal.
if (I != E)
- memcpy(Dest, I, (E - I) * sizeof(T));
+ memcpy(reinterpret_cast<void *>(Dest), I, (E - I) * sizeof(T));
}
/// Double the size of the allocated memory, guaranteeing space for at
/// least one more element or MinSize if specified.
- void grow(size_t MinSize = 0) {
- this->grow_pod(MinSize*sizeof(T), sizeof(T));
- }
+ void grow(size_t MinSize = 0) { this->grow_pod(MinSize, sizeof(T)); }
public:
void push_back(const T &Elt) {
- if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
+ if (LLVM_UNLIKELY(this->size() >= this->capacity()))
this->grow();
- memcpy(this->end(), &Elt, sizeof(T));
- this->setEnd(this->end()+1);
+ memcpy(reinterpret_cast<void *>(this->end()), &Elt, sizeof(T));
+ this->set_size(this->size() + 1);
}
- void pop_back() {
- this->setEnd(this->end()-1);
- }
+ void pop_back() { this->set_size(this->size() - 1); }
};
/// This class consists of common code factored out of the SmallVector class to
@@ -332,8 +331,7 @@
protected:
// Default ctor - Initialize to empty.
explicit SmallVectorImpl(unsigned N)
- : SmallVectorTemplateBase<T, isPodLike<T>::value>(N*sizeof(T)) {
- }
+ : SmallVectorTemplateBase<T, isPodLike<T>::value>(N) {}
public:
SmallVectorImpl(const SmallVectorImpl &) = delete;
@@ -347,31 +345,31 @@
void clear() {
this->destroy_range(this->begin(), this->end());
- this->EndX = this->BeginX;
+ this->Size = 0;
}
void resize(size_type N) {
if (N < this->size()) {
this->destroy_range(this->begin()+N, this->end());
- this->setEnd(this->begin()+N);
+ this->set_size(N);
} else if (N > this->size()) {
if (this->capacity() < N)
this->grow(N);
for (auto I = this->end(), E = this->begin() + N; I != E; ++I)
new (&*I) T();
- this->setEnd(this->begin()+N);
+ this->set_size(N);
}
}
void resize(size_type N, const T &NV) {
if (N < this->size()) {
this->destroy_range(this->begin()+N, this->end());
- this->setEnd(this->begin()+N);
+ this->set_size(N);
} else if (N > this->size()) {
if (this->capacity() < N)
this->grow(N);
std::uninitialized_fill(this->end(), this->begin()+N, NV);
- this->setEnd(this->begin()+N);
+ this->set_size(N);
}
}
@@ -396,23 +394,23 @@
void append(in_iter in_start, in_iter in_end) {
size_type NumInputs = std::distance(in_start, in_end);
// Grow allocated space if needed.
- if (NumInputs > size_type(this->capacity_ptr()-this->end()))
+ if (NumInputs > this->capacity() - this->size())
this->grow(this->size()+NumInputs);
// Copy the new elements over.
this->uninitialized_copy(in_start, in_end, this->end());
- this->setEnd(this->end() + NumInputs);
+ this->set_size(this->size() + NumInputs);
}
/// Add the specified range to the end of the SmallVector.
void append(size_type NumInputs, const T &Elt) {
// Grow allocated space if needed.
- if (NumInputs > size_type(this->capacity_ptr()-this->end()))
+ if (NumInputs > this->capacity() - this->size())
this->grow(this->size()+NumInputs);
// Copy the new elements over.
std::uninitialized_fill_n(this->end(), NumInputs, Elt);
- this->setEnd(this->end() + NumInputs);
+ this->set_size(this->size() + NumInputs);
}
void append(std::initializer_list<T> IL) {
@@ -426,7 +424,7 @@
clear();
if (this->capacity() < NumElts)
this->grow(NumElts);
- this->setEnd(this->begin()+NumElts);
+ this->set_size(NumElts);
std::uninitialized_fill(this->begin(), this->end(), Elt);
}
@@ -473,7 +471,7 @@
iterator I = std::move(E, this->end(), S);
// Drop the last elts.
this->destroy_range(I, this->end());
- this->setEnd(I);
+ this->set_size(I - this->begin());
return(N);
}
@@ -486,7 +484,7 @@
assert(I >= this->begin() && "Insertion iterator is out of bounds.");
assert(I <= this->end() && "Inserting past the end of the vector.");
- if (this->EndX >= this->CapacityX) {
+ if (this->size() >= this->capacity()) {
size_t EltNo = I-this->begin();
this->grow();
I = this->begin()+EltNo;
@@ -495,12 +493,12 @@
::new ((void*) this->end()) T(::std::move(this->back()));
// Push everything else over.
std::move_backward(I, this->end()-1, this->end());
- this->setEnd(this->end()+1);
+ this->set_size(this->size() + 1);
// If we just moved the element we're inserting, be sure to update
// the reference.
T *EltPtr = &Elt;
- if (I <= EltPtr && EltPtr < this->EndX)
+ if (I <= EltPtr && EltPtr < this->end())
++EltPtr;
*I = ::std::move(*EltPtr);
@@ -516,7 +514,7 @@
assert(I >= this->begin() && "Insertion iterator is out of bounds.");
assert(I <= this->end() && "Inserting past the end of the vector.");
- if (this->EndX >= this->CapacityX) {
+ if (this->size() >= this->capacity()) {
size_t EltNo = I-this->begin();
this->grow();
I = this->begin()+EltNo;
@@ -524,12 +522,12 @@
::new ((void*) this->end()) T(std::move(this->back()));
// Push everything else over.
std::move_backward(I, this->end()-1, this->end());
- this->setEnd(this->end()+1);
+ this->set_size(this->size() + 1);
// If we just moved the element we're inserting, be sure to update
// the reference.
const T *EltPtr = &Elt;
- if (I <= EltPtr && EltPtr < this->EndX)
+ if (I <= EltPtr && EltPtr < this->end())
++EltPtr;
*I = *EltPtr;
@@ -575,7 +573,7 @@
// Move over the elements that we're about to overwrite.
T *OldEnd = this->end();
- this->setEnd(this->end() + NumToInsert);
+ this->set_size(this->size() + NumToInsert);
size_t NumOverwritten = OldEnd-I;
this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
@@ -632,7 +630,7 @@
// Move over the elements that we're about to overwrite.
T *OldEnd = this->end();
- this->setEnd(this->end() + NumToInsert);
+ this->set_size(this->size() + NumToInsert);
size_t NumOverwritten = OldEnd-I;
this->uninitialized_move(I, OldEnd, this->end()-NumOverwritten);
@@ -652,10 +650,10 @@
}
template <typename... ArgTypes> void emplace_back(ArgTypes &&... Args) {
- if (LLVM_UNLIKELY(this->EndX >= this->CapacityX))
+ if (LLVM_UNLIKELY(this->size() >= this->capacity()))
this->grow();
::new ((void *)this->end()) T(std::forward<ArgTypes>(Args)...);
- this->setEnd(this->end() + 1);
+ this->set_size(this->size() + 1);
}
SmallVectorImpl &operator=(const SmallVectorImpl &RHS);
@@ -674,20 +672,6 @@
return std::lexicographical_compare(this->begin(), this->end(),
RHS.begin(), RHS.end());
}
-
- /// Set the array size to \p N, which the current array must have enough
- /// capacity for.
- ///
- /// This does not construct or destroy any elements in the vector.
- ///
- /// Clients can use this in conjunction with capacity() to write past the end
- /// of the buffer when they know that more elements are available, and only
- /// update the size later. This avoids the cost of value initializing elements
- /// which will only be overwritten.
- void set_size(size_type N) {
- assert(N <= this->capacity());
- this->setEnd(this->begin() + N);
- }
};
template <typename T>
@@ -697,8 +681,8 @@
// We can only avoid copying elements if neither vector is small.
if (!this->isSmall() && !RHS.isSmall()) {
std::swap(this->BeginX, RHS.BeginX);
- std::swap(this->EndX, RHS.EndX);
- std::swap(this->CapacityX, RHS.CapacityX);
+ std::swap(this->Size, RHS.Size);
+ std::swap(this->Capacity, RHS.Capacity);
return;
}
if (RHS.size() > this->capacity())
@@ -716,15 +700,15 @@
if (this->size() > RHS.size()) {
size_t EltDiff = this->size() - RHS.size();
this->uninitialized_copy(this->begin()+NumShared, this->end(), RHS.end());
- RHS.setEnd(RHS.end()+EltDiff);
+ RHS.set_size(RHS.size() + EltDiff);
this->destroy_range(this->begin()+NumShared, this->end());
- this->setEnd(this->begin()+NumShared);
+ this->set_size(NumShared);
} else if (RHS.size() > this->size()) {
size_t EltDiff = RHS.size() - this->size();
this->uninitialized_copy(RHS.begin()+NumShared, RHS.end(), this->end());
- this->setEnd(this->end() + EltDiff);
+ this->set_size(this->size() + EltDiff);
this->destroy_range(RHS.begin()+NumShared, RHS.end());
- RHS.setEnd(RHS.begin()+NumShared);
+ RHS.set_size(NumShared);
}
}
@@ -750,7 +734,7 @@
this->destroy_range(NewEnd, this->end());
// Trim.
- this->setEnd(NewEnd);
+ this->set_size(RHSSize);
return *this;
}
@@ -760,7 +744,7 @@
if (this->capacity() < RHSSize) {
// Destroy current elements.
this->destroy_range(this->begin(), this->end());
- this->setEnd(this->begin());
+ this->set_size(0);
CurSize = 0;
this->grow(RHSSize);
} else if (CurSize) {
@@ -773,7 +757,7 @@
this->begin()+CurSize);
// Set end.
- this->setEnd(this->begin()+RHSSize);
+ this->set_size(RHSSize);
return *this;
}
@@ -787,8 +771,8 @@
this->destroy_range(this->begin(), this->end());
if (!this->isSmall()) free(this->begin());
this->BeginX = RHS.BeginX;
- this->EndX = RHS.EndX;
- this->CapacityX = RHS.CapacityX;
+ this->Size = RHS.Size;
+ this->Capacity = RHS.Capacity;
RHS.resetToSmall();
return *this;
}
@@ -805,7 +789,7 @@
// Destroy excess elements and trim the bounds.
this->destroy_range(NewEnd, this->end());
- this->setEnd(NewEnd);
+ this->set_size(RHSSize);
// Clear the RHS.
RHS.clear();
@@ -820,7 +804,7 @@
if (this->capacity() < RHSSize) {
// Destroy current elements.
this->destroy_range(this->begin(), this->end());
- this->setEnd(this->begin());
+ this->set_size(0);
CurSize = 0;
this->grow(RHSSize);
} else if (CurSize) {
@@ -833,22 +817,23 @@
this->begin()+CurSize);
// Set end.
- this->setEnd(this->begin()+RHSSize);
+ this->set_size(RHSSize);
RHS.clear();
return *this;
}
-/// Storage for the SmallVector elements which aren't contained in
-/// SmallVectorTemplateCommon. There are 'N-1' elements here. The remaining '1'
-/// element is in the base class. This is specialized for the N=1 and N=0 cases
+/// Storage for the SmallVector elements. This is specialized for the N=0 case
/// to avoid allocating unnecessary storage.
template <typename T, unsigned N>
struct SmallVectorStorage {
- typename SmallVectorTemplateCommon<T>::U InlineElts[N - 1];
+ AlignedCharArrayUnion<T> InlineElts[N];
};
-template <typename T> struct SmallVectorStorage<T, 1> {};
-template <typename T> struct SmallVectorStorage<T, 0> {};
+
+/// We need the storage to be properly aligned even for small-size of 0 so that
+/// the pointer math in \a SmallVectorTemplateCommon::getFirstEl() is
+/// well-defined.
+template <typename T> struct alignas(alignof(T)) SmallVectorStorage<T, 0> {};
/// This is a 'vector' (really, a variable-sized array), optimized
/// for the case when the array is small. It contains some number of elements
@@ -859,10 +844,7 @@
/// Note that this does not attempt to be exception safe.
///
template <typename T, unsigned N>
-class SmallVector : public SmallVectorImpl<T> {
- /// Inline space for elements which aren't stored in the base class.
- SmallVectorStorage<T, N> Storage;
-
+class SmallVector : public SmallVectorImpl<T>, SmallVectorStorage<T, N> {
public:
SmallVector() : SmallVectorImpl<T>(N) {}
diff --git a/linux-x64/clang/include/llvm/ADT/Statistic.h b/linux-x64/clang/include/llvm/ADT/Statistic.h
index 3a08997..90c2eef 100644
--- a/linux-x64/clang/include/llvm/ADT/Statistic.h
+++ b/linux-x64/clang/include/llvm/ADT/Statistic.h
@@ -169,19 +169,19 @@
#define STATISTIC(VARNAME, DESC) \
static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, {false}}
-/// \brief Enable the collection and printing of statistics.
+/// Enable the collection and printing of statistics.
void EnableStatistics(bool PrintOnExit = true);
-/// \brief Check if statistics are enabled.
+/// Check if statistics are enabled.
bool AreStatisticsEnabled();
-/// \brief Return a file stream to print our output on.
+/// Return a file stream to print our output on.
std::unique_ptr<raw_fd_ostream> CreateInfoOutputFile();
-/// \brief Print statistics to the file returned by CreateInfoOutputFile().
+/// Print statistics to the file returned by CreateInfoOutputFile().
void PrintStatistics();
-/// \brief Print statistics to the given output stream.
+/// Print statistics to the given output stream.
void PrintStatistics(raw_ostream &OS);
/// Print statistics in JSON format. This does include all global timers (\see
@@ -190,7 +190,7 @@
/// PrintStatisticsJSON().
void PrintStatisticsJSON(raw_ostream &OS);
-/// \brief Get the statistics. This can be used to look up the value of
+/// Get the statistics. This can be used to look up the value of
/// statistics without needing to parse JSON.
///
/// This function does not prevent statistics being updated by other threads
@@ -199,7 +199,7 @@
/// completes.
const std::vector<std::pair<StringRef, unsigned>> GetStatistics();
-/// \brief Reset the statistics. This can be used to zero and de-register the
+/// Reset the statistics. This can be used to zero and de-register the
/// statistics in order to measure a compilation.
///
/// When this function begins to call destructors prior to returning, all
diff --git a/linux-x64/clang/include/llvm/ADT/StringExtras.h b/linux-x64/clang/include/llvm/ADT/StringExtras.h
index 45f6677..71b0e75 100644
--- a/linux-x64/clang/include/llvm/ADT/StringExtras.h
+++ b/linux-x64/clang/include/llvm/ADT/StringExtras.h
@@ -39,6 +39,16 @@
return X < 10 ? '0' + X : HexChar + X - 10;
}
+/// Given an array of c-style strings terminated by a null pointer, construct
+/// a vector of StringRefs representing the same strings without the terminating
+/// null string.
+inline std::vector<StringRef> toStringRefArray(const char *const *Strings) {
+ std::vector<StringRef> Result;
+ while (*Strings)
+ Result.push_back(*Strings++);
+ return Result;
+}
+
/// Construct a string ref from a boolean.
inline StringRef toStringRef(bool B) { return StringRef(B ? "true" : "false"); }
@@ -78,6 +88,26 @@
/// lowercase letter as classified by "C" locale.
inline bool isAlnum(char C) { return isAlpha(C) || isDigit(C); }
+/// Checks whether character \p C is valid ASCII (high bit is zero).
+inline bool isASCII(char C) { return static_cast<unsigned char>(C) <= 127; }
+
+/// Checks whether all characters in S are ASCII.
+inline bool isASCII(llvm::StringRef S) {
+ for (char C : S)
+ if (LLVM_UNLIKELY(!isASCII(C)))
+ return false;
+ return true;
+}
+
+/// Checks whether character \p C is printable.
+///
+/// Locale-independent version of the C standard library isprint whose results
+/// may differ on different platforms.
+inline bool isPrint(char C) {
+ unsigned char UC = static_cast<unsigned char>(C);
+ return (0x20 <= UC) && (UC <= 0x7E);
+}
+
/// Returns the corresponding lowercase character if \p x is uppercase.
inline char toLower(char x) {
if (x >= 'A' && x <= 'Z')
@@ -157,7 +187,7 @@
return Output;
}
-/// \brief Convert the string \p S to an integer of the specified type using
+/// Convert the string \p S to an integer of the specified type using
/// the radix \p Base. If \p Base is 0, auto-detects the radix.
/// Returns true if the number was successfully converted, false otherwise.
template <typename N> bool to_integer(StringRef S, N &Num, unsigned Base = 0) {
@@ -251,9 +281,13 @@
}
}
-/// PrintEscapedString - Print each character of the specified string, escaping
-/// it if it is not printable or if it is an escape char.
-void PrintEscapedString(StringRef Name, raw_ostream &Out);
+/// Print each character of the specified string, escaping it if it is not
+/// printable or if it is an escape char.
+void printEscapedString(StringRef Name, raw_ostream &Out);
+
+/// Print each character of the specified string, escaping HTML special
+/// characters.
+void printHTMLEscaped(StringRef String, raw_ostream &Out);
/// printLowerCase - Print each character as lowercase if it is uppercase.
void printLowerCase(StringRef String, raw_ostream &Out);
diff --git a/linux-x64/clang/include/llvm/ADT/StringMap.h b/linux-x64/clang/include/llvm/ADT/StringMap.h
index d34d5ed..a9f83d3 100644
--- a/linux-x64/clang/include/llvm/ADT/StringMap.h
+++ b/linux-x64/clang/include/llvm/ADT/StringMap.h
@@ -164,9 +164,7 @@
StringMapEntry *NewItem =
static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));
-
- if (NewItem == nullptr)
- report_bad_alloc_error("Allocation of StringMap entry failed.");
+ assert(NewItem && "Unhandled out-of-memory");
// Construct the value.
new (NewItem) StringMapEntry(KeyLength, std::forward<InitTy>(InitVals)...);
diff --git a/linux-x64/clang/include/llvm/ADT/StringRef.h b/linux-x64/clang/include/llvm/ADT/StringRef.h
index 3d2417a..a5ba5b5 100644
--- a/linux-x64/clang/include/llvm/ADT/StringRef.h
+++ b/linux-x64/clang/include/llvm/ADT/StringRef.h
@@ -201,7 +201,7 @@
LLVM_NODISCARD
int compare_numeric(StringRef RHS) const;
- /// \brief Determine the edit distance between this string and another
+ /// Determine the edit distance between this string and another
/// string.
///
/// \param Other the string to compare this string against.
@@ -725,10 +725,7 @@
/// \returns The split substrings.
LLVM_NODISCARD
std::pair<StringRef, StringRef> split(char Separator) const {
- size_t Idx = find(Separator);
- if (Idx == npos)
- return std::make_pair(*this, StringRef());
- return std::make_pair(slice(0, Idx), slice(Idx+1, npos));
+ return split(StringRef(&Separator, 1));
}
/// Split into two substrings around the first occurrence of a separator
@@ -749,6 +746,24 @@
return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
}
+ /// Split into two substrings around the last occurrence of a separator
+ /// string.
+ ///
+ /// If \p Separator is in the string, then the result is a pair (LHS, RHS)
+ /// such that (*this == LHS + Separator + RHS) is true and RHS is
+ /// minimal. If \p Separator is not in the string, then the result is a
+ /// pair (LHS, RHS) where (*this == LHS) and (RHS == "").
+ ///
+ /// \param Separator - The string to split on.
+ /// \return - The split substrings.
+ LLVM_NODISCARD
+ std::pair<StringRef, StringRef> rsplit(StringRef Separator) const {
+ size_t Idx = rfind(Separator);
+ if (Idx == npos)
+ return std::make_pair(*this, StringRef());
+ return std::make_pair(slice(0, Idx), slice(Idx + Separator.size(), npos));
+ }
+
/// Split into substrings around the occurrences of a separator string.
///
/// Each substring is stored in \p A. If \p MaxSplit is >= 0, at most
@@ -796,10 +811,7 @@
/// \return - The split substrings.
LLVM_NODISCARD
std::pair<StringRef, StringRef> rsplit(char Separator) const {
- size_t Idx = rfind(Separator);
- if (Idx == npos)
- return std::make_pair(*this, StringRef());
- return std::make_pair(slice(0, Idx), slice(Idx+1, npos));
+ return rsplit(StringRef(&Separator, 1));
}
/// Return string with consecutive \p Char characters starting from the
@@ -912,7 +924,7 @@
/// @}
- /// \brief Compute a hash_code for a StringRef.
+ /// Compute a hash_code for a StringRef.
LLVM_NODISCARD
hash_code hash_value(StringRef S);
diff --git a/linux-x64/clang/include/llvm/ADT/StringSwitch.h b/linux-x64/clang/include/llvm/ADT/StringSwitch.h
index 9e07303..b7860b9 100644
--- a/linux-x64/clang/include/llvm/ADT/StringSwitch.h
+++ b/linux-x64/clang/include/llvm/ADT/StringSwitch.h
@@ -20,7 +20,7 @@
namespace llvm {
-/// \brief A switch()-like statement whose cases are string literals.
+/// A switch()-like statement whose cases are string literals.
///
/// The StringSwitch class is a simple form of a switch() statement that
/// determines whether the given string matches one of the given string
@@ -41,10 +41,10 @@
/// \endcode
template<typename T, typename R = T>
class StringSwitch {
- /// \brief The string we are matching.
+ /// The string we are matching.
const StringRef Str;
- /// \brief The pointer to the result of this switch statement, once known,
+ /// The pointer to the result of this switch statement, once known,
/// null before that.
Optional<T> Result;
diff --git a/linux-x64/clang/include/llvm/ADT/TinyPtrVector.h b/linux-x64/clang/include/llvm/ADT/TinyPtrVector.h
index 73573d6..1b8e9aa 100644
--- a/linux-x64/clang/include/llvm/ADT/TinyPtrVector.h
+++ b/linux-x64/clang/include/llvm/ADT/TinyPtrVector.h
@@ -108,6 +108,12 @@
return *this;
}
+ TinyPtrVector(std::initializer_list<EltTy> IL)
+ : Val(IL.size() == 0
+ ? PtrUnion()
+ : IL.size() == 1 ? PtrUnion(*IL.begin())
+ : PtrUnion(new VecTy(IL.begin(), IL.end()))) {}
+
/// Constructor from an ArrayRef.
///
/// This also is a constructor for individual array elements due to the single
diff --git a/linux-x64/clang/include/llvm/ADT/Triple.h b/linux-x64/clang/include/llvm/ADT/Triple.h
index 8ba50d9..c95b16d 100644
--- a/linux-x64/clang/include/llvm/ADT/Triple.h
+++ b/linux-x64/clang/include/llvm/ADT/Triple.h
@@ -101,6 +101,7 @@
enum SubArchType {
NoSubArch,
+ ARMSubArch_v8_4a,
ARMSubArch_v8_3a,
ARMSubArch_v8_2a,
ARMSubArch_v8_1a,
@@ -144,7 +145,8 @@
AMD,
Mesa,
SUSE,
- LastVendorType = SUSE
+ OpenEmbedded,
+ LastVendorType = OpenEmbedded
};
enum OSType {
UnknownOS,
@@ -658,6 +660,21 @@
return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
}
+ /// Tests whether the target is MIPS 32-bit (little and big endian).
+ bool isMIPS32() const {
+ return getArch() == Triple::mips || getArch() == Triple::mipsel;
+ }
+
+ /// Tests whether the target is MIPS 64-bit (little and big endian).
+ bool isMIPS64() const {
+ return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
+ }
+
+ /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
+ bool isMIPS() const {
+ return isMIPS32() || isMIPS64();
+ }
+
/// Tests whether the target supports comdat
bool supportsCOMDAT() const {
return !isOSBinFormatMachO();
diff --git a/linux-x64/clang/include/llvm/ADT/UniqueVector.h b/linux-x64/clang/include/llvm/ADT/UniqueVector.h
index b17fb23..c86bedd 100644
--- a/linux-x64/clang/include/llvm/ADT/UniqueVector.h
+++ b/linux-x64/clang/include/llvm/ADT/UniqueVector.h
@@ -72,16 +72,16 @@
return Vector[ID - 1];
}
- /// \brief Return an iterator to the start of the vector.
+ /// Return an iterator to the start of the vector.
iterator begin() { return Vector.begin(); }
- /// \brief Return an iterator to the start of the vector.
+ /// Return an iterator to the start of the vector.
const_iterator begin() const { return Vector.begin(); }
- /// \brief Return an iterator to the end of the vector.
+ /// Return an iterator to the end of the vector.
iterator end() { return Vector.end(); }
- /// \brief Return an iterator to the end of the vector.
+ /// Return an iterator to the end of the vector.
const_iterator end() const { return Vector.end(); }
/// size - Returns the number of entries in the vector.
diff --git a/linux-x64/clang/include/llvm/ADT/VariadicFunction.h b/linux-x64/clang/include/llvm/ADT/VariadicFunction.h
index 403130c..9028abe 100644
--- a/linux-x64/clang/include/llvm/ADT/VariadicFunction.h
+++ b/linux-x64/clang/include/llvm/ADT/VariadicFunction.h
@@ -53,7 +53,7 @@
#define LLVM_COMMA_JOIN31(x) LLVM_COMMA_JOIN30(x), x ## 30
#define LLVM_COMMA_JOIN32(x) LLVM_COMMA_JOIN31(x), x ## 31
-/// \brief Class which can simulate a type-safe variadic function.
+/// Class which can simulate a type-safe variadic function.
///
/// The VariadicFunction class template makes it easy to define
/// type-safe variadic functions where all arguments have the same
diff --git a/linux-x64/clang/include/llvm/ADT/edit_distance.h b/linux-x64/clang/include/llvm/ADT/edit_distance.h
index 06a01b1..b2e8ec5 100644
--- a/linux-x64/clang/include/llvm/ADT/edit_distance.h
+++ b/linux-x64/clang/include/llvm/ADT/edit_distance.h
@@ -22,7 +22,7 @@
namespace llvm {
-/// \brief Determine the edit distance between two sequences.
+/// Determine the edit distance between two sequences.
///
/// \param FromArray the first sequence to compare.
///
diff --git a/linux-x64/clang/include/llvm/ADT/ilist.h b/linux-x64/clang/include/llvm/ADT/ilist.h
index a788f81..00bb6d5 100644
--- a/linux-x64/clang/include/llvm/ADT/ilist.h
+++ b/linux-x64/clang/include/llvm/ADT/ilist.h
@@ -84,21 +84,11 @@
struct ilist_node_traits : ilist_alloc_traits<NodeTy>,
ilist_callback_traits<NodeTy> {};
-/// Default template traits for intrusive list.
-///
-/// By inheriting from this, you can easily use default implementations for all
-/// common operations.
-///
-/// TODO: Remove this customization point. Specializing ilist_traits is
-/// already fully general.
-template <typename NodeTy>
-struct ilist_default_traits : public ilist_node_traits<NodeTy> {};
-
/// Template traits for intrusive list.
///
/// Customize callbacks and allocation semantics.
template <typename NodeTy>
-struct ilist_traits : public ilist_default_traits<NodeTy> {};
+struct ilist_traits : public ilist_node_traits<NodeTy> {};
/// Const traits should never be instantiated.
template <typename Ty> struct ilist_traits<const Ty> {};
@@ -178,9 +168,6 @@
class iplist_impl : public TraitsT, IntrusiveListT {
typedef IntrusiveListT base_list_type;
-protected:
- typedef iplist_impl iplist_impl_type;
-
public:
typedef typename base_list_type::pointer pointer;
typedef typename base_list_type::const_pointer const_pointer;
@@ -369,26 +356,26 @@
using base_list_type::sort;
- /// \brief Get the previous node, or \c nullptr for the list head.
+ /// Get the previous node, or \c nullptr for the list head.
pointer getPrevNode(reference N) const {
auto I = N.getIterator();
if (I == begin())
return nullptr;
return &*std::prev(I);
}
- /// \brief Get the previous node, or \c nullptr for the list head.
+ /// Get the previous node, or \c nullptr for the list head.
const_pointer getPrevNode(const_reference N) const {
return getPrevNode(const_cast<reference >(N));
}
- /// \brief Get the next node, or \c nullptr for the list tail.
+ /// Get the next node, or \c nullptr for the list tail.
pointer getNextNode(reference N) const {
auto Next = std::next(N.getIterator());
if (Next == end())
return nullptr;
return &*Next;
}
- /// \brief Get the next node, or \c nullptr for the list tail.
+ /// Get the next node, or \c nullptr for the list tail.
const_pointer getNextNode(const_reference N) const {
return getNextNode(const_cast<reference >(N));
}
@@ -402,7 +389,7 @@
template <class T, class... Options>
class iplist
: public iplist_impl<simple_ilist<T, Options...>, ilist_traits<T>> {
- typedef typename iplist::iplist_impl_type iplist_impl_type;
+ using iplist_impl_type = typename iplist::iplist_impl;
public:
iplist() = default;
diff --git a/linux-x64/clang/include/llvm/ADT/ilist_node.h b/linux-x64/clang/include/llvm/ADT/ilist_node.h
index 3362611..dd0e6b4 100644
--- a/linux-x64/clang/include/llvm/ADT/ilist_node.h
+++ b/linux-x64/clang/include/llvm/ADT/ilist_node.h
@@ -271,7 +271,7 @@
public:
/// @name Adjacent Node Accessors
/// @{
- /// \brief Get the previous node, or \c nullptr for the list head.
+ /// Get the previous node, or \c nullptr for the list head.
NodeTy *getPrevNode() {
// Should be separated to a reused function, but then we couldn't use auto
// (and would need the type of the list).
@@ -280,12 +280,12 @@
return List.getPrevNode(*static_cast<NodeTy *>(this));
}
- /// \brief Get the previous node, or \c nullptr for the list head.
+ /// Get the previous node, or \c nullptr for the list head.
const NodeTy *getPrevNode() const {
return const_cast<ilist_node_with_parent *>(this)->getPrevNode();
}
- /// \brief Get the next node, or \c nullptr for the list tail.
+ /// Get the next node, or \c nullptr for the list tail.
NodeTy *getNextNode() {
// Should be separated to a reused function, but then we couldn't use auto
// (and would need the type of the list).
@@ -294,7 +294,7 @@
return List.getNextNode(*static_cast<NodeTy *>(this));
}
- /// \brief Get the next node, or \c nullptr for the list tail.
+ /// Get the next node, or \c nullptr for the list tail.
const NodeTy *getNextNode() const {
return const_cast<ilist_node_with_parent *>(this)->getNextNode();
}
diff --git a/linux-x64/clang/include/llvm/ADT/ilist_node_options.h b/linux-x64/clang/include/llvm/ADT/ilist_node_options.h
index c33df1e..7ff4005 100644
--- a/linux-x64/clang/include/llvm/ADT/ilist_node_options.h
+++ b/linux-x64/clang/include/llvm/ADT/ilist_node_options.h
@@ -11,7 +11,6 @@
#define LLVM_ADT_ILIST_NODE_OPTIONS_H
#include "llvm/Config/abi-breaking.h"
-#include "llvm/Config/llvm-config.h"
#include <type_traits>
diff --git a/linux-x64/clang/include/llvm/ADT/iterator.h b/linux-x64/clang/include/llvm/ADT/iterator.h
index 711f8f2..549c522 100644
--- a/linux-x64/clang/include/llvm/ADT/iterator.h
+++ b/linux-x64/clang/include/llvm/ADT/iterator.h
@@ -19,7 +19,7 @@
namespace llvm {
-/// \brief CRTP base class which implements the entire standard iterator facade
+/// CRTP base class which implements the entire standard iterator facade
/// in terms of a minimal subset of the interface.
///
/// Use this when it is reasonable to implement most of the iterator
@@ -183,7 +183,7 @@
}
};
-/// \brief CRTP base class for adapting an iterator to a different type.
+/// CRTP base class for adapting an iterator to a different type.
///
/// This class can be used through CRTP to adapt one iterator into another.
/// Typically this is done through providing in the derived class a custom \c
@@ -274,7 +274,7 @@
ReferenceT operator*() const { return *I; }
};
-/// \brief An iterator type that allows iterating over the pointees via some
+/// An iterator type that allows iterating over the pointees via some
/// other iterator.
///
/// The typical usage of this is to expose a type that iterates over Ts, but
@@ -288,7 +288,7 @@
decltype(**std::declval<WrappedIteratorT>())>::type>
struct pointee_iterator
: iterator_adaptor_base<
- pointee_iterator<WrappedIteratorT>, WrappedIteratorT,
+ pointee_iterator<WrappedIteratorT, T>, WrappedIteratorT,
typename std::iterator_traits<WrappedIteratorT>::iterator_category,
T> {
pointee_iterator() = default;
@@ -311,7 +311,7 @@
template <typename WrappedIteratorT,
typename T = decltype(&*std::declval<WrappedIteratorT>())>
class pointer_iterator
- : public iterator_adaptor_base<pointer_iterator<WrappedIteratorT>,
+ : public iterator_adaptor_base<pointer_iterator<WrappedIteratorT, T>,
WrappedIteratorT, T> {
mutable T Ptr;
diff --git a/linux-x64/clang/include/llvm/ADT/iterator_range.h b/linux-x64/clang/include/llvm/ADT/iterator_range.h
index 3cbf619..2ba1286 100644
--- a/linux-x64/clang/include/llvm/ADT/iterator_range.h
+++ b/linux-x64/clang/include/llvm/ADT/iterator_range.h
@@ -24,7 +24,7 @@
namespace llvm {
-/// \brief A range adaptor for a pair of iterators.
+/// A range adaptor for a pair of iterators.
///
/// This just wraps two iterators into a range-compatible interface. Nothing
/// fancy at all.
@@ -47,7 +47,7 @@
IteratorT end() const { return end_iterator; }
};
-/// \brief Convenience function for iterating over sub-ranges.
+/// Convenience function for iterating over sub-ranges.
///
/// This provides a bit of syntactic sugar to make using sub-ranges
/// in for loops a bit easier. Analogous to std::make_pair().
@@ -59,9 +59,10 @@
return iterator_range<T>(std::move(p.first), std::move(p.second));
}
-template<typename T>
-iterator_range<decltype(begin(std::declval<T>()))> drop_begin(T &&t, int n) {
- return make_range(std::next(begin(t), n), end(t));
+template <typename T>
+iterator_range<decltype(adl_begin(std::declval<T>()))> drop_begin(T &&t,
+ int n) {
+ return make_range(std::next(adl_begin(t), n), adl_end(t));
}
}