Skip to content

Commit aad74dc

Browse files
authored
[compiler-rt] FuzzedDataProvider: modernize outdated trait patterns (#127811)
1 parent 0a913b5 commit aad74dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler-rt/include/fuzzer/FuzzedDataProvider.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ template <typename T> T FuzzedDataProvider::ConsumeIntegral() {
203203
// be less than or equal to |max|.
204204
template <typename T>
205205
T FuzzedDataProvider::ConsumeIntegralInRange(T min, T max) {
206-
static_assert(std::is_integral<T>::value, "An integral type is required.");
206+
static_assert(std::is_integral_v<T>, "An integral type is required.");
207207
static_assert(sizeof(T) <= sizeof(uint64_t), "Unsupported integral type.");
208208

209209
if (min > max)
@@ -271,14 +271,14 @@ T FuzzedDataProvider::ConsumeFloatingPointInRange(T min, T max) {
271271
// Returns a floating point number in the range [0.0, 1.0]. If there's no
272272
// input data left, always returns 0.
273273
template <typename T> T FuzzedDataProvider::ConsumeProbability() {
274-
static_assert(std::is_floating_point<T>::value,
274+
static_assert(std::is_floating_point_v<T>,
275275
"A floating point type is required.");
276276

277277
// Use different integral types for different floating point types in order
278278
// to provide better density of the resulting values.
279279
using IntegralType =
280-
typename std::conditional<(sizeof(T) <= sizeof(uint32_t)), uint32_t,
281-
uint64_t>::type;
280+
typename std::conditional_t<(sizeof(T) <= sizeof(uint32_t)), uint32_t,
281+
uint64_t>;
282282

283283
T result = static_cast<T>(ConsumeIntegral<IntegralType>());
284284
result /= static_cast<T>(std::numeric_limits<IntegralType>::max());
@@ -294,7 +294,7 @@ inline bool FuzzedDataProvider::ConsumeBool() {
294294
// also contain |kMaxValue| aliased to its largest (inclusive) value. Such as:
295295
// enum class Foo { SomeValue, OtherValue, kMaxValue = OtherValue };
296296
template <typename T> T FuzzedDataProvider::ConsumeEnum() {
297-
static_assert(std::is_enum<T>::value, "|T| must be an enum type.");
297+
static_assert(std::is_enum_v<T>, "|T| must be an enum type.");
298298
return static_cast<T>(
299299
ConsumeIntegralInRange<uint32_t>(0, static_cast<uint32_t>(T::kMaxValue)));
300300
}

0 commit comments

Comments
 (0)