diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-04-14 21:41:27 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-06-22 18:20:56 +0000 |
commit | bdd1243df58e60e85101c09001d9812a789b6bc4 (patch) | |
tree | a1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp | |
parent | 781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff) | |
parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp b/contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp index 8a69f7513255..6e8137c405b8 100644 --- a/contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp +++ b/contrib/llvm-project/llvm/lib/Support/NativeFormatting.cpp @@ -14,6 +14,8 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" +#include <cmath> + #if defined(_WIN32) && !defined(__MINGW32__) #include <float.h> // For _fpclass in llvm::write_double. #endif @@ -53,7 +55,7 @@ static void writeWithCommas(raw_ostream &S, ArrayRef<char> Buffer) { template <typename T> static void write_unsigned_impl(raw_ostream &S, T N, size_t MinDigits, IntegerStyle Style, bool IsNegative) { - static_assert(std::is_unsigned<T>::value, "Value is not unsigned!"); + static_assert(std::is_unsigned_v<T>, "Value is not unsigned!"); char NumberBuffer[128]; std::memset(NumberBuffer, '0', sizeof(NumberBuffer)); @@ -90,7 +92,7 @@ static void write_unsigned(raw_ostream &S, T N, size_t MinDigits, template <typename T> static void write_signed(raw_ostream &S, T N, size_t MinDigits, IntegerStyle Style) { - static_assert(std::is_signed<T>::value, "Value is not signed!"); + static_assert(std::is_signed_v<T>, "Value is not signed!"); using UnsignedT = std::make_unsigned_t<T>; @@ -134,12 +136,12 @@ void llvm::write_integer(raw_ostream &S, long long N, size_t MinDigits, } void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, - Optional<size_t> Width) { + std::optional<size_t> Width) { const size_t kMaxWidth = 128u; size_t W = std::min(kMaxWidth, Width.value_or(0u)); - unsigned Nibbles = (64 - countLeadingZeros(N) + 3) / 4; + unsigned Nibbles = (llvm::bit_width(N) + 3) / 4; bool Prefix = (Style == HexPrintStyle::PrefixLower || Style == HexPrintStyle::PrefixUpper); bool Upper = @@ -149,7 +151,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::max(static_cast<unsigned>(W), std::max(1u, Nibbles) + PrefixChars); char NumberBuffer[kMaxWidth]; - ::memset(NumberBuffer, '0', llvm::array_lengthof(NumberBuffer)); + ::memset(NumberBuffer, '0', std::size(NumberBuffer)); if (Prefix) NumberBuffer[1] = 'x'; char *EndPtr = NumberBuffer + NumChars; @@ -164,7 +166,7 @@ void llvm::write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, } void llvm::write_double(raw_ostream &S, double N, FloatStyle Style, - Optional<size_t> Precision) { + std::optional<size_t> Precision) { size_t Prec = Precision.value_or(getDefaultPrecision(Style)); if (std::isnan(N)) { |