From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:12:41 -0400 Subject: [PATCH 02/37] Wrap std::min/max calls in parens, for Windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- llvm/include/llvm/ADT/SmallVector.h | 6 +++--- llvm/include/llvm/Support/ConvertUTF.h | 2 +- llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 7ccc9445c0a7b882b424b2431858ea596d0eb58f..c4764fffa845a7f9eb69f262aa0ee728d08b1655 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -432,7 +432,7 @@ protected: return 0; // +1 is required because of the strict equality. // For example if NumEntries is 48, we need to return 401. - return NextPowerOf2(NumEntries * 4 / 3 + 1); + return static_cast(NextPowerOf2(NumEntries * 4 / 3 + 1)); } void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) { @@ -868,7 +868,7 @@ public: // Reduce the number of buckets. unsigned NewNumBuckets = 0; if (OldNumEntries) - NewNumBuckets = std::max(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1)); + NewNumBuckets = (std::max)(64, 1 << (Log2_32_Ceil(OldNumEntries) + 1)); if (NewNumBuckets == NumBuckets) { this->BaseT::initEmpty(); return; diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 94d8da059f4f8bad50039b0d0b7993396707829c..85bf5172e419b1b58f53d3cf00d4aabb58877c33 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -56,7 +56,7 @@ protected: /// The maximum value of the Size_T used. static constexpr size_t SizeTypeMax() { - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } SmallVectorBase() = delete; @@ -290,7 +290,7 @@ public: size_type size_in_bytes() const { return size() * sizeof(T); } size_type max_size() const { - return std::min(this->SizeTypeMax(), size_type(-1) / sizeof(T)); + return (std::min)(this->SizeTypeMax(), size_type(-1) / sizeof(T)); } size_t capacity_in_bytes() const { return capacity() * sizeof(T); } @@ -722,7 +722,7 @@ public: } // Assign over existing elements. - std::fill_n(this->begin(), std::min(NumElts, this->size()), Elt); + std::fill_n(this->begin(), (std::min)(NumElts, this->size()), Elt); if (NumElts > this->size()) std::uninitialized_fill_n(this->end(), NumElts - this->size(), Elt); else if (NumElts < this->size()) diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd68eb7d02f 100644 --- a/llvm/include/llvm/Support/ConvertUTF.h +++ b/llvm/include/llvm/Support/ConvertUTF.h @@ -127,7 +127,7 @@ namespace llvm { typedef unsigned int UTF32; /* at least 32 bits */ typedef unsigned short UTF16; /* at least 16 bits */ typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ +typedef bool Boolean; /* 0 or 1 */ /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h index e568e42afcf4d20dba137346953ff4be9d27ffc7..d9de2e92d5b07bce1d02ffcfda614b9079d2df91 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -338,26 +338,26 @@ template <> constexpr size_t CTLog2<1>() { return 0; } /// (32 bit edition.) /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 inline unsigned Log2_32(uint32_t Value) { - return 31 - llvm::countl_zero(Value); + return static_cast(31 - llvm::countl_zero(Value)); } /// Return the floor log base 2 of the specified value, -1 if the value is zero. /// (64 bit edition.) inline unsigned Log2_64(uint64_t Value) { - return 63 - llvm::countl_zero(Value); + return static_cast(63 - llvm::countl_zero(Value)); } /// Return the ceil log base 2 of the specified value, 32 if the value is zero. /// (32 bit edition). /// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3 inline unsigned Log2_32_Ceil(uint32_t Value) { - return 32 - llvm::countl_zero(Value - 1); + return static_cast(32 - llvm::countl_zero(Value - 1)); } /// Return the ceil log base 2 of the specified value, 64 if the value is zero. /// (64 bit edition.) inline unsigned Log2_64_Ceil(uint64_t Value) { - return 64 - llvm::countl_zero(Value - 1); + return static_cast(64 - llvm::countl_zero(Value - 1)); } /// A and B are either alignments or offsets. Return the minimum alignment that @@ -417,7 +417,7 @@ constexpr uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator) { // happens only when Numerator = INT_MIN and Denominator = -1. template constexpr bool divideSignedWouldOverflow(U Numerator, V Denominator) { - return Numerator == std::numeric_limits::min() && Denominator == -1; + return Numerator == (std::numeric_limits::min)() && Denominator == -1; } /// Returns the integer ceil(Numerator / Denominator). Signed version. @@ -605,7 +605,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { T Z = X + Y; Overflowed = (Z < X || Z < Y); if (Overflowed) - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); else return Z; } @@ -618,7 +618,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, bool Overflowed = false; T XY = SaturatingAdd(X, Y, &Overflowed); if (Overflowed) - return SaturatingAdd(std::numeric_limits::max(), T(1), Args...); + return SaturatingAdd((std::numeric_limits::max)(), T(1), Args...); return SaturatingAdd(XY, Z, Args...); } @@ -642,7 +642,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { // Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z // will necessarily be less than Log2Max as desired. int Log2Z = Log2_64(X) + Log2_64(Y); - const T Max = std::numeric_limits::max(); + const T Max = (std::numeric_limits::max)(); int Log2Max = Log2_64(Max); if (Log2Z < Log2Max) { return X * Y; @@ -764,9 +764,9 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { // Check how the max allowed absolute value (2^n for negative, 2^(n-1) for // positive) divided by an argument compares to the other. if (IsNegative) - return UX > (static_cast(std::numeric_limits::max()) + U(1)) / UY; + return UX > (static_cast((std::numeric_limits::max)()) + U(1)) / UY; else - return UX > (static_cast(std::numeric_limits::max())) / UY; + return UX > (static_cast((std::numeric_limits::max)())) / UY; #endif }