diff options
author | Pavel Kopyl <pavelkopyl@gmail.com> | 2023-02-10 23:36:24 +0100 |
---|---|---|
committer | Pavel Kopyl <pavelkopyl@gmail.com> | 2023-02-14 22:16:19 +0100 |
commit | 36606cf07080a44a1a9157f80112f9512bd6a3bf (patch) | |
tree | 516934053dadeeeb876ceb0c5cc04f5f4fe4704c /llvm/lib/Support/APInt.cpp | |
parent | 31c35285d27ed507ae758aefdca0d9cd05c7f21d (diff) | |
download | llvm-36606cf07080a44a1a9157f80112f9512bd6a3bf.zip llvm-36606cf07080a44a1a9157f80112f9512bd6a3bf.tar.gz llvm-36606cf07080a44a1a9157f80112f9512bd6a3bf.tar.bz2 |
[NFC] Replace -1U{LL} expressions with appropriate *_MAX macros in Support library.
This makes a code a bit more clear and also gets rid of C4146 warning
on MSVC compiler:
'unary minus operator applied to unsigned type, result still unsigned'.
In case uint64_t variable is initialized or compared against -1U expression,
which corresponds to 32-bit constant, UINT_MAX macro is used to preserve
NFC semantics; -1ULL is replaced with UINT64_MAX.
Reviewed By: dblaikie, craig.topper
Differential Revision: https://reviews.llvm.org/D143942
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 9e0d9064..857d400 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -68,7 +68,7 @@ inline static unsigned getDigit(char cdigit, uint8_t radix) { if (r < radix) return r; - return -1U; + return UINT_MAX; } @@ -2330,7 +2330,7 @@ void APInt::tcClearBit(WordType *parts, unsigned bit) { } /// Returns the bit number of the least significant set bit of a number. If the -/// input number has no bits set -1U is returned. +/// input number has no bits set UINT_MAX is returned. unsigned APInt::tcLSB(const WordType *parts, unsigned n) { for (unsigned i = 0; i < n; i++) { if (parts[i] != 0) { @@ -2339,11 +2339,11 @@ unsigned APInt::tcLSB(const WordType *parts, unsigned n) { } } - return -1U; + return UINT_MAX; } /// Returns the bit number of the most significant set bit of a number. -/// If the input number has no bits set -1U is returned. +/// If the input number has no bits set UINT_MAX is returned. unsigned APInt::tcMSB(const WordType *parts, unsigned n) { do { --n; @@ -2356,7 +2356,7 @@ unsigned APInt::tcMSB(const WordType *parts, unsigned n) { } } while (n); - return -1U; + return UINT_MAX; } /// Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to |