diff options
author | Guillaume Chatelet <gchatelet@google.com> | 2023-12-15 15:51:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-15 15:51:10 +0100 |
commit | 57fcc238968cff9944509b7a5dcf47286ad374e5 (patch) | |
tree | 3b5a36a057f2c49a81d3e986a7bc8d07e34d114d /libc/test/UnitTest | |
parent | 32f9983c064557883223b585810eac3c6797d500 (diff) | |
download | llvm-57fcc238968cff9944509b7a5dcf47286ad374e5.zip llvm-57fcc238968cff9944509b7a5dcf47286ad374e5.tar.gz llvm-57fcc238968cff9944509b7a5dcf47286ad374e5.tar.bz2 |
[libc] Fix improper initialization of `StorageType` (#75610)
`StorageType` may be a `BigInt` under the hood. Initializing it with
`-1` does not yields the maximum value.
Diffstat (limited to 'libc/test/UnitTest')
-rw-r--r-- | libc/test/UnitTest/FPMatcher.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index a3b7764..003de7e 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -9,6 +9,7 @@ #ifndef LLVM_LIBC_UTILS_UNITTEST_FPMATCHER_H #define LLVM_LIBC_UTILS_UNITTEST_FPMATCHER_H +#include "src/__support/CPP/type_traits.h" #include "src/__support/FPUtil/FEnvImpl.h" #include "src/__support/FPUtil/FPBits.h" #include "src/__support/FPUtil/fpbits_str.h" @@ -62,6 +63,8 @@ template <TestCond C, typename T> FPMatcher<T, C> getMatcher(T expectedValue) { template <typename T> struct FPTest : public Test { using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>; using StorageType = typename FPBits::StorageType; + static constexpr StorageType STORAGE_MAX = + LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max(); static constexpr T zero = FPBits::zero(); static constexpr T neg_zero = FPBits::neg_zero(); static constexpr T aNaN = FPBits::build_quiet_nan(1); @@ -88,6 +91,8 @@ template <typename T> struct FPTest : public Test { #define DECLARE_SPECIAL_CONSTANTS(T) \ using FPBits = LIBC_NAMESPACE::fputil::FPBits<T>; \ using StorageType = typename FPBits::StorageType; \ + static constexpr StorageType STORAGE_MAX = \ + LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max(); \ const T zero = FPBits::zero(); \ const T neg_zero = FPBits::neg_zero(); \ const T aNaN = FPBits::build_quiet_nan(1); \ |