Skip to content

Commit e13b79c

Browse files
[IR] Use llvm::is_detected (NFC) (#137562)
1 parent 3eab094 commit e13b79c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

llvm/include/llvm/IR/Metadata.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -619,23 +619,16 @@ class LocalAsMetadata : public ValueAsMetadata {
619619
namespace mdconst {
620620

621621
namespace detail {
622+
template <typename U, typename V>
623+
using check_has_dereference = decltype(static_cast<V>(*std::declval<U &>()));
622624

623-
template <class T> T &make();
624-
template <class T, class Result> struct HasDereference {
625-
using Yes = char[1];
626-
using No = char[2];
627-
template <size_t N> struct SFINAE {};
625+
template <typename U, typename V>
626+
static constexpr bool HasDereference =
627+
is_detected<check_has_dereference, U, V>::value;
628628

629-
template <class U, class V>
630-
static Yes &hasDereference(SFINAE<sizeof(static_cast<V>(*make<U>()))> * = 0);
631-
template <class U, class V> static No &hasDereference(...);
632-
633-
static const bool value =
634-
sizeof(hasDereference<T, Result>(nullptr)) == sizeof(Yes);
635-
};
636629
template <class V, class M> struct IsValidPointer {
637630
static const bool value = std::is_base_of<Constant, V>::value &&
638-
HasDereference<M, const Metadata &>::value;
631+
HasDereference<M, const Metadata &>;
639632
};
640633
template <class V, class M> struct IsValidReference {
641634
static const bool value = std::is_base_of<Constant, V>::value &&

0 commit comments

Comments
 (0)