[llvm] a04c0f5 - [IR] Modernize HasCachedHash (NFC) (#159902)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 20 08:15:16 PDT 2025
Author: Kazu Hirata
Date: 2025-09-20T08:15:12-07:00
New Revision: a04c0f5cebfed58fb54969c0f52ce559c7277025
URL: https://github.com/llvm/llvm-project/commit/a04c0f5cebfed58fb54969c0f52ce559c7277025
DIFF: https://github.com/llvm/llvm-project/commit/a04c0f5cebfed58fb54969c0f52ce559c7277025.diff
LOG: [IR] Modernize HasCachedHash (NFC) (#159902)
This patch modernizes HasCachedHash.
- "struct SFINAE" is replaced with identically defined SameType.
- The return types Yes and No are replaced with std::true_type and
std::false_type.
My previous attempt (#159510) to clean up HasCachedHash failed on
clang++-18, but this version works with clang++-18.
Added:
Modified:
llvm/lib/IR/Metadata.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index fc78a5b299f49..dc1651462aef4 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -986,15 +986,11 @@ static T *uniquifyImpl(T *N, DenseSet<T *, InfoT> &Store) {
}
template <class NodeTy> struct MDNode::HasCachedHash {
- using Yes = char[1];
- using No = char[2];
- template <class U, U Val> struct SFINAE {};
-
template <class U>
- static Yes &check(SFINAE<void (U::*)(unsigned), &U::setHash> *);
- template <class U> static No &check(...);
+ static std::true_type check(SameType<void (U::*)(unsigned), &U::setHash> *);
+ template <class U> static std::false_type check(...);
- static const bool value = sizeof(check<NodeTy>(nullptr)) == sizeof(Yes);
+ static constexpr bool value = decltype(check<NodeTy>(nullptr))::value;
};
MDNode *MDNode::uniquify() {
More information about the llvm-commits
mailing list