From: Samuel Benzaquen Date: Wed, 24 Jul 2013 14:48:01 +0000 (+0000) Subject: Add support for Adaptative matchers on the dynamic registry. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6de440e1989ee7932c942dcba85e862c31bf4604;p=clang Add support for Adaptative matchers on the dynamic registry. Summary: Add support for Adaptative matchers on the dynamic registry. Each adaptative matcher is created with a function template. We instantiate the function N times, one for each possible From type and apply the techniques used on argument overloaded and polymorphic matchers to add them to the registry. Reviewers: klimek CC: cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D1201 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187044 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index b151985a16..fc36227cbe 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1708,11 +1708,13 @@ findAll(const internal::Matcher &Matcher) { /// /// Usable as: Any Matcher template -internal::ArgumentAdaptingMatcher +internal::ArgumentAdaptingMatcher, + internal::TypeList > hasParent(const internal::Matcher &ParentMatcher) { return internal::ArgumentAdaptingMatcher< - internal::HasParentMatcher, - ParentT>(ParentMatcher); + internal::HasParentMatcher, ParentT, internal::TypeList, + internal::TypeList >(ParentMatcher); } /// \brief Matches AST nodes that have an ancestor that matches the provided @@ -1727,11 +1729,13 @@ hasParent(const internal::Matcher &ParentMatcher) { /// /// Usable as: Any Matcher template -internal::ArgumentAdaptingMatcher +internal::ArgumentAdaptingMatcher, + internal::TypeList > hasAncestor(const internal::Matcher &AncestorMatcher) { return internal::ArgumentAdaptingMatcher< - internal::HasAncestorMatcher, - AncestorT>(AncestorMatcher); + internal::HasAncestorMatcher, AncestorT, internal::TypeList, + internal::TypeList >(AncestorMatcher); } /// \brief Matches if the provided matcher does not match. diff --git a/include/clang/ASTMatchers/ASTMatchersInternal.h b/include/clang/ASTMatchers/ASTMatchersInternal.h index 915f1bd6af..711e67dc13 100644 --- a/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -732,35 +732,6 @@ protected: AncestorMatchMode MatchMode) = 0; }; -/// \brief Converts a \c Matcher to a matcher of desired type \c To by -/// "adapting" a \c To into a \c T. -/// -/// The \c ArgumentAdapterT argument specifies how the adaptation is done. -/// -/// For example: -/// \c ArgumentAdaptingMatcher(InnerMatcher); -/// Given that \c InnerMatcher is of type \c Matcher, this returns a matcher -/// that is convertible into any matcher of type \c To by constructing -/// \c HasMatcher(InnerMatcher). -/// -/// If a matcher does not need knowledge about the inner type, prefer to use -/// PolymorphicMatcherWithParam1. -template