diff options
author | Alex Sepkowski <alexsepkowski@gmail.com> | 2025-07-09 16:13:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-09 16:13:28 -0700 |
commit | 7c16a31aa593b9cc750e61b260c27ade74edb1dd (patch) | |
tree | 6628e4804b3e91a3d0a63100ba1a565f51c9c12b /clang/lib/Lex/Lexer.cpp | |
parent | ddf9b91f9fed8654c4649881f7db51f1e474701f (diff) | |
download | llvm-7c16a31aa593b9cc750e61b260c27ade74edb1dd.zip llvm-7c16a31aa593b9cc750e61b260c27ade74edb1dd.tar.gz llvm-7c16a31aa593b9cc750e61b260c27ade74edb1dd.tar.bz2 |
Address a handful of C4146 compiler warnings where literals can be replaced with std::numeric_limits (#147623)
This PR addresses instances of compiler warning C4146 that can be
replaced with std::numeric_limits. Specifically, these are cases where a
literal such as '-1ULL' was used to assign a value to a uint64_t
variable. The intent is much cleaner if we use the appropriate
std::numeric_limits value<Type>::max() for these cases.
Addresses #147439
Diffstat (limited to 'clang/lib/Lex/Lexer.cpp')
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 78988e9..1f695b4 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -41,6 +41,7 @@ #include <cstddef> #include <cstdint> #include <cstring> +#include <limits> #include <optional> #include <string> #include <tuple> @@ -3456,7 +3457,7 @@ std::optional<uint32_t> Lexer::tryReadNumericUCN(const char *&StartPtr, } unsigned Value = llvm::hexDigitValue(C); - if (Value == -1U) { + if (Value == std::numeric_limits<unsigned>::max()) { if (!Delimited) break; if (Diagnose) |