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

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 11:33:41 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Jordan Rupprecht (rupprecht)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/159622.diff


1 Files Affected:

- (modified) llvm/lib/IR/Metadata.cpp (+7-2) 


``````````diff
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() {

``````````

</details>


https://github.com/llvm/llvm-project/pull/159622


More information about the llvm-commits mailing list