Skip to content

Commit d6b7ac8

Browse files
[IR] Simplify HasCachedHash with is_detected (NFC) (#159510)
With is_detected, we don't need to implement a SFINAE trick on our own.
1 parent deb9520 commit d6b7ac8

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

llvm/lib/IR/Metadata.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -986,15 +986,10 @@ 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+
using check = decltype(static_cast<void (U::*)(unsigned)>(&U::setHash));
996991

997-
static const bool value = sizeof(check<NodeTy>(nullptr)) == sizeof(Yes);
992+
static constexpr bool value = is_detected<check, NodeTy>::value;
998993
};
999994

1000995
MDNode *MDNode::uniquify() {

0 commit comments

Comments
 (0)