Skip to content

Commit a04c0f5

Browse files
[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.
1 parent cb78bf6 commit a04c0f5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

llvm/lib/IR/Metadata.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -986,15 +986,11 @@ static T *uniquifyImpl(T *N, DenseSet<T *, InfoT> &Store) {
986986
}
987987

988988
template <class NodeTy> struct MDNode::HasCachedHash {
989-
using Yes = char[1];
990-
using No = char[2];
991-
template <class U, U Val> struct SFINAE {};
992-
993989
template <class U>
994-
static Yes &check(SFINAE<void (U::*)(unsigned), &U::setHash> *);
995-
template <class U> static No &check(...);
990+
static std::true_type check(SameType<void (U::*)(unsigned), &U::setHash> *);
991+
template <class U> static std::false_type check(...);
996992

997-
static const bool value = sizeof(check<NodeTy>(nullptr)) == sizeof(Yes);
993+
static constexpr bool value = decltype(check<NodeTy>(nullptr))::value;
998994
};
999995

1000996
MDNode *MDNode::uniquify() {

0 commit comments

Comments
 (0)