[llvm] ec8605f - [llvm] Use std::is_unsigned instead of std::numeric_limits (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 17:35:37 PDT 2022
Author: Kazu Hirata
Date: 2022-08-28T17:35:06-07:00
New Revision: ec8605ff5296f835e148be11f86a7698b4736757
URL: https://github.com/llvm/llvm-project/commit/ec8605ff5296f835e148be11f86a7698b4736757
DIFF: https://github.com/llvm/llvm-project/commit/ec8605ff5296f835e148be11f86a7698b4736757.diff
LOG: [llvm] Use std::is_unsigned instead of std::numeric_limits (NFC)
Added:
Modified:
llvm/include/llvm/ADT/SparseMultiSet.h
llvm/include/llvm/ADT/SparseSet.h
llvm/include/llvm/Support/MathExtras.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/SparseMultiSet.h b/llvm/include/llvm/ADT/SparseMultiSet.h
index ef2a5ea5ed715..d8dbe4023ea64 100644
--- a/llvm/include/llvm/ADT/SparseMultiSet.h
+++ b/llvm/include/llvm/ADT/SparseMultiSet.h
@@ -84,8 +84,7 @@ template<typename ValueT,
typename KeyFunctorT = identity<unsigned>,
typename SparseT = uint8_t>
class SparseMultiSet {
- static_assert(std::numeric_limits<SparseT>::is_integer &&
- !std::numeric_limits<SparseT>::is_signed,
+ static_assert(std::is_unsigned_v<SparseT>,
"SparseT must be an unsigned integer type");
/// The actual data that's stored, as a doubly-linked list implemented via
diff --git a/llvm/include/llvm/ADT/SparseSet.h b/llvm/include/llvm/ADT/SparseSet.h
index 5c7087b1bffef..c9895d7475404 100644
--- a/llvm/include/llvm/ADT/SparseSet.h
+++ b/llvm/include/llvm/ADT/SparseSet.h
@@ -122,8 +122,7 @@ template<typename ValueT,
typename KeyFunctorT = identity<unsigned>,
typename SparseT = uint8_t>
class SparseSet {
- static_assert(std::numeric_limits<SparseT>::is_integer &&
- !std::numeric_limits<SparseT>::is_signed,
+ static_assert(std::is_unsigned_v<SparseT>,
"SparseT must be an unsigned integer type");
using KeyT = typename KeyFunctorT::argument_type;
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index ca3e7b976663a..c318ec6641ec4 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -151,8 +151,7 @@ template <typename T> struct TrailingZerosCounter<T, 8> {
/// valid arguments.
template <typename T>
unsigned countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
- static_assert(std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed,
+ static_assert(std::is_unsigned_v<T>,
"Only unsigned integral types are allowed.");
return llvm::detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
}
@@ -220,8 +219,7 @@ template <typename T> struct LeadingZerosCounter<T, 8> {
/// valid arguments.
template <typename T>
unsigned countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
- static_assert(std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed,
+ static_assert(std::is_unsigned_v<T>,
"Only unsigned integral types are allowed.");
return llvm::detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
}
@@ -504,8 +502,7 @@ constexpr inline bool isPowerOf2_64(uint64_t Value) {
/// ZB_Undefined are valid arguments.
template <typename T>
unsigned countLeadingOnes(T Value, ZeroBehavior ZB = ZB_Width) {
- static_assert(std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed,
+ static_assert(std::is_unsigned_v<T>,
"Only unsigned integral types are allowed.");
return countLeadingZeros<T>(~Value, ZB);
}
@@ -520,8 +517,7 @@ unsigned countLeadingOnes(T Value, ZeroBehavior ZB = ZB_Width) {
/// ZB_Undefined are valid arguments.
template <typename T>
unsigned countTrailingOnes(T Value, ZeroBehavior ZB = ZB_Width) {
- static_assert(std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed,
+ static_assert(std::is_unsigned_v<T>,
"Only unsigned integral types are allowed.");
return countTrailingZeros<T>(~Value, ZB);
}
@@ -531,8 +527,7 @@ unsigned countTrailingOnes(T Value, ZeroBehavior ZB = ZB_Width) {
/// Returns 0 if the word is zero.
template <typename T>
inline unsigned countPopulation(T Value) {
- static_assert(std::numeric_limits<T>::is_integer &&
- !std::numeric_limits<T>::is_signed,
+ static_assert(std::is_unsigned_v<T>,
"Only unsigned integral types are allowed.");
return (unsigned)llvm::popcount(Value);
}
More information about the llvm-commits
mailing list