diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index ec7d030a20de8..22ab59be55eb2 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -619,23 +619,16 @@ class LocalAsMetadata : public ValueAsMetadata { namespace mdconst { namespace detail { +template +using check_has_dereference = decltype(static_cast(*std::declval())); -template T &make(); -template struct HasDereference { - using Yes = char[1]; - using No = char[2]; - template struct SFINAE {}; +template +static constexpr bool HasDereference = + is_detected::value; - template - static Yes &hasDereference(SFINAE(*make()))> * = 0); - template static No &hasDereference(...); - - static const bool value = - sizeof(hasDereference(nullptr)) == sizeof(Yes); -}; template struct IsValidPointer { static const bool value = std::is_base_of::value && - HasDereference::value; + HasDereference; }; template struct IsValidReference { static const bool value = std::is_base_of::value &&