[llvm] 3e0c58b - Revert "[IR] Simplify HasCachedHash with is_detected (NFC) (#159510)" (#159622)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 12:11:23 PDT 2025


Author: Jordan Rupprecht
Date: 2025-09-18T19:11:20Z
New Revision: 3e0c58be49c81931daf285c0973db5fb763e51e4

URL: https://github.com/llvm/llvm-project/commit/3e0c58be49c81931daf285c0973db5fb763e51e4
DIFF: https://github.com/llvm/llvm-project/commit/3e0c58be49c81931daf285c0973db5fb763e51e4.diff

LOG: Revert "[IR] Simplify HasCachedHash with is_detected (NFC) (#159510)" (#159622)

This reverts commit d6b7ac830ab4c1b26a1b2eecd15306eccf9cea90. Build
breakages reported on the PR hint at not working with certain versions
of the host compiler.

Added: 
    

Modified: 
    llvm/lib/IR/Metadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 09e25ceaf59c3..fc78a5b299f49 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -986,10 +986,15 @@ 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>
-  using check = decltype(static_cast<void (U::*)(unsigned)>(&U::setHash));
+  static Yes &check(SFINAE<void (U::*)(unsigned), &U::setHash> *);
+  template <class U> static No &check(...);
 
-  static constexpr bool value = is_detected<check, NodeTy>::value;
+  static const bool value = sizeof(check<NodeTy>(nullptr)) == sizeof(Yes);
 };
 
 MDNode *MDNode::uniquify() {


        


More information about the llvm-commits mailing list