[llvm] 9395cf0 - [ADT] Apply fixes from modernize-type-traits (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 16 16:24:45 PDT 2023
Author: Kazu Hirata
Date: 2023-04-16T16:24:34-07:00
New Revision: 9395cf063a013003704118deccf7633533170a5b
URL: https://github.com/llvm/llvm-project/commit/9395cf063a013003704118deccf7633533170a5b
DIFF: https://github.com/llvm/llvm-project/commit/9395cf063a013003704118deccf7633533170a5b.diff
LOG: [ADT] Apply fixes from modernize-type-traits (NFC)
Added:
Modified:
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/ADT/Any.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/Bitfields.h
llvm/include/llvm/ADT/CoalescingBitVector.h
llvm/include/llvm/ADT/DenseMap.h
llvm/include/llvm/ADT/FoldingSet.h
llvm/include/llvm/ADT/FunctionExtras.h
llvm/include/llvm/ADT/Hashing.h
llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
llvm/include/llvm/ADT/PointerIntPair.h
llvm/include/llvm/ADT/PriorityWorklist.h
llvm/include/llvm/ADT/STLExtras.h
llvm/include/llvm/ADT/STLFunctionalExtras.h
llvm/include/llvm/ADT/Sequence.h
llvm/include/llvm/ADT/SmallVector.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/ADT/TinyPtrVector.h
llvm/include/llvm/ADT/bit.h
llvm/include/llvm/ADT/iterator.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index f5eb9f38aea4e..80d9d212934be 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -757,7 +757,7 @@ class APFloat : public APFloatBase {
typedef detail::IEEEFloat IEEEFloat;
typedef detail::DoubleAPFloat DoubleAPFloat;
- static_assert(std::is_standard_layout<IEEEFloat>::value);
+ static_assert(std::is_standard_layout_v<IEEEFloat>);
union Storage {
const fltSemantics *semantics;
@@ -849,9 +849,9 @@ class APFloat : public APFloatBase {
} U;
template <typename T> static bool usesLayout(const fltSemantics &Semantics) {
- static_assert(std::is_same<T, IEEEFloat>::value ||
- std::is_same<T, DoubleAPFloat>::value);
- if (std::is_same<T, DoubleAPFloat>::value) {
+ static_assert(std::is_same_v<T, IEEEFloat> ||
+ std::is_same_v<T, DoubleAPFloat>);
+ if (std::is_same_v<T, DoubleAPFloat>) {
return &Semantics == &PPCDoubleDouble();
}
return &Semantics != &PPCDoubleDouble();
@@ -912,7 +912,7 @@ class APFloat : public APFloatBase {
APFloat(const fltSemantics &Semantics, StringRef S);
APFloat(const fltSemantics &Semantics, integerPart I) : U(Semantics, I) {}
template <typename T,
- typename = std::enable_if_t<std::is_floating_point<T>::value>>
+ typename = std::enable_if_t<std::is_floating_point_v<T>>>
APFloat(const fltSemantics &Semantics, T V) = delete;
// TODO: Remove this constructor. This isn't faster than the first one.
APFloat(const fltSemantics &Semantics, uninitializedTag)
diff --git a/llvm/include/llvm/ADT/Any.h b/llvm/include/llvm/ADT/Any.h
index acb7101a5145f..4231427713346 100644
--- a/llvm/include/llvm/ADT/Any.h
+++ b/llvm/include/llvm/ADT/Any.h
@@ -70,7 +70,7 @@ class LLVM_EXTERNAL_VISIBILITY Any {
// instead.
template <typename T,
std::enable_if_t<
- std::conjunction<
+ std::conjunction_v<
std::negation<std::is_same<std::decay_t<T>, Any>>,
// We also disable this overload when an `Any` object can be
// converted to the parameter type because in that case,
@@ -83,7 +83,7 @@ class LLVM_EXTERNAL_VISIBILITY Any {
// adopting it to work-around usage of `Any` with types that
// need to be implicitly convertible from an `Any`.
std::negation<std::is_convertible<Any, std::decay_t<T>>>,
- std::is_copy_constructible<std::decay_t<T>>>::value,
+ std::is_copy_constructible<std::decay_t<T>>>,
int> = 0>
Any(T &&Value) {
Storage =
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index a25cf1cf817ef..ebcf087d93e09 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -122,8 +122,8 @@ namespace llvm {
/// ensure that only ArrayRefs of pointers can be converted.
template <typename U>
ArrayRef(const ArrayRef<U *> &A,
- std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
- * = nullptr)
+ std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
+ nullptr)
: Data(A.data()), Length(A.size()) {}
/// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
@@ -132,7 +132,7 @@ namespace llvm {
template <typename U, typename DummyT>
/*implicit*/ ArrayRef(
const SmallVectorTemplateCommon<U *, DummyT> &Vec,
- std::enable_if_t<std::is_convertible<U *const *, T const *>::value> * =
+ std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
nullptr)
: Data(Vec.data()), Length(Vec.size()) {}
@@ -140,8 +140,8 @@ namespace llvm {
/// to ensure that only vectors of pointers can be converted.
template <typename U, typename A>
ArrayRef(const std::vector<U *, A> &Vec,
- std::enable_if_t<std::is_convertible<U *const *, T const *>::value>
- * = nullptr)
+ std::enable_if_t<std::is_convertible_v<U *const *, T const *>> * =
+ nullptr)
: Data(Vec.data()), Length(Vec.size()) {}
/// @}
@@ -261,7 +261,7 @@ namespace llvm {
/// The declaration here is extra complicated so that "arrayRef = {}"
/// continues to select the move assignment operator.
template <typename U>
- std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
+ std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &
operator=(U &&Temporary) = delete;
/// Disallow accidental assignment from a temporary.
@@ -269,7 +269,7 @@ namespace llvm {
/// The declaration here is extra complicated so that "arrayRef = {}"
/// continues to select the move assignment operator.
template <typename U>
- std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>> &
+ std::enable_if_t<std::is_same_v<U, T>, ArrayRef<T>> &
operator=(std::initializer_list<U>) = delete;
/// @}
diff --git a/llvm/include/llvm/ADT/Bitfields.h b/llvm/include/llvm/ADT/Bitfields.h
index 4064d716f8a77..1fd9346f3bbd2 100644
--- a/llvm/include/llvm/ADT/Bitfields.h
+++ b/llvm/include/llvm/ADT/Bitfields.h
@@ -117,9 +117,9 @@ template <typename T, unsigned Bits> struct BitPatterns {
/// type so it can be packed and unpacked into a `bits` sized integer,
/// `Compressor` is specialized on signed-ness so no runtime cost is incurred.
/// The `pack` method also checks that the passed in `UserValue` is valid.
-template <typename T, unsigned Bits, bool = std::is_unsigned<T>::value>
+template <typename T, unsigned Bits, bool = std::is_unsigned_v<T>>
struct Compressor {
- static_assert(std::is_unsigned<T>::value, "T must be unsigned");
+ static_assert(std::is_unsigned_v<T>, "T must be unsigned");
using BP = BitPatterns<T, Bits>;
static T pack(T UserValue, T UserMaxValue) {
@@ -132,7 +132,7 @@ struct Compressor {
};
template <typename T, unsigned Bits> struct Compressor<T, Bits, false> {
- static_assert(std::is_signed<T>::value, "T must be signed");
+ static_assert(std::is_signed_v<T>, "T must be signed");
using BP = BitPatterns<T, Bits>;
static T pack(T UserValue, T UserMaxValue) {
@@ -154,8 +154,7 @@ template <typename T, unsigned Bits> struct Compressor<T, Bits, false> {
/// Impl is where Bifield description and Storage are put together to interact
/// with values.
template <typename Bitfield, typename StorageType> struct Impl {
- static_assert(std::is_unsigned<StorageType>::value,
- "Storage must be unsigned");
+ static_assert(std::is_unsigned_v<StorageType>, "Storage must be unsigned");
using IntegerType = typename Bitfield::IntegerType;
using C = Compressor<IntegerType, Bitfield::Bits>;
using BP = BitPatterns<StorageType, Bitfield::Bits>;
@@ -193,8 +192,7 @@ template <typename Bitfield, typename StorageType> struct Impl {
/// consistent semantics, this excludes typed enums and `bool` that are replaced
/// with their unsigned counterparts. The correct type is restored in the public
/// API.
-template <typename T, bool = std::is_enum<T>::value>
-struct ResolveUnderlyingType {
+template <typename T, bool = std::is_enum_v<T>> struct ResolveUnderlyingType {
using type = std::underlying_type_t<T>;
};
template <typename T> struct ResolveUnderlyingType<T, false> {
@@ -217,7 +215,7 @@ struct Bitfield {
/// \tparam Size The size of the field.
/// \tparam MaxValue For enums the maximum enum allowed.
template <typename T, unsigned Offset, unsigned Size,
- T MaxValue = std::is_enum<T>::value
+ T MaxValue = std::is_enum_v<T>
? T(0) // coupled with static_assert below
: std::numeric_limits<T>::max()>
struct Element {
@@ -236,12 +234,11 @@ struct Bitfield {
static_assert(Bits > 0, "Bits must be non zero");
static constexpr size_t TypeBits = sizeof(IntegerType) * CHAR_BIT;
static_assert(Bits <= TypeBits, "Bits may not be greater than T size");
- static_assert(!std::is_enum<T>::value || MaxValue != T(0),
+ static_assert(!std::is_enum_v<T> || MaxValue != T(0),
"Enum Bitfields must provide a MaxValue");
- static_assert(!std::is_enum<T>::value ||
- std::is_unsigned<IntegerType>::value,
+ static_assert(!std::is_enum_v<T> || std::is_unsigned_v<IntegerType>,
"Enum must be unsigned");
- static_assert(std::is_integral<IntegerType>::value &&
+ static_assert(std::is_integral_v<IntegerType> &&
std::numeric_limits<IntegerType>::is_integer,
"IntegerType must be an integer type");
diff --git a/llvm/include/llvm/ADT/CoalescingBitVector.h b/llvm/include/llvm/ADT/CoalescingBitVector.h
index 4940bc1c2c18b..54fd156e61c5b 100644
--- a/llvm/include/llvm/ADT/CoalescingBitVector.h
+++ b/llvm/include/llvm/ADT/CoalescingBitVector.h
@@ -36,7 +36,7 @@ namespace llvm {
///
/// \tparam IndexT - The type of the index into the bitvector.
template <typename IndexT> class CoalescingBitVector {
- static_assert(std::is_unsigned<IndexT>::value,
+ static_assert(std::is_unsigned_v<IndexT>,
"Index must be an unsigned integer.");
using ThisT = CoalescingBitVector<IndexT>;
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 8a680c031d302..87c82b0c4fce1 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -464,7 +464,7 @@ class DenseMapBase : public DebugEpochBase {
}
static const KeyT getEmptyKey() {
- static_assert(std::is_base_of<DenseMapBase, DerivedT>::value,
+ static_assert(std::is_base_of_v<DenseMapBase, DerivedT>,
"Must pass the derived type to this template!");
return KeyInfoT::getEmptyKey();
}
diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index 237668921cbb2..0ce6643f45be7 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/include/llvm/ADT/FoldingSet.h
@@ -830,7 +830,7 @@ struct FoldingSetTrait<std::pair<T1, T2>> {
};
template <typename T>
-struct FoldingSetTrait<T, std::enable_if_t<std::is_enum<T>::value>> {
+struct FoldingSetTrait<T, std::enable_if_t<std::is_enum_v<T>>> {
static void Profile(const T &X, FoldingSetNodeID &ID) {
ID.AddInteger(static_cast<std::underlying_type_t<T>>(X));
}
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 8f04277cdf0e5..9eda8657aec67 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -60,21 +60,20 @@ namespace detail {
template <typename T>
using EnableIfTrivial =
std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
- std::is_trivially_destructible<T>::value>;
+ std::is_trivially_destructible_v<T>>;
template <typename CallableT, typename ThisT>
using EnableUnlessSameType =
- std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>::value>;
+ std::enable_if_t<!std::is_same_v<remove_cvref_t<CallableT>, ThisT>>;
template <typename CallableT, typename Ret, typename... Params>
-using EnableIfCallable = std::enable_if_t<std::disjunction<
+using EnableIfCallable = std::enable_if_t<std::disjunction_v<
std::is_void<Ret>,
std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
Ret>,
std::is_same<const decltype(std::declval<CallableT>()(
std::declval<Params>()...)),
Ret>,
- std::is_convertible<decltype(std::declval<CallableT>()(
- std::declval<Params>()...)),
- Ret>>::value>;
+ std::is_convertible<
+ decltype(std::declval<CallableT>()(std::declval<Params>()...)), Ret>>>;
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
protected:
@@ -97,7 +96,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
// It doesn't have to be exact though, and in one way it is more strict
// because we want to still be able to observe either moves *or* copies.
template <typename T> struct AdjustedParamTBase {
- static_assert(!std::is_reference<T>::value,
+ static_assert(!std::is_reference_v<T>,
"references should be handled by template specialization");
using type = std::conditional_t<
llvm::is_trivially_copy_constructible<T>::value &&
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index ef983105c7bae..dc03a11cd4953 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -355,10 +355,12 @@ inline uint64_t get_execution_seed() {
// for equality. For all the platforms we care about, this holds for integers
// and pointers, but there are platforms where it doesn't and we would like to
// support user-defined types which happen to satisfy this property.
-template <typename T> struct is_hashable_data
- : std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
- std::is_pointer<T>::value) &&
- 64 % sizeof(T) == 0)> {};
+template <typename T>
+struct is_hashable_data
+ : std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
+ std::is_pointer_v<T>)&&64 %
+ sizeof(T) ==
+ 0)> {};
// Special case std::pair to detect when both types are viable and when there
// is no alignment-derived padding in the pair. This is a bit of a lie because
diff --git a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
index e41eb0639ce30..40abf0a1c7be6 100644
--- a/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
+++ b/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h
@@ -177,13 +177,13 @@ template <typename T> class IntrusiveRefCntPtr {
IntrusiveRefCntPtr(IntrusiveRefCntPtr &&S) : Obj(S.Obj) { S.Obj = nullptr; }
template <class X,
- std::enable_if_t<std::is_convertible<X *, T *>::value, bool> = true>
+ std::enable_if_t<std::is_convertible_v<X *, T *>, bool> = true>
IntrusiveRefCntPtr(IntrusiveRefCntPtr<X> S) : Obj(S.get()) {
S.Obj = nullptr;
}
template <class X,
- std::enable_if_t<std::is_convertible<X *, T *>::value, bool> = true>
+ std::enable_if_t<std::is_convertible_v<X *, T *>, bool> = true>
IntrusiveRefCntPtr(std::unique_ptr<X> S) : Obj(S.release()) {
retain();
}
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index f73f5bcd6ce0c..5b6cd3ecdf22d 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -30,9 +30,9 @@ template <typename Ptr> struct PunnedPointer {
// Asserts that allow us to let the compiler implement the destructor and
// copy/move constructors
- static_assert(std::is_trivially_destructible<Ptr>::value, "");
- static_assert(std::is_trivially_copy_constructible<Ptr>::value, "");
- static_assert(std::is_trivially_move_constructible<Ptr>::value, "");
+ static_assert(std::is_trivially_destructible_v<Ptr>, "");
+ static_assert(std::is_trivially_copy_constructible_v<Ptr>, "");
+ static_assert(std::is_trivially_move_constructible_v<Ptr>, "");
explicit constexpr PunnedPointer(intptr_t i = 0) { *this = i; }
diff --git a/llvm/include/llvm/ADT/PriorityWorklist.h b/llvm/include/llvm/ADT/PriorityWorklist.h
index 2b6510f42d569..7c76744d017a3 100644
--- a/llvm/include/llvm/ADT/PriorityWorklist.h
+++ b/llvm/include/llvm/ADT/PriorityWorklist.h
@@ -109,7 +109,7 @@ class PriorityWorklist {
/// Insert a sequence of new elements into the PriorityWorklist.
template <typename SequenceT>
- std::enable_if_t<!std::is_convertible<SequenceT, T>::value>
+ std::enable_if_t<!std::is_convertible_v<SequenceT, T>>
insert(SequenceT &&Input) {
if (std::begin(Input) == std::end(Input))
// Nothing to do for an empty input sequence.
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 6475ac7976072..f683a2143095a 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -166,7 +166,7 @@ using is_detected = typename detail::detector<void, Op, Args...>::value_t;
/// * To access the number of arguments: Traits::num_args
/// * To access the type of an argument: Traits::arg_t<Index>
/// * To access the type of the result: Traits::result_t
-template <typename T, bool isClass = std::is_class<T>::value>
+template <typename T, bool isClass = std::is_class_v<T>>
struct function_traits : public function_traits<decltype(&T::operator())> {};
/// Overload for class function types.
@@ -265,9 +265,9 @@ using TypeAtIndex = std::tuple_element_t<I, std::tuple<Ts...>>;
/// Helper which adds two underlying types of enumeration type.
/// Implicit conversion to a common type is accepted.
template <typename EnumTy1, typename EnumTy2,
- typename UT1 = std::enable_if_t<std::is_enum<EnumTy1>::value,
+ typename UT1 = std::enable_if_t<std::is_enum_v<EnumTy1>,
std::underlying_type_t<EnumTy1>>,
- typename UT2 = std::enable_if_t<std::is_enum<EnumTy2>::value,
+ typename UT2 = std::enable_if_t<std::is_enum_v<EnumTy2>,
std::underlying_type_t<EnumTy2>>>
constexpr auto addEnumValues(EnumTy1 LHS, EnumTy2 RHS) {
return static_cast<UT1>(LHS) + static_cast<UT2>(RHS);
@@ -638,9 +638,9 @@ template <> struct fwd_or_bidi_tag_impl<true> {
/// of \p IterT does not derive from bidirectional_iterator_tag, and to
/// bidirectional_iterator_tag otherwise.
template <typename IterT> struct fwd_or_bidi_tag {
- using type = typename fwd_or_bidi_tag_impl<std::is_base_of<
+ using type = typename fwd_or_bidi_tag_impl<std::is_base_of_v<
std::bidirectional_iterator_tag,
- typename std::iterator_traits<IterT>::iterator_category>::value>::type;
+ typename std::iterator_traits<IterT>::iterator_category>>::type;
};
} // namespace detail
@@ -1421,8 +1421,9 @@ class indexed_accessor_range_base {
}
/// Allow conversion to any type accepting an iterator_range.
- template <typename RangeT, typename = std::enable_if_t<std::is_constructible<
- RangeT, iterator_range<iterator>>::value>>
+ template <typename RangeT,
+ typename = std::enable_if_t<
+ std::is_constructible_v<RangeT, iterator_range<iterator>>>>
operator RangeT() const {
return RangeT(iterator_range<iterator>(*this));
}
@@ -1500,7 +1501,7 @@ namespace detail {
/// always be a reference, to avoid returning a reference to a temporary.
template <typename EltTy, typename FirstTy> class first_or_second_type {
public:
- using type = std::conditional_t<std::is_reference<EltTy>::value, FirstTy,
+ using type = std::conditional_t<std::is_reference_v<EltTy>, FirstTy,
std::remove_reference_t<FirstTy>>;
};
} // end namespace detail
@@ -1774,12 +1775,13 @@ inline void sort(Container &&C, Compare Comp) {
/// Get the size of a range. This is a wrapper function around std::distance
/// which is only enabled when the operation is O(1).
template <typename R>
-auto size(R &&Range,
- std::enable_if_t<
- std::is_base_of<std::random_access_iterator_tag,
- typename std::iterator_traits<decltype(
- Range.begin())>::iterator_category>::value,
- void> * = nullptr) {
+auto size(
+ R &&Range,
+ std::enable_if_t<
+ std::is_base_of_v<std::random_access_iterator_tag,
+ typename std::iterator_traits<
+ decltype(Range.begin())>::iterator_category>,
+ void> * = nullptr) {
return std::distance(Range.begin(), Range.end());
}
@@ -2167,11 +2169,11 @@ void replace(Container &Cont, typename Container::iterator ContIt,
/// [&](StringRef name) { os << name; },
/// [&] { os << ", "; });
/// \endcode
-template <typename ForwardIterator, typename UnaryFunctor,
- typename NullaryFunctor,
- typename = std::enable_if_t<
- !std::is_constructible<StringRef, UnaryFunctor>::value &&
- !std::is_constructible<StringRef, NullaryFunctor>::value>>
+template <
+ typename ForwardIterator, typename UnaryFunctor, typename NullaryFunctor,
+ typename =
+ std::enable_if_t<!std::is_constructible_v<StringRef, UnaryFunctor> &&
+ !std::is_constructible_v<StringRef, NullaryFunctor>>>
inline void interleave(ForwardIterator begin, ForwardIterator end,
UnaryFunctor each_fn, NullaryFunctor between_fn) {
if (begin == end)
@@ -2186,8 +2188,8 @@ inline void interleave(ForwardIterator begin, ForwardIterator end,
template <typename Container, typename UnaryFunctor, typename NullaryFunctor,
typename = std::enable_if_t<
- !std::is_constructible<StringRef, UnaryFunctor>::value &&
- !std::is_constructible<StringRef, NullaryFunctor>::value>>
+ !std::is_constructible_v<StringRef, UnaryFunctor> &&
+ !std::is_constructible_v<StringRef, NullaryFunctor>>>
inline void interleave(const Container &c, UnaryFunctor each_fn,
NullaryFunctor between_fn) {
interleave(c.begin(), c.end(), each_fn, between_fn);
@@ -2490,11 +2492,11 @@ bool hasNItems(
IterTy &&Begin, IterTy &&End, unsigned N,
Pred &&ShouldBeCounted =
[](const decltype(*std::declval<IterTy>()) &) { return true; },
- std::enable_if_t<
- !std::is_base_of<std::random_access_iterator_tag,
+ std::enable_if_t<!std::is_base_of_v<
+ std::random_access_iterator_tag,
typename std::iterator_traits<std::remove_reference_t<
- decltype(Begin)>>::iterator_category>::value,
- void> * = nullptr) {
+ decltype(Begin)>>::iterator_category>,
+ void> * = nullptr) {
for (; N; ++Begin) {
if (Begin == End)
return false; // Too few.
@@ -2515,11 +2517,11 @@ bool hasNItemsOrMore(
IterTy &&Begin, IterTy &&End, unsigned N,
Pred &&ShouldBeCounted =
[](const decltype(*std::declval<IterTy>()) &) { return true; },
- std::enable_if_t<
- !std::is_base_of<std::random_access_iterator_tag,
+ std::enable_if_t<!std::is_base_of_v<
+ std::random_access_iterator_tag,
typename std::iterator_traits<std::remove_reference_t<
- decltype(Begin)>>::iterator_category>::value,
- void> * = nullptr) {
+ decltype(Begin)>>::iterator_category>,
+ void> * = nullptr) {
for (; N; ++Begin) {
if (Begin == End)
return false; // Too few.
diff --git a/llvm/include/llvm/ADT/STLFunctionalExtras.h b/llvm/include/llvm/ADT/STLFunctionalExtras.h
index dd7fc6dc74864..f3044febe4621 100644
--- a/llvm/include/llvm/ADT/STLFunctionalExtras.h
+++ b/llvm/include/llvm/ADT/STLFunctionalExtras.h
@@ -54,13 +54,13 @@ class function_ref<Ret(Params...)> {
function_ref(
Callable &&callable,
// This is not the copy-constructor.
- std::enable_if_t<!std::is_same<remove_cvref_t<Callable>,
- function_ref>::value> * = nullptr,
+ std::enable_if_t<!std::is_same_v<remove_cvref_t<Callable>, function_ref>>
+ * = nullptr,
// Functor must be callable and return a suitable type.
- std::enable_if_t<std::is_void<Ret>::value ||
- std::is_convertible<decltype(std::declval<Callable>()(
- std::declval<Params>()...)),
- Ret>::value> * = nullptr)
+ std::enable_if_t<std::is_void_v<Ret> ||
+ std::is_convertible_v<decltype(std::declval<Callable>()(
+ std::declval<Params>()...)),
+ Ret>> * = nullptr)
: callback(callback_fn<std::remove_reference_t<Callable>>),
callable(reinterpret_cast<intptr_t>(&callable)) {}
diff --git a/llvm/include/llvm/ADT/Sequence.h b/llvm/include/llvm/ADT/Sequence.h
index ddda9a95a7bc6..9a63552b39ec1 100644
--- a/llvm/include/llvm/ADT/Sequence.h
+++ b/llvm/include/llvm/ADT/Sequence.h
@@ -126,7 +126,7 @@ template <typename T, typename U> bool canTypeFitValue(const U Value) {
struct CheckedInt {
// Integral constructor, asserts if Value cannot be represented as intmax_t.
template <typename Integral,
- std::enable_if_t<std::is_integral<Integral>::value, bool> = 0>
+ std::enable_if_t<std::is_integral_v<Integral>, bool> = 0>
static CheckedInt from(Integral FromValue) {
if (!canTypeFitValue<intmax_t>(FromValue))
assertOutOfBounds();
@@ -136,8 +136,7 @@ struct CheckedInt {
}
// Enum constructor, asserts if Value cannot be represented as intmax_t.
- template <typename Enum,
- std::enable_if_t<std::is_enum<Enum>::value, bool> = 0>
+ template <typename Enum, std::enable_if_t<std::is_enum_v<Enum>, bool> = 0>
static CheckedInt from(Enum FromValue) {
using type = std::underlying_type_t<Enum>;
return from<type>(static_cast<type>(FromValue));
@@ -163,7 +162,7 @@ struct CheckedInt {
// Convert to integral, asserts if Value cannot be represented as Integral.
template <typename Integral,
- std::enable_if_t<std::is_integral<Integral>::value, bool> = 0>
+ std::enable_if_t<std::is_integral_v<Integral>, bool> = 0>
Integral to() const {
if (!canTypeFitValue<Integral>(Value))
assertOutOfBounds();
@@ -172,8 +171,7 @@ struct CheckedInt {
// Convert to enum, asserts if Value cannot be represented as Enum's
// underlying type.
- template <typename Enum,
- std::enable_if_t<std::is_enum<Enum>::value, bool> = 0>
+ template <typename Enum, std::enable_if_t<std::is_enum_v<Enum>, bool> = 0>
Enum to() const {
using type = std::underlying_type_t<Enum>;
return Enum(to<type>());
@@ -287,9 +285,9 @@ template <typename T> struct iota_range {
auto rend() const { return const_reverse_iterator(BeginValue - 1); }
private:
- static_assert(std::is_integral<T>::value || std::is_enum<T>::value,
+ static_assert(std::is_integral_v<T> || std::is_enum_v<T>,
"T must be an integral or enum type");
- static_assert(std::is_same<T, std::remove_cv_t<T>>::value,
+ static_assert(std::is_same_v<T, std::remove_cv_t<T>>,
"T must not be const nor volatile");
iterator BeginValue;
@@ -300,8 +298,8 @@ template <typename T> struct iota_range {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX] for
/// forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX] for reverse
/// iteration).
-template <typename T, typename = std::enable_if_t<std::is_integral<T>::value &&
- !std::is_enum<T>::value>>
+template <typename T, typename = std::enable_if_t<std::is_integral_v<T> &&
+ !std::is_enum_v<T>>>
auto seq(T Begin, T End) {
return iota_range<T>(Begin, End, false);
}
@@ -310,8 +308,8 @@ auto seq(T Begin, T End) {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX - 1]
/// for forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX - 1] for reverse
/// iteration).
-template <typename T, typename = std::enable_if_t<std::is_integral<T>::value &&
- !std::is_enum<T>::value>>
+template <typename T, typename = std::enable_if_t<std::is_integral_v<T> &&
+ !std::is_enum_v<T>>>
auto seq_inclusive(T Begin, T End) {
return iota_range<T>(Begin, End, true);
}
@@ -322,8 +320,7 @@ auto seq_inclusive(T Begin, T End) {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX] for
/// forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX] for reverse
/// iteration).
-template <typename EnumT,
- typename = std::enable_if_t<std::is_enum<EnumT>::value>>
+template <typename EnumT, typename = std::enable_if_t<std::is_enum_v<EnumT>>>
auto enum_seq(EnumT Begin, EnumT End) {
static_assert(enum_iteration_traits<EnumT>::is_iterable,
"Enum type is not marked as iterable.");
@@ -337,8 +334,7 @@ auto enum_seq(EnumT Begin, EnumT End) {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX] for
/// forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX] for reverse
/// iteration).
-template <typename EnumT,
- typename = std::enable_if_t<std::is_enum<EnumT>::value>>
+template <typename EnumT, typename = std::enable_if_t<std::is_enum_v<EnumT>>>
auto enum_seq(EnumT Begin, EnumT End, force_iteration_on_noniterable_enum_t) {
return iota_range<EnumT>(Begin, End, false);
}
@@ -349,8 +345,7 @@ auto enum_seq(EnumT Begin, EnumT End, force_iteration_on_noniterable_enum_t) {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX - 1]
/// for forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX - 1] for reverse
/// iteration).
-template <typename EnumT,
- typename = std::enable_if_t<std::is_enum<EnumT>::value>>
+template <typename EnumT, typename = std::enable_if_t<std::is_enum_v<EnumT>>>
auto enum_seq_inclusive(EnumT Begin, EnumT End) {
static_assert(enum_iteration_traits<EnumT>::is_iterable,
"Enum type is not marked as iterable.");
@@ -364,8 +359,7 @@ auto enum_seq_inclusive(EnumT Begin, EnumT End) {
/// Note: Begin and End values have to be within [INTMAX_MIN, INTMAX_MAX - 1]
/// for forward iteration (resp. [INTMAX_MIN + 1, INTMAX_MAX - 1] for reverse
/// iteration).
-template <typename EnumT,
- typename = std::enable_if_t<std::is_enum<EnumT>::value>>
+template <typename EnumT, typename = std::enable_if_t<std::is_enum_v<EnumT>>>
auto enum_seq_inclusive(EnumT Begin, EnumT End,
force_iteration_on_noniterable_enum_t) {
return iota_range<EnumT>(Begin, End, true);
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 93d94916745d2..31ab184f323f2 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -37,9 +37,10 @@ template <typename T> class ArrayRef;
template <typename IteratorT> class iterator_range;
template <class Iterator>
-using EnableIfConvertibleToInputIterator = std::enable_if_t<std::is_convertible<
- typename std::iterator_traits<Iterator>::iterator_category,
- std::input_iterator_tag>::value>;
+using EnableIfConvertibleToInputIterator =
+ std::enable_if_t<std::is_convertible_v<
+ typename std::iterator_traits<Iterator>::iterator_category,
+ std::input_iterator_tag>>;
/// This is all the stuff common to all SmallVectors.
///
@@ -207,10 +208,9 @@ class SmallVectorTemplateCommon
this->assertSafeToReferenceAfterResize(From, 0);
this->assertSafeToReferenceAfterResize(To - 1, 0);
}
- template <
- class ItTy,
- std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>, T *>::value,
- bool> = false>
+ template <class ItTy,
+ std::enable_if_t<!std::is_same_v<std::remove_const_t<ItTy>, T *>,
+ bool> = false>
void assertSafeToReferenceAfterClear(ItTy, ItTy) {}
/// Check whether any part of the range will be invalidated by growing.
@@ -220,10 +220,9 @@ class SmallVectorTemplateCommon
this->assertSafeToAdd(From, To - From);
this->assertSafeToAdd(To - 1, To - From);
}
- template <
- class ItTy,
- std::enable_if_t<!std::is_same<std::remove_const_t<ItTy>, T *>::value,
- bool> = false>
+ template <class ItTy,
+ std::enable_if_t<!std::is_same_v<std::remove_const_t<ItTy>, T *>,
+ bool> = false>
void assertSafeToAddRange(ItTy, ItTy) {}
/// Reserve enough space to add one element, and return the updated element
@@ -328,7 +327,7 @@ class SmallVectorTemplateCommon
/// trivially assignable.
template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
(is_trivially_move_constructible<T>::value) &&
- std::is_trivially_destructible<T>::value>
+ std::is_trivially_destructible_v<T>>
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
friend class SmallVectorTemplateCommon<T>;
@@ -514,7 +513,7 @@ class SmallVectorTemplateBase<T, true> : public SmallVectorTemplateCommon<T> {
template <typename T1, typename T2>
static void uninitialized_copy(
T1 *I, T1 *E, T2 *Dest,
- std::enable_if_t<std::is_same<std::remove_const_t<T1>, T2>::value> * =
+ std::enable_if_t<std::is_same_v<std::remove_const_t<T1>, T2>> * =
nullptr) {
// Use memcpy for PODs iterated by pointers (which includes SmallVector
// iterators): std::uninitialized_copy optimizes to memmove, but we can
@@ -1232,7 +1231,7 @@ class LLVM_GSL_OWNER SmallVector : public SmallVectorImpl<T>,
}
template <typename U,
- typename = std::enable_if_t<std::is_convertible<U, T>::value>>
+ typename = std::enable_if_t<std::is_convertible_v<U, T>>>
explicit SmallVector(ArrayRef<U> A) : SmallVectorImpl<T>(N) {
this->append(A.begin(), A.end());
}
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 868722e19001c..f672784edbc42 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -238,7 +238,7 @@ namespace llvm {
/// The declaration here is extra complicated so that `stringRef = {}`
/// and `stringRef = "abc"` continue to select the move assignment operator.
template <typename T>
- std::enable_if_t<std::is_same<T, std::string>::value, StringRef> &
+ std::enable_if_t<std::is_same_v<T, std::string>, StringRef> &
operator=(T &&Str) = delete;
/// @}
diff --git a/llvm/include/llvm/ADT/TinyPtrVector.h b/llvm/include/llvm/ADT/TinyPtrVector.h
index aa87fd66ac20e..2caa56407e838 100644
--- a/llvm/include/llvm/ADT/TinyPtrVector.h
+++ b/llvm/include/llvm/ADT/TinyPtrVector.h
@@ -151,10 +151,9 @@ class TinyPtrVector {
}
// Implicit conversion to ArrayRef<U> if EltTy* implicitly converts to U*.
- template <
- typename U,
- std::enable_if_t<std::is_convertible<ArrayRef<EltTy>, ArrayRef<U>>::value,
- bool> = false>
+ template <typename U, std::enable_if_t<
+ std::is_convertible_v<ArrayRef<EltTy>, ArrayRef<U>>,
+ bool> = false>
operator ArrayRef<U>() const {
return operator ArrayRef<EltTy>();
}
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 2840c5f608d3e..e416e9ed7266e 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -44,12 +44,11 @@ namespace llvm {
// This implementation of bit_cast is
diff erent from the C++20 one in two ways:
// - It isn't constexpr because that requires compiler support.
// - It requires trivially-constructible To, to avoid UB in the implementation.
-template <
- typename To, typename From,
- typename = std::enable_if_t<sizeof(To) == sizeof(From)>,
- typename = std::enable_if_t<std::is_trivially_constructible<To>::value>,
- typename = std::enable_if_t<std::is_trivially_copyable<To>::value>,
- typename = std::enable_if_t<std::is_trivially_copyable<From>::value>>
+template <typename To, typename From,
+ typename = std::enable_if_t<sizeof(To) == sizeof(From)>,
+ typename = std::enable_if_t<std::is_trivially_constructible_v<To>>,
+ typename = std::enable_if_t<std::is_trivially_copyable_v<To>>,
+ typename = std::enable_if_t<std::is_trivially_copyable_v<From>>>
[[nodiscard]] inline To bit_cast(const From &from) noexcept {
#if __has_builtin(__builtin_bit_cast)
return __builtin_bit_cast(To, from);
diff --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h
index 6f0c42fe08bec..de826dd5e8bac 100644
--- a/llvm/include/llvm/ADT/iterator.h
+++ b/llvm/include/llvm/ADT/iterator.h
@@ -87,10 +87,10 @@ class iterator_facade_base {
protected:
enum {
- IsRandomAccess = std::is_base_of<std::random_access_iterator_tag,
- IteratorCategoryT>::value,
- IsBidirectional = std::is_base_of<std::bidirectional_iterator_tag,
- IteratorCategoryT>::value,
+ IsRandomAccess =
+ std::is_base_of_v<std::random_access_iterator_tag, IteratorCategoryT>,
+ IsBidirectional =
+ std::is_base_of_v<std::bidirectional_iterator_tag, IteratorCategoryT>,
};
/// A proxy object for computing a reference via indirecting a copy of an
@@ -225,12 +225,12 @@ template <
typename DifferenceTypeT =
typename std::iterator_traits<WrappedIteratorT>::
diff erence_type,
typename PointerT = std::conditional_t<
- std::is_same<T, typename std::iterator_traits<
- WrappedIteratorT>::value_type>::value,
+ std::is_same_v<
+ T, typename std::iterator_traits<WrappedIteratorT>::value_type>,
typename std::iterator_traits<WrappedIteratorT>::pointer, T *>,
typename ReferenceT = std::conditional_t<
- std::is_same<T, typename std::iterator_traits<
- WrappedIteratorT>::value_type>::value,
+ std::is_same_v<
+ T, typename std::iterator_traits<WrappedIteratorT>::value_type>,
typename std::iterator_traits<WrappedIteratorT>::reference, T &>>
class iterator_adaptor_base
: public iterator_facade_base<DerivedT, IteratorCategoryT, T,
More information about the llvm-commits
mailing list