Skip to content

Commit 9395cf0

Browse files
[ADT] Apply fixes from modernize-type-traits (NFC)
1 parent ce47090 commit 9395cf0

20 files changed

+125
-134
lines changed

llvm/include/llvm/ADT/APFloat.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ class APFloat : public APFloatBase {
757757
typedef detail::IEEEFloat IEEEFloat;
758758
typedef detail::DoubleAPFloat DoubleAPFloat;
759759

760-
static_assert(std::is_standard_layout<IEEEFloat>::value);
760+
static_assert(std::is_standard_layout_v<IEEEFloat>);
761761

762762
union Storage {
763763
const fltSemantics *semantics;
@@ -849,9 +849,9 @@ class APFloat : public APFloatBase {
849849
} U;
850850

851851
template <typename T> static bool usesLayout(const fltSemantics &Semantics) {
852-
static_assert(std::is_same<T, IEEEFloat>::value ||
853-
std::is_same<T, DoubleAPFloat>::value);
854-
if (std::is_same<T, DoubleAPFloat>::value) {
852+
static_assert(std::is_same_v<T, IEEEFloat> ||
853+
std::is_same_v<T, DoubleAPFloat>);
854+
if (std::is_same_v<T, DoubleAPFloat>) {
855855
return &Semantics == &PPCDoubleDouble();
856856
}
857857
return &Semantics != &PPCDoubleDouble();
@@ -912,7 +912,7 @@ class APFloat : public APFloatBase {
912912
APFloat(const fltSemantics &Semantics, StringRef S);
913913
APFloat(const fltSemantics &Semantics, integerPart I) : U(Semantics, I) {}
914914
template <typename T,
915-
typename = std::enable_if_t<std::is_floating_point<T>::value>>
915+
typename = std::enable_if_t<std::is_floating_point_v<T>>>
916916
APFloat(const fltSemantics &Semantics, T V) = delete;
917917
// TODO: Remove this constructor. This isn't faster than the first one.
918918
APFloat(const fltSemantics &Semantics, uninitializedTag)

llvm/include/llvm/ADT/Any.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class LLVM_EXTERNAL_VISIBILITY Any {
7070
// instead.
7171
template <typename T,
7272
std::enable_if_t<
73-
std::conjunction<
73+
std::conjunction_v<
7474
std::negation<std::is_same<std::decay_t<T>, Any>>,
7575
// We also disable this overload when an `Any` object can be
7676
// converted to the parameter type because in that case,
@@ -83,7 +83,7 @@ class LLVM_EXTERNAL_VISIBILITY Any {
8383
// adopting it to work-around usage of `Any` with types that
8484
// need to be implicitly convertible from an `Any`.
8585
std::negation<std::is_convertible<Any, std::decay_t<T>>>,
86-
std::is_copy_constructible<std::decay_t<T>>>::value,
86+
std::is_copy_constructible<std::decay_t<T>>>,
8787
int> = 0>
8888
Any(T &&Value) {
8989
Storage =

llvm/include/llvm/ADT/ArrayRef.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ namespace llvm {
122122
/// ensure that only ArrayRefs of pointers can be converted.
123123
template <typename U>
124124
ArrayRef(const ArrayRef<U *> &A,
125-
std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
126-
* = nullptr)
125+
std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
126+
nullptr)
127127
: Data(A.data()), Length(A.size()) {}
128128

129129
/// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
@@ -132,16 +132,16 @@ namespace llvm {
132132
template <typename U, typename DummyT>
133133
/*implicit*/ ArrayRef(
134134
const SmallVectorTemplateCommon<U *, DummyT> &Vec,
135-
std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
135+
std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
136136
nullptr)
137137
: Data(Vec.data()), Length(Vec.size()) {}
138138

139139
/// Construct an ArrayRef<const T*> from std::vector<T*>. This uses SFINAE
140140
/// to ensure that only vectors of pointers can be converted.
141141
template <typename U, typename A>
142142
ArrayRef(const std::vector<U *, A> &Vec,
143-
std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
144-
* = nullptr)
143+
std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
144+
nullptr)
145145
: Data(Vec.data()), Length(Vec.size()) {}
146146

147147
/// @}
@@ -261,15 +261,15 @@ namespace llvm {
261261
/// The declaration here is extra complicated so that "arrayRef = {}"
262262
/// continues to select the move assignment operator.
263263
template <typename U>
264-
std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
264+
std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &
265265
operator=(U &&Temporary) = delete;
266266

267267
/// Disallow accidental assignment from a temporary.
268268
///
269269
/// The declaration here is extra complicated so that "arrayRef = {}"
270270
/// continues to select the move assignment operator.
271271
template <typename U>
272-
std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
272+
std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &
273273
operator=(std::initializer_list<U>) = delete;
274274

275275
/// @}

llvm/include/llvm/ADT/Bitfields.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ template <typename T, unsigned Bits> struct BitPatterns {
117117
/// type so it can be packed and unpacked into a `bits` sized integer,
118118
/// `Compressor` is specialized on signed-ness so no runtime cost is incurred.
119119
/// The `pack` method also checks that the passed in `UserValue` is valid.
120-
template <typename T, unsigned Bits, bool = std::is_unsigned<T>::value>
120+
template <typename T, unsigned Bits, bool = std::is_unsigned_v<T>>
121121
struct Compressor {
122-
static_assert(std::is_unsigned<T>::value, "T must be unsigned");
122+
static_assert(std::is_unsigned_v<T>, "T must be unsigned");
123123
using BP = BitPatterns<T, Bits>;
124124

125125
static T pack(T UserValue, T UserMaxValue) {
@@ -132,7 +132,7 @@ struct Compressor {
132132
};
133133

134134
template <typename T, unsigned Bits> struct Compressor<T, Bits, false> {
135-
static_assert(std::is_signed<T>::value, "T must be signed");
135+
static_assert(std::is_signed_v<T>, "T must be signed");
136136
using BP = BitPatterns<T, Bits>;
137137

138138
static T pack(T UserValue, T UserMaxValue) {
@@ -154,8 +154,7 @@ template <typename T, unsigned Bits> struct Compressor<T, Bits, false> {
154154
/// Impl is where Bifield description and Storage are put together to interact
155155
/// with values.
156156
template <typename Bitfield, typename StorageType> struct Impl {
157-
static_assert(std::is_unsigned<StorageType>::value,
158-
"Storage must be unsigned");
157+
static_assert(std::is_unsigned_v<StorageType>, "Storage must be unsigned");
159158
using IntegerType = typename Bitfield::IntegerType;
160159
using C = Compressor<IntegerType, Bitfield::Bits>;
161160
using BP = BitPatterns<StorageType, Bitfield::Bits>;
@@ -193,8 +192,7 @@ template <typename Bitfield, typename StorageType> struct Impl {
193192
/// consistent semantics, this excludes typed enums and `bool` that are replaced
194193
/// with their unsigned counterparts. The correct type is restored in the public
195194
/// API.
196-
template <typename T, bool = std::is_enum<T>::value>
197-
struct ResolveUnderlyingType {
195+
template <typename T, bool = std::is_enum_v<T>> struct ResolveUnderlyingType {
198196
using type = std::underlying_type_t<T>;
199197
};
200198
template <typename T> struct ResolveUnderlyingType<T, false> {
@@ -217,7 +215,7 @@ struct Bitfield {
217215
/// \tparam Size The size of the field.
218216
/// \tparam MaxValue For enums the maximum enum allowed.
219217
template <typename T, unsigned Offset, unsigned Size,
220-
T MaxValue = std::is_enum<T>::value
218+
T MaxValue = std::is_enum_v<T>
221219
? T(0) // coupled with static_assert below
222220
: std::numeric_limits<T>::max()>
223221
struct Element {
@@ -236,12 +234,11 @@ struct Bitfield {
236234
static_assert(Bits > 0, "Bits must be non zero");
237235
static constexpr size_t TypeBits = sizeof(IntegerType) * CHAR_BIT;
238236
static_assert(Bits <= TypeBits, "Bits may not be greater than T size");
239-
static_assert(!std::is_enum<T>::value || MaxValue != T(0),
237+
static_assert(!std::is_enum_v<T> || MaxValue != T(0),
240238
"Enum Bitfields must provide a MaxValue");
241-
static_assert(!std::is_enum<T>::value ||
242-
std::is_unsigned<IntegerType>::value,
239+
static_assert(!std::is_enum_v<T> || std::is_unsigned_v<IntegerType>,
243240
"Enum must be unsigned");
244-
static_assert(std::is_integral<IntegerType>::value &&
241+
static_assert(std::is_integral_v<IntegerType> &&
245242
std::numeric_limits<IntegerType>::is_integer,
246243
"IntegerType must be an integer type");
247244

llvm/include/llvm/ADT/CoalescingBitVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace llvm {
3636
///
3737
/// \tparam IndexT - The type of the index into the bitvector.
3838
template <typename IndexT> class CoalescingBitVector {
39-
static_assert(std::is_unsigned<IndexT>::value,
39+
static_assert(std::is_unsigned_v<IndexT>,
4040
"Index must be an unsigned integer.");
4141

4242
using ThisT = CoalescingBitVector<IndexT>;

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class DenseMapBase : public DebugEpochBase {
464464
}
465465

466466
static const KeyT getEmptyKey() {
467-
static_assert(std::is_base_of<DenseMapBase, DerivedT>::value,
467+
static_assert(std::is_base_of_v<DenseMapBase, DerivedT>,
468468
"Must pass the derived type to this template!");
469469
return KeyInfoT::getEmptyKey();
470470
}

llvm/include/llvm/ADT/FoldingSet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ struct FoldingSetTrait<std::pair<T1, T2>> {
830830
};
831831

832832
template <typename T>
833-
struct FoldingSetTrait<T, std::enable_if_t<std::is_enum<T>::value>> {
833+
struct FoldingSetTrait<T, std::enable_if_t<std::is_enum_v<T>>> {
834834
static void Profile(const T &X, FoldingSetNodeID &ID) {
835835
ID.AddInteger(static_cast<std::underlying_type_t<T>>(X));
836836
}

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,20 @@ namespace detail {
6060
template <typename T>
6161
using EnableIfTrivial =
6262
std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
63-
std::is_trivially_destructible<T>::value>;
63+
std::is_trivially_destructible_v<T>>;
6464
template <typename CallableT, typename ThisT>
6565
using EnableUnlessSameType =
66-
std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>::value>;
66+
std::enable_if_t<!std::is_same_v<remove_cvref_t<CallableT>, ThisT>>;
6767
template <typename CallableT, typename Ret, typename... Params>
68-
using EnableIfCallable = std::enable_if_t<std::disjunction<
68+
using EnableIfCallable = std::enable_if_t<std::disjunction_v<
6969
std::is_void<Ret>,
7070
std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
7171
Ret>,
7272
std::is_same<const decltype(std::declval<CallableT>()(
7373
std::declval<Params>()...)),
7474
Ret>,
75-
std::is_convertible<decltype(std::declval<CallableT>()(
76-
std::declval<Params>()...)),
77-
Ret>>::value>;
75+
std::is_convertible<
76+
decltype(std::declval<CallableT>()(std::declval<Params>()...)), Ret>>>;
7877

7978
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
8079
protected:
@@ -97,7 +96,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
9796
// It doesn't have to be exact though, and in one way it is more strict
9897
// because we want to still be able to observe either moves *or* copies.
9998
template <typename T> struct AdjustedParamTBase {
100-
static_assert(!std::is_reference<T>::value,
99+
static_assert(!std::is_reference_v<T>,
101100
"references should be handled by template specialization");
102101
using type = std::conditional_t<
103102
llvm::is_trivially_copy_constructible<T>::value &&

llvm/include/llvm/ADT/Hashing.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,12 @@ inline uint64_t get_execution_seed() {
355355
// for equality. For all the platforms we care about, this holds for integers
356356
// and pointers, but there are platforms where it doesn't and we would like to
357357
// support user-defined types which happen to satisfy this property.
358-
template <typename T> struct is_hashable_data
359-
: std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
360-
std::is_pointer<T>::value) &&
361-
64 % sizeof(T) == 0)> {};
358+
template <typename T>
359+
struct is_hashable_data
360+
: std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
361+
std::is_pointer_v<T>)&&64 %
362+
sizeof(T) ==
363+
0)> {};
362364

363365
// Special case std::pair to detect when both types are viable and when there
364366
// is no alignment-derived padding in the pair. This is a bit of a lie because

llvm/include/llvm/ADT/IntrusiveRefCntPtr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ template <typename T> class IntrusiveRefCntPtr {
177177
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S) : Obj(S.Obj) { S.Obj = nullptr; }
178178

179179
template <class X,
180-
std::enable_if_t<std::is_convertible<X *, T *>::value, bool> = true>
180+
std::enable_if_t<std::is_convertible_v<X *, T *>, bool> = true>
181181
IntrusiveRefCntPtr(IntrusiveRefCntPtr<X> S) : Obj(S.get()) {
182182
S.Obj = nullptr;
183183
}
184184

185185
template <class X,
186-
std::enable_if_t<std::is_convertible<X *, T *>::value, bool> = true>
186+
std::enable_if_t<std::is_convertible_v<X *, T *>, bool> = true>
187187
IntrusiveRefCntPtr(std::unique_ptr<X> S) : Obj(S.release()) {
188188
retain();
189189
}

0 commit comments

Comments
 (0)