class MatchComputation

Declaration

template <typename T>
class MatchComputation { /* full declaration omitted */ };

Description

A failable computation over nodes bound by AST matchers, with (limited) reflection via the `toString` method. The computation should report any errors though its return value (rather than terminating the program) to enable usage in interactive scenarios like clang-query. This is a central abstraction of the Transformer framework. It is a generalization of `MatchConsumer` and intended to replace it.

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:64

Templates

T

Method Overview

Methods

MatchComputation<T>()

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:85

MatchComputation<T>(const MatchComputation<T>&)

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:89

Parameters

const MatchComputation<T>&

virtual llvm::Error eval(
    const ast_matchers::MatchFinder::MatchResult&
        Match,
    T* Result) const

Description

Evaluates the computation and (potentially) updates the accumulator \c Result. \c Result is undefined in the case of an error. `Result` is an out parameter to optimize case where the computation involves composing the result of sub-computation evaluations.

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:72

Parameters

const ast_matchers::MatchFinder::MatchResult& Match
T* Result

llvm::Expected<T> eval(
    const ast_matchers::MatchFinder::MatchResult&
        R) const

Description

Convenience version of `eval`, for the case where the computation is being evaluated on its own.

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:77

Parameters

const ast_matchers::MatchFinder::MatchResult& R

virtual std::string toString() const

Description

Constructs a string representation of the computation, for informational purposes. The representation must be deterministic, but is not required to be unique.

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:82

virtual ~MatchComputation<T>()

Declared at: clang/include/clang/Tooling/Transformer/MatchConsumer.h:66