diff --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h index c9c2118716fb12..c64cf303d4c048 100644 --- a/llvm/include/llvm/ADT/APSInt.h +++ b/llvm/include/llvm/ADT/APSInt.h @@ -29,10 +29,10 @@ class [[nodiscard]] APSInt : public APInt { /// Create an APSInt with the specified width, default to unsigned. explicit APSInt(uint32_t BitWidth, bool isUnsigned = true) - : APInt(BitWidth, 0), IsUnsigned(isUnsigned) {} + : APInt(BitWidth, 0), IsUnsigned(isUnsigned) {} explicit APSInt(APInt I, bool isUnsigned = true) - : APInt(std::move(I)), IsUnsigned(isUnsigned) {} + : APInt(std::move(I)), IsUnsigned(isUnsigned) {} /// Construct an APSInt from a string representation. /// @@ -137,7 +137,7 @@ class [[nodiscard]] APSInt : public APInt { APSInt operator>>(unsigned Amt) const { return IsUnsigned ? APSInt(lshr(Amt), true) : APSInt(ashr(Amt), false); } - APSInt& operator>>=(unsigned Amt) { + APSInt &operator>>=(unsigned Amt) { if (IsUnsigned) lshrInPlace(Amt); else @@ -149,29 +149,27 @@ class [[nodiscard]] APSInt : public APInt { : APSInt(relativeAShr(Amt), false); } - inline bool operator<(const APSInt& RHS) const { + inline bool operator<(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return IsUnsigned ? ult(RHS) : slt(RHS); } - inline bool operator>(const APSInt& RHS) const { + inline bool operator>(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return IsUnsigned ? ugt(RHS) : sgt(RHS); } - inline bool operator<=(const APSInt& RHS) const { + inline bool operator<=(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return IsUnsigned ? ule(RHS) : sle(RHS); } - inline bool operator>=(const APSInt& RHS) const { + inline bool operator>=(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return IsUnsigned ? uge(RHS) : sge(RHS); } - inline bool operator==(const APSInt& RHS) const { + inline bool operator==(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return eq(RHS); } - inline bool operator!=(const APSInt& RHS) const { - return !((*this) == RHS); - } + inline bool operator!=(const APSInt &RHS) const { return !((*this) == RHS); } bool operator==(int64_t RHS) const { return compareValues(*this, get(RHS)) == 0; @@ -196,10 +194,10 @@ class [[nodiscard]] APSInt : public APInt { // signedness information. APSInt operator<<(unsigned Bits) const { - return APSInt(static_cast(*this) << Bits, IsUnsigned); + return APSInt(static_cast(*this) << Bits, IsUnsigned); } - APSInt& operator<<=(unsigned Amt) { - static_cast(*this) <<= Amt; + APSInt &operator<<=(unsigned Amt) { + static_cast(*this) <<= Amt; return *this; } APSInt relativeShl(unsigned Amt) const { @@ -207,97 +205,99 @@ class [[nodiscard]] APSInt : public APInt { : APSInt(relativeAShl(Amt), false); } - APSInt& operator++() { - ++(static_cast(*this)); + APSInt &operator++() { + ++(static_cast(*this)); return *this; } - APSInt& operator--() { - --(static_cast(*this)); + APSInt &operator--() { + --(static_cast(*this)); return *this; } APSInt operator++(int) { - return APSInt(++static_cast(*this), IsUnsigned); + return APSInt(++static_cast(*this), IsUnsigned); } APSInt operator--(int) { - return APSInt(--static_cast(*this), IsUnsigned); + return APSInt(--static_cast(*this), IsUnsigned); } APSInt operator-() const { - return APSInt(-static_cast(*this), IsUnsigned); + return APSInt(-static_cast(*this), IsUnsigned); } - APSInt& operator+=(const APSInt& RHS) { + APSInt &operator+=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) += RHS; + static_cast(*this) += RHS; return *this; } - APSInt& operator-=(const APSInt& RHS) { + APSInt &operator-=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) -= RHS; + static_cast(*this) -= RHS; return *this; } - APSInt& operator*=(const APSInt& RHS) { + APSInt &operator*=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) *= RHS; + static_cast(*this) *= RHS; return *this; } - APSInt& operator&=(const APSInt& RHS) { + APSInt &operator&=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) &= RHS; + static_cast(*this) &= RHS; return *this; } - APSInt& operator|=(const APSInt& RHS) { + APSInt &operator|=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) |= RHS; + static_cast(*this) |= RHS; return *this; } - APSInt& operator^=(const APSInt& RHS) { + APSInt &operator^=(const APSInt &RHS) { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - static_cast(*this) ^= RHS; + static_cast(*this) ^= RHS; return *this; } - APSInt operator&(const APSInt& RHS) const { + APSInt operator&(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) & RHS, IsUnsigned); + return APSInt(static_cast(*this) & RHS, IsUnsigned); } - APSInt operator|(const APSInt& RHS) const { + APSInt operator|(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) | RHS, IsUnsigned); + return APSInt(static_cast(*this) | RHS, IsUnsigned); } APSInt operator^(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) ^ RHS, IsUnsigned); + return APSInt(static_cast(*this) ^ RHS, IsUnsigned); } - APSInt operator*(const APSInt& RHS) const { + APSInt operator*(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) * RHS, IsUnsigned); + return APSInt(static_cast(*this) * RHS, IsUnsigned); } - APSInt operator+(const APSInt& RHS) const { + APSInt operator+(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) + RHS, IsUnsigned); + return APSInt(static_cast(*this) + RHS, IsUnsigned); } - APSInt operator-(const APSInt& RHS) const { + APSInt operator-(const APSInt &RHS) const { assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); - return APSInt(static_cast(*this) - RHS, IsUnsigned); + return APSInt(static_cast(*this) - RHS, IsUnsigned); } APSInt operator~() const { - return APSInt(~static_cast(*this), IsUnsigned); + return APSInt(~static_cast(*this), IsUnsigned); } /// Return the APSInt representing the maximum integer value with the given /// bit width and signedness. static APSInt getMaxValue(uint32_t numBits, bool Unsigned) { return APSInt(Unsigned ? APInt::getMaxValue(numBits) - : APInt::getSignedMaxValue(numBits), Unsigned); + : APInt::getSignedMaxValue(numBits), + Unsigned); } /// Return the APSInt representing the minimum integer value with the given /// bit width and signedness. static APSInt getMinValue(uint32_t numBits, bool Unsigned) { return APSInt(Unsigned ? APInt::getMinValue(numBits) - : APInt::getSignedMinValue(numBits), Unsigned); + : APInt::getSignedMinValue(numBits), + Unsigned); } /// Determine if two APSInts have the same value, zero- or @@ -337,7 +337,7 @@ class [[nodiscard]] APSInt : public APInt { /// Used to insert APSInt objects, or objects that contain APSInt objects, /// into FoldingSets. - void Profile(FoldingSetNodeID& ID) const; + void Profile(FoldingSetNodeID &ID) const; }; inline bool operator==(int64_t V1, const APSInt &V2) { return V2 == V1; }