diff options
Diffstat (limited to 'include/clang/ASTMatchers/ASTMatchers.h')
-rw-r--r-- | include/clang/ASTMatchers/ASTMatchers.h | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index f10addc..ab62dd0 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -129,7 +129,8 @@ typedef internal::Matcher<NestedNameSpecifierLoc> NestedNameSpecifierLocMatcher; /// \endcode /// /// Usable as: Any Matcher -inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher> anything() { +inline internal::PolymorphicMatcherWithParam0<internal::TrueMatcher> +anything() { return internal::PolymorphicMatcherWithParam0<internal::TrueMatcher>(); } @@ -157,6 +158,17 @@ const internal::VariadicAllOfMatcher<Decl> decl; /// \endcode const internal::VariadicDynCastAllOfMatcher<Decl, NamedDecl> namedDecl; +/// \brief Matches a declaration of a namespace. +/// +/// Given +/// \code +/// namespace {} +/// namespace test {} +/// \endcode +/// namespaceDecl() +/// matches "namespace {}" and "namespace test {}" +const internal::VariadicDynCastAllOfMatcher<Decl, NamespaceDecl> namespaceDecl; + /// \brief Matches C++ class declarations. /// /// Example matches \c X, \c Z @@ -2514,6 +2526,38 @@ AST_MATCHER_P(CXXMethodDecl, ofClass, InnerMatcher.matches(*Parent, Finder, Builder)); } +/// \brief Matches if the given method declaration is virtual. +/// +/// Given +/// \code +/// class A { +/// public: +/// virtual void x(); +/// }; +/// \endcode +/// matches A::x +AST_MATCHER(CXXMethodDecl, isVirtual) { + return Node.isVirtual(); +} + +/// \brief Matches if the given method declaration overrides another method. +/// +/// Given +/// \code +/// class A { +/// public: +/// virtual void x(); +/// }; +/// class B : public A { +/// public: +/// virtual void x(); +/// }; +/// \endcode +/// matches B::x +AST_MATCHER(CXXMethodDecl, isOverride) { + return Node.size_overridden_methods() > 0; +} + /// \brief Matches member expressions that are called with '->' as opposed /// to '.'. /// |