[llvm] 0e627c9 - [NFC][support] Extract `IsHashableData` out of class
Alexandre Rames via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 09:41:37 PDT 2021
Author: Alexandre Rames
Date: 2021-09-07T09:41:33-07:00
New Revision: 0e627c93be8c87c4ccc245ff86457a7b4f581144
URL: https://github.com/llvm/llvm-project/commit/0e627c93be8c87c4ccc245ff86457a7b4f581144
DIFF: https://github.com/llvm/llvm-project/commit/0e627c93be8c87c4ccc245ff86457a7b4f581144.diff
LOG: [NFC][support] Extract `IsHashableData` out of class
Extract `HashBuilder::IsHashableData` out of class; it does not depend on
template parametres.
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D109205
Added:
Modified:
llvm/include/llvm/Support/HashBuilder.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/HashBuilder.h b/llvm/include/llvm/Support/HashBuilder.h
index 23f73f1b659d..9ff5acf16729 100644
--- a/llvm/include/llvm/Support/HashBuilder.h
+++ b/llvm/include/llvm/Support/HashBuilder.h
@@ -26,6 +26,15 @@
namespace llvm {
+namespace hashbuilder_detail {
+/// Trait to indicate whether a type's bits can be hashed directly (after
+/// endianness correction).
+template <typename U>
+struct IsHashableData
+ : std::integral_constant<bool, is_integral_or_enum<U>::value> {};
+
+} // namespace hashbuilder_detail
+
/// Declares the hasher member, and functions forwarding directly to the hasher.
template <typename HasherT> class HashBuilderBase {
public:
@@ -80,11 +89,6 @@ template <typename HasherT, support::endianness Endianness>
class HashBuilderImpl : public HashBuilderBase<HasherT> {
static_assert(Endianness != support::endianness::native,
"HashBuilder should canonicalize endianness");
- /// Trait to indicate whether a type's bits can be hashed directly (after
- /// endianness correction).
- template <typename U>
- struct IsHashableData
- : std::integral_constant<bool, is_integral_or_enum<U>::value> {};
public:
explicit HashBuilderImpl(HasherT &Hasher)
@@ -95,7 +99,9 @@ class HashBuilderImpl : public HashBuilderBase<HasherT> {
/// Implement hashing for hashable data types, e.g. integral or enum values.
template <typename T>
- std::enable_if_t<IsHashableData<T>::value, HashBuilderImpl &> add(T Value) {
+ std::enable_if_t<hashbuilder_detail::IsHashableData<T>::value,
+ HashBuilderImpl &>
+ add(T Value) {
return adjustForEndiannessAndAdd(Value);
}
@@ -118,7 +124,7 @@ class HashBuilderImpl : public HashBuilderBase<HasherT> {
// details of `ArrayRef::begin()` and `ArrayRef::end()`. Explicitly call
// `update` to guarantee the fast path.
add(Value.size());
- if (IsHashableData<T>::value &&
+ if (hashbuilder_detail::IsHashableData<T>::value &&
Endianness == support::endian::system_endianness()) {
this->update(
makeArrayRef(reinterpret_cast<const uint8_t *>(Value.begin()),
@@ -242,7 +248,7 @@ class HashBuilderImpl : public HashBuilderBase<HasherT> {
/// ```
template <typename T>
std::enable_if_t<is_detected<HasAddHashT, T>::value &&
- !IsHashableData<T>::value,
+ !hashbuilder_detail::IsHashableData<T>::value,
HashBuilderImpl &>
add(const T &Value) {
addHash(*this, Value);
@@ -334,7 +340,7 @@ class HashBuilderImpl : public HashBuilderBase<HasherT> {
}
template <typename T>
- std::enable_if_t<IsHashableData<T>::value &&
+ std::enable_if_t<hashbuilder_detail::IsHashableData<T>::value &&
Endianness == support::endian::system_endianness(),
HashBuilderImpl &>
addRangeElementsImpl(T *First, T *Last, std::forward_iterator_tag) {
More information about the llvm-commits
mailing list