class ASTMatchFinder

Declaration

class ASTMatchFinder { /* full declaration omitted */ };

Description

Interface that allows matchers to traverse the AST. FIXME: Find a better name. This provides three entry methods for each base node type in the AST: - \c matchesChildOf: Matches a matcher on every child node of the given node. Returns true if at least one child node could be matched. - \c matchesDescendantOf: Matches a matcher on all descendant nodes of the given node. Returns true if at least one descendant matched. - \c matchesAncestorOf: Matches a matcher on all ancestors of the given node. Returns true if at least one ancestor matched. FIXME: Currently we only allow Stmt and Decl nodes to start a traversal. In the future, we want to implement this for all nodes for which it makes sense. In the case of matchesAncestorOf, we'll want to implement it for all nodes, as all nodes have ancestors.

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:702

Method Overview

  • public virtual bool IsMatchingInASTNodeNotAsIs() const
  • public virtual bool IsMatchingInASTNodeNotSpelledInSource() const
  • public virtual bool classIsDerivedFrom(const clang::CXXRecordDecl * Declaration, const Matcher<clang::NamedDecl> & Base, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, bool Directly)
  • public virtual clang::ASTContext & getASTContext() const
  • private virtual bool isMatchingChildrenNotSpelledInSource() const
  • public bool isTraversalIgnoringImplicitNodes() const
  • protected virtual bool matchesAncestorOf(const clang::DynTypedNode & Node, clang::ASTContext & Ctx, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::AncestorMatchMode MatchMode)
  • public template <typename T>bool matchesAncestorOf(const T & Node, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::AncestorMatchMode MatchMode)
  • protected virtual bool matchesChildOf(const clang::DynTypedNode & Node, clang::ASTContext & Ctx, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::BindKind Bind)
  • public template <typename T>bool matchesChildOf(const T & Node, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::BindKind Bind)
  • protected virtual bool matchesDescendantOf(const clang::DynTypedNode & Node, clang::ASTContext & Ctx, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::BindKind Bind)
  • public template <typename T>bool matchesDescendantOf(const T & Node, const clang::ast_matchers::internal::DynTypedMatcher & Matcher, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, clang::ast_matchers::internal::ASTMatchFinder::BindKind Bind)
  • public virtual bool objcClassIsDerivedFrom(const clang::ObjCInterfaceDecl * Declaration, const Matcher<clang::NamedDecl> & Base, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder, bool Directly)
  • private virtual void setMatchingChildrenNotSpelledInSource(bool Set)
  • public virtual ~ASTMatchFinder()

Methods

virtual bool IsMatchingInASTNodeNotAsIs() const

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:791

virtual bool
IsMatchingInASTNodeNotSpelledInSource() const

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:789

virtual bool classIsDerivedFrom(
    const clang::CXXRecordDecl* Declaration,
    const Matcher<clang::NamedDecl>& Base,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    bool Directly)

Description

Returns true if the given C++ class is directly or indirectly derived from a base type matching \c base. A class is not considered to be derived from itself.

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:728

Parameters

const clang::CXXRecordDecl* Declaration
const Matcher<clang::NamedDecl>& Base
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
bool Directly

virtual clang::ASTContext& getASTContext() const

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:787

virtual bool
isMatchingChildrenNotSpelledInSource() const

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:812

bool isTraversalIgnoringImplicitNodes() const

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:793

virtual bool matchesAncestorOf(
    const clang::DynTypedNode& Node,
    clang::ASTContext& Ctx,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::AncestorMatchMode
            MatchMode)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:806

Parameters

const clang::DynTypedNode& Node
clang::ASTContext& Ctx
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: AncestorMatchMode MatchMode

template <typename T>
bool matchesAncestorOf(
    const T& Node,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::AncestorMatchMode
            MatchMode)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:774

Templates

T

Parameters

const T& Node
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: AncestorMatchMode MatchMode

virtual bool matchesChildOf(
    const clang::DynTypedNode& Node,
    clang::ASTContext& Ctx,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::BindKind Bind)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:796

Parameters

const clang::DynTypedNode& Node
clang::ASTContext& Ctx
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: BindKind Bind

template <typename T>
bool matchesChildOf(
    const T& Node,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::BindKind Bind)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:743

Templates

T

Parameters

const T& Node
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: BindKind Bind

virtual bool matchesDescendantOf(
    const clang::DynTypedNode& Node,
    clang::ASTContext& Ctx,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::BindKind Bind)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:801

Parameters

const clang::DynTypedNode& Node
clang::ASTContext& Ctx
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: BindKind Bind

template <typename T>
bool matchesDescendantOf(
    const T& Node,
    const clang::ast_matchers::internal::
        DynTypedMatcher& Matcher,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    clang::ast_matchers::internal::
        ASTMatchFinder::BindKind Bind)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:758

Templates

T

Parameters

const T& Node
const clang::ast_matchers::internal:: DynTypedMatcher& Matcher
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
clang::ast_matchers::internal::ASTMatchFinder:: BindKind Bind

virtual bool objcClassIsDerivedFrom(
    const clang::ObjCInterfaceDecl* Declaration,
    const Matcher<clang::NamedDecl>& Base,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder,
    bool Directly)

Description

Returns true if the given Objective-C class is directly or indirectly derived from a base class matching \c base. A class is not considered to be derived from itself.

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:737

Parameters

const clang::ObjCInterfaceDecl* Declaration
const Matcher<clang::NamedDecl>& Base
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder
bool Directly

virtual void
setMatchingChildrenNotSpelledInSource(bool Set)

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:813

Parameters

bool Set

virtual ~ASTMatchFinder()

Declared at: clang/include/clang/ASTMatchers/ASTMatchersInternal.h:722