Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h @@ -3504,15 +3504,15 @@ /// \brief Matches if a node equals another node. /// /// \c Decl has pointer identity in the AST. -inline internal::Matcher equalsNode(const Decl *Node) { - return internal::makeMatcher(new internal::EqualsNodeMatcher(Node)); +AST_MATCHER_P_OVERLOAD(Decl, equalsNode, const Decl*, Other, 0) { + return &Node == Other; } /// \brief Matches if a node equals another node. /// /// \c Stmt has pointer identity in the AST. /// -inline internal::Matcher equalsNode(const Stmt *Node) { - return internal::makeMatcher(new internal::EqualsNodeMatcher(Node)); +AST_MATCHER_P_OVERLOAD(Stmt, equalsNode, const Stmt*, Other, 1) { + return &Node == Other; } /// @} Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h =================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1387,20 +1387,6 @@ const ValueT ExpectedValue; }; -template -class EqualsNodeMatcher : public SingleNodeMatcherInterface { -public: - explicit EqualsNodeMatcher(const T *ExpectedNode) - : ExpectedNode(ExpectedNode) {} - - bool matchesNode(const T &Node) const override { - return &Node == ExpectedNode; - } - -private: - const T *ExpectedNode; -}; - /// \brief A VariadicDynCastAllOfMatcher object is a /// variadic functor that takes a number of Matcher and returns a /// Matcher that matches TargetT nodes that are matched by all of the Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h =================================================================== --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -52,9 +52,9 @@ 0) #define AST_MATCHER_FUNCTION_P_OVERLOAD(ReturnType, DefineMatcher, ParamType, \ Param, OverloadId) \ - inline ReturnType DefineMatcher(const ParamType &Param); \ - typedef ReturnType (&DefineMatcher##_Type##OverloadId)(const ParamType &); \ - inline ReturnType DefineMatcher(const ParamType &Param) + inline ReturnType DefineMatcher(ParamType const &Param); \ + typedef ReturnType (&DefineMatcher##_Type##OverloadId)(ParamType const &); \ + inline ReturnType DefineMatcher(ParamType const &Param) /// \brief AST_MATCHER(Type, DefineMatcher) { ... } /// defines a zero parameter function named DefineMatcher() that returns a @@ -107,21 +107,21 @@ : public MatcherInterface { \ public: \ explicit matcher_##DefineMatcher##OverloadId##Matcher( \ - const ParamType &A##Param) \ + ParamType const &A##Param) \ : Param(A##Param) {} \ bool matches(const Type &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const override; \ \ private: \ - const ParamType Param; \ + ParamType const Param; \ }; \ } \ - inline internal::Matcher DefineMatcher(const ParamType &Param) { \ + inline internal::Matcher DefineMatcher(ParamType const &Param) { \ return internal::makeMatcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param)); \ } \ typedef internal::Matcher(&DefineMatcher##_Type##OverloadId)( \ - const ParamType &Param); \ + ParamType const &Param); \ inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \ const Type &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const @@ -151,25 +151,25 @@ class matcher_##DefineMatcher##OverloadId##Matcher \ : public MatcherInterface { \ public: \ - matcher_##DefineMatcher##OverloadId##Matcher(const ParamType1 &A##Param1, \ - const ParamType2 &A##Param2) \ + matcher_##DefineMatcher##OverloadId##Matcher(ParamType1 const &A##Param1, \ + ParamType2 const &A##Param2) \ : Param1(A##Param1), Param2(A##Param2) {} \ bool matches(const Type &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const override; \ \ private: \ - const ParamType1 Param1; \ - const ParamType2 Param2; \ + ParamType1 const Param1; \ + ParamType2 const Param2; \ }; \ } \ - inline internal::Matcher DefineMatcher(const ParamType1 &Param1, \ - const ParamType2 &Param2) { \ + inline internal::Matcher DefineMatcher(ParamType1 const &Param1, \ + ParamType2 const &Param2) { \ return internal::makeMatcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param1, \ Param2)); \ } \ typedef internal::Matcher(&DefineMatcher##_Type##OverloadId)( \ - const ParamType1 &Param1, const ParamType2 &Param2); \ + ParamType1 const &Param1, ParamType2 const &Param2); \ inline bool internal::matcher_##DefineMatcher##OverloadId##Matcher::matches( \ const Type &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const @@ -240,18 +240,18 @@ : public MatcherInterface { \ public: \ explicit matcher_##DefineMatcher##OverloadId##Matcher( \ - const ParamType &A##Param) \ + ParamType const &A##Param) \ : Param(A##Param) {} \ bool matches(const NodeType &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const override; \ \ private: \ - const ParamType Param; \ + ParamType const Param; \ }; \ } \ inline internal::PolymorphicMatcherWithParam1< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ - ReturnTypesF> DefineMatcher(const ParamType &Param) { \ + ReturnTypesF> DefineMatcher(ParamType const &Param) { \ return internal::PolymorphicMatcherWithParam1< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ ReturnTypesF>(Param); \ @@ -259,7 +259,7 @@ typedef internal::PolymorphicMatcherWithParam1< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType, \ ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \ - const ParamType &Param); \ + ParamType const &Param); \ template \ bool internal::matcher_##DefineMatcher##OverloadId##Matcher< \ NodeType, ParamT>::matches(const NodeType &Node, ASTMatchFinder *Finder, \ @@ -286,21 +286,21 @@ class matcher_##DefineMatcher##OverloadId##Matcher \ : public MatcherInterface { \ public: \ - matcher_##DefineMatcher##OverloadId##Matcher(const ParamType1 &A##Param1, \ - const ParamType2 &A##Param2) \ + matcher_##DefineMatcher##OverloadId##Matcher(ParamType1 const &A##Param1, \ + ParamType2 const &A##Param2) \ : Param1(A##Param1), Param2(A##Param2) {} \ bool matches(const NodeType &Node, ASTMatchFinder *Finder, \ BoundNodesTreeBuilder *Builder) const override; \ \ private: \ - const ParamType1 Param1; \ - const ParamType2 Param2; \ + ParamType1 const Param1; \ + ParamType2 const Param2; \ }; \ } \ inline internal::PolymorphicMatcherWithParam2< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ - ParamType2, ReturnTypesF> DefineMatcher(const ParamType1 &Param1, \ - const ParamType2 &Param2) { \ + ParamType2, ReturnTypesF> DefineMatcher(ParamType1 const &Param1, \ + ParamType2 const &Param2) { \ return internal::PolymorphicMatcherWithParam2< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ ParamType2, ReturnTypesF>(Param1, Param2); \ @@ -308,7 +308,7 @@ typedef internal::PolymorphicMatcherWithParam2< \ internal::matcher_##DefineMatcher##OverloadId##Matcher, ParamType1, \ ParamType2, ReturnTypesF>(&DefineMatcher##_Type##OverloadId)( \ - const ParamType1 &Param1, const ParamType2 &Param2); \ + ParamType1 const &Param1, ParamType2 const &Param2); \ template \ bool internal::matcher_##DefineMatcher##OverloadId##Matcher< \ NodeType, ParamT1, ParamT2>::matches( \