class DynTypedMatcher

Declaration

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

Description

Matcher that works on a \c DynTypedNode. It is constructed from a \c Matcher<T> object and redirects most calls to underlying matcher. It checks whether the \c DynTypedNode is convertible into the type of the underlying matcher and then do the actual match on the actual node, or return false if it is not convertible.

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

Member Variables

private bool AllowBind = false
private clang::ASTNodeKind SupportedKind
private clang::ASTNodeKind RestrictKind
It allows to perform implicit and dynamic cast of matchers without needing to change \c Implementation.
private IntrusiveRefCntPtr<clang::ast_matchers::internal:: DynMatcherInterface> Implementation

Method Overview

  • public template <typename T> DynTypedMatcher(MatcherInterface<T> * Implementation)
  • private DynTypedMatcher(clang::ASTNodeKind SupportedKind, clang::ASTNodeKind RestrictKind, IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface> Implementation)
  • public template <typename T>bool canConvertTo() const
  • public bool canConvertTo(clang::ASTNodeKind To) const
  • public bool canMatchNodesOfKind(clang::ASTNodeKind Kind) const
  • public static clang::ast_matchers::internal::DynTypedMatcher constructRestrictedWrapper(const clang::ast_matchers::internal::DynTypedMatcher & InnerMatcher, clang::ASTNodeKind RestrictKind)
  • public static clang::ast_matchers::internal::DynTypedMatcher constructVariadic(clang::ast_matchers::internal::DynTypedMatcher::VariadicOperator Op, clang::ASTNodeKind SupportedKind, std::vector<DynTypedMatcher> InnerMatchers)
  • public template <typename T>Matcher<T> convertTo() const
  • public clang::ast_matchers::internal::DynTypedMatcher dynCastTo(const clang::ASTNodeKind Kind) const
  • public clang::ast_matchers::internal::DynTypedMatcher::MatcherIDType getID() const
  • public clang::ASTNodeKind getSupportedKind() const
  • public llvm::Optional<clang::TraversalKind> getTraversalKind() const
  • public bool matches(const clang::DynTypedNode & DynNode, clang::ast_matchers::internal::ASTMatchFinder * Finder, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder) const
  • public bool matchesNoKindCheck(const clang::DynTypedNode & DynNode, clang::ast_matchers::internal::ASTMatchFinder * Finder, clang::ast_matchers::internal::BoundNodesTreeBuilder * Builder) const
  • public void setAllowBind(bool AB)
  • public static clang::ast_matchers::internal::DynTypedMatcher trueMatcher(clang::ASTNodeKind NodeKind)
  • public llvm::Optional<DynTypedMatcher> tryBind(llvm::StringRef ID) const
  • public template <typename T>Matcher<T> unconditionalConvertTo() const
  • public clang::ast_matchers::internal::DynTypedMatcher withTraversalKind(clang::TraversalKind TK)

Methods

template <typename T>
DynTypedMatcher(
    MatcherInterface<T>* Implementation)

Description

Takes ownership of the provided implementation pointer.

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

Templates

T

Parameters

MatcherInterface<T>* Implementation

DynTypedMatcher(
    clang::ASTNodeKind SupportedKind,
    clang::ASTNodeKind RestrictKind,
    IntrusiveRefCntPtr<
        clang::ast_matchers::internal::
            DynMatcherInterface> Implementation)

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

Parameters

clang::ASTNodeKind SupportedKind
clang::ASTNodeKind RestrictKind
IntrusiveRefCntPtr<clang::ast_matchers::internal:: DynMatcherInterface> Implementation

template <typename T>
bool canConvertTo() const

Description

Returns \c true if the passed \c DynTypedMatcher can be converted to a \c Matcher<T>. This method verifies that the underlying matcher in \c Other can process nodes of types T.

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

Templates

T

bool canConvertTo(clang::ASTNodeKind To) const

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

Parameters

clang::ASTNodeKind To

bool canMatchNodesOfKind(
    clang::ASTNodeKind Kind) const

Description

Check whether this matcher could ever match a node of kind \p Kind.

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

Parameters

clang::ASTNodeKind Kind

Returns

