forked from OSchip/llvm-project
Replace a compiler-specific approach to determining the presence of a getDecl() member function with one that does not require compiler-specific workarounds; NFC.
llvm-svn: 261872
This commit is contained in:
parent
74a7bb39a2
commit
0eb1d7bca0
|
@ -569,32 +569,21 @@ bool matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metafunction to determine if type T has a member called
|
// Metafunction to determine if type T has a member called getDecl.
|
||||||
// getDecl.
|
template <typename Ty>
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
class has_getDecl {
|
||||||
// For MSVC, we use a weird nonstandard __if_exists statement, as it
|
typedef char yes[1];
|
||||||
// is not standards-conformant enough to properly compile the standard
|
typedef char no[2];
|
||||||
// code below. (At least up through MSVC 2015 require this workaround)
|
|
||||||
template <typename T> struct has_getDecl {
|
template <typename Inner>
|
||||||
__if_exists(T::getDecl) {
|
static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
|
||||||
enum { value = 1 };
|
|
||||||
}
|
template <typename>
|
||||||
__if_not_exists(T::getDecl) {
|
static no& test(...);
|
||||||
enum { value = 0 };
|
|
||||||
}
|
public:
|
||||||
|
static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
// There is a default template inheriting from "false_type". Then, a
|
|
||||||
// partial specialization inherits from "true_type". However, this
|
|
||||||
// specialization will only exist when the call to getDecl() isn't an
|
|
||||||
// error -- it vanishes by SFINAE when the member doesn't exist.
|
|
||||||
template <typename> struct type_sink_to_void { typedef void type; };
|
|
||||||
template <typename T, typename = void> struct has_getDecl : std::false_type {};
|
|
||||||
template <typename T>
|
|
||||||
struct has_getDecl<
|
|
||||||
T, typename type_sink_to_void<decltype(std::declval<T>().getDecl())>::type>
|
|
||||||
: std::true_type {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// \brief Matches overloaded operators with a specific name.
|
/// \brief Matches overloaded operators with a specific name.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue