From 9cae2d4a214d2ff88521a52e6578f3e94b7ed4d6 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 16 Sep 2025 10:36:25 -0700 Subject: [PATCH] [IR] Simplify HasCachedHash with is_detected (NFC) With is_detected, we don't need to implement a SFINAE trick on our own. --- llvm/lib/IR/Metadata.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index fc78a5b299f49..09e25ceaf59c3 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -986,15 +986,10 @@ static T *uniquifyImpl(T *N, DenseSet &Store) { } template struct MDNode::HasCachedHash { - using Yes = char[1]; - using No = char[2]; - template struct SFINAE {}; - template - static Yes &check(SFINAE *); - template static No &check(...); + using check = decltype(static_cast(&U::setHash)); - static const bool value = sizeof(check(nullptr)) == sizeof(Yes); + static constexpr bool value = is_detected::value; }; MDNode *MDNode::uniquify() {