\c false if this matcher will never match such a node. Otherwise, return \c true.

static clang::ast_matchers::internal::
    DynTypedMatcher
    constructRestrictedWrapper(
        const clang::ast_matchers::internal::
            DynTypedMatcher& InnerMatcher,
        clang::ASTNodeKind RestrictKind)

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

Parameters

const clang::ast_matchers::internal:: DynTypedMatcher& InnerMatcher
clang::ASTNodeKind RestrictKind

static clang::ast_matchers::internal::
    DynTypedMatcher
    constructVariadic(
        clang::ast_matchers::internal::
            DynTypedMatcher::VariadicOperator Op,
        clang::ASTNodeKind SupportedKind,
        std::vector<DynTypedMatcher>
            InnerMatchers)

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

Parameters

clang::ast_matchers::internal::DynTypedMatcher:: VariadicOperator Op
clang::ASTNodeKind SupportedKind
std::vector<DynTypedMatcher> InnerMatchers

template <typename T>
Matcher<T> convertTo() const

Description

Construct a \c Matcher<T> interface around the dynamic matcher. This method asserts that \c canConvertTo() is \c true. Callers should call \c canConvertTo() first to make sure that \c this is compatible with T.

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

Templates

T

clang::ast_matchers::internal::DynTypedMatcher
dynCastTo(const clang::ASTNodeKind Kind) const

Description

Return a matcher that points to the same implementation, but restricts the node types for \p Kind.

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

Parameters

const clang::ASTNodeKind Kind

clang::ast_matchers::internal::DynTypedMatcher::
    MatcherIDType
    getID() const

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

clang::ASTNodeKind getSupportedKind() const

Description

Returns the type this matcher works on. \c matches() will always return false unless the node passed is of this or a derived type.

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

llvm::Optional<clang::TraversalKind>
getTraversalKind() const

Description

Returns the \c TraversalKind respected by calls to `match()`, if any. Most matchers will not have a traversal kind set, instead relying on the surrounding context. For those, \c llvm::None is returned.

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

bool matches(
    const clang::DynTypedNode& DynNode,
    clang::ast_matchers::internal::ASTMatchFinder*
        Finder,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder) const

Description

Returns true if the matcher matches the given \c DynNode.

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

Parameters

const clang::DynTypedNode& DynNode
clang::ast_matchers::internal::ASTMatchFinder* Finder
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder

bool matchesNoKindCheck(
    const clang::DynTypedNode& DynNode,
    clang::ast_matchers::internal::ASTMatchFinder*
        Finder,
    clang::ast_matchers::internal::
        BoundNodesTreeBuilder* Builder) const

Description

Same as matches(), but skips the kind check. It is faster, but the caller must ensure the node is valid for the kind of this matcher.

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

Parameters

const clang::DynTypedNode& DynNode
clang::ast_matchers::internal::ASTMatchFinder* Finder
clang::ast_matchers::internal:: BoundNodesTreeBuilder* Builder

void setAllowBind(bool AB)

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

Parameters

bool AB

static clang::ast_matchers::internal::
    DynTypedMatcher
    trueMatcher(clang::ASTNodeKind NodeKind)

Description

Get a "true" matcher for \p NodeKind. It only checks that the node is of the right kind.

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

Parameters

clang::ASTNodeKind NodeKind

llvm::Optional<DynTypedMatcher> tryBind(
    llvm::StringRef ID) const

Description

Bind the specified \p ID to the matcher.

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

Parameters

llvm::StringRef ID

Returns

A new matcher with the \p ID bound to it if this matcher supports binding. Otherwise, returns an empty \c Optional<>.

template <typename T>
Matcher<T> unconditionalConvertTo() const

Description

Same as \c convertTo(), but does not check that the underlying matcher can handle a value of T. If it is not compatible, then this matcher will never match anything.

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

Templates

T

clang::ast_matchers::internal::DynTypedMatcher
withTraversalKind(clang::TraversalKind TK)

Description

Return a matcher that that points to the same implementation, but sets the traversal kind. If the traversal kind is already set, then \c TK overrides it.

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

Parameters

clang::TraversalKind TK