Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions llvm/include/llvm/IR/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,23 +619,16 @@ class LocalAsMetadata : public ValueAsMetadata {
namespace mdconst {

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

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

template <class U, class V>
static Yes &hasDereference(SFINAE<sizeof(static_cast<V>(*make<U>()))> * = 0);
template <class U, class V> static No &hasDereference(...);

static const bool value =
sizeof(hasDereference<T, Result>(nullptr)) == sizeof(Yes);
};
template <class V, class M> struct IsValidPointer {
static const bool value = std::is_base_of<Constant, V>::value &&
HasDereference<M, const Metadata &>::value;
HasDereference<M, const Metadata &>;
};
template <class V, class M> struct IsValidReference {
static const bool value = std::is_base_of<Constant, V>::value &&
Expand Down
Loading