From: James Y Knight Date: Tue, 29 Dec 2015 04:46:43 +0000 (+0000) Subject: Revert "[TrailingObjects] Use a different technique to determine if a getDecl" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a17defeefcbfef958a0f7785665b558e8e260303;p=clang Revert "[TrailingObjects] Use a different technique to determine if a getDecl" This reverts commit r256534. Failed to build on MSVC with error: clang/ASTMatchers/ASTMatchersInternal.h(572): error C2228: left of '.getDecl' must have class/struct/union type is 'add_rvalue_reference<_Ty>::type' (http://lab.llvm.org:8011/builders/lldb-x86-win7-msvc/builds/13873/steps/build/logs/stdio) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256535 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h index 816dc435a4..22068b48e7 100644 --- a/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -558,19 +558,22 @@ bool matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start, return false; } -/// Metafunction to determine if type T has a member called -/// getDecl. -/// -/// 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 struct type_sink_to_void { typedef void type; }; -template struct has_getDecl : std::false_type {}; -template -struct has_getDecl< - T, typename type_sink_to_void().getDecl())>::type> - : std::true_type {}; +/// \brief Metafunction to determine if type T has a member called getDecl. +template struct has_getDecl { + struct Default { int getDecl; }; + struct Derived : T, Default { }; + + template struct CheckT; + + // If T::getDecl exists, an ambiguity arises and CheckT will + // not be instantiable. This makes f(...) the only available + // overload. + template + static char (&f(CheckT*))[1]; + template static char (&f(...))[2]; + + static bool const value = sizeof(f(nullptr)) == 2; +}; /// \brief Matches overloaded operators with a specific name. ///