clang 10.0.0git

Public Member Functions | Protected Member Functions | List of all members
clang::transformer::MatchComputation< T > Class Template Referenceabstract

A failable computation over nodes bound by AST matchers, with (limited) reflection via the `toString` method. More...

`#include "clang/Tooling/Transformer/MatchConsumer.h"`

## Public Member Functions
virtual | ~MatchComputation ()=default
virtual llvm::Error | eval (const ast_matchers::MatchFinder::MatchResult &Match, T *Result) const =0
| Evaluates the computation and (potentially) updates the accumulator `Result`. More...
llvm::Expected< T > | eval (const ast_matchers::MatchFinder::MatchResult &R) const
| Convenience version of `eval`, for the case where the computation is being evaluated on its own. More...
virtual std::string | toString () const =0
| Constructs a string representation of the computation, for informational purposes. More...

## Protected Member Functions
| MatchComputation ()=default
| MatchComputation (const MatchComputation &)=default
MatchComputation & | operator= (const MatchComputation &)=default

## Detailed Description

### template<typename T>
class clang::transformer::MatchComputation< T >

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.

Definition at line 64 of file MatchConsumer.h.

## Constructor & Destructor Documentation

## ◆ ~MatchComputation()

template<typename T >

virtual clang::transformer::MatchComputation< T >::~MatchComputation | ( |  | ) |
| virtual default

## ◆ MatchComputation() [1/2]

template<typename T >

clang::transformer::MatchComputation< T >::MatchComputation | ( |  | ) |
| protected default

## ◆ MatchComputation() [2/2]

template<typename T >

clang::transformer::MatchComputation< T >::MatchComputation | ( | const MatchComputation< T > & |  | ) |
| protected default

## Member Function Documentation

## ◆ eval() [1/2]

template<typename T >

virtual llvm::Error clang::transformer::MatchComputation< T >::eval | ( | const ast_matchers::MatchFinder::MatchResult & | Match,
|  | T * | Result
| ) |  | const
| pure virtual

Evaluates the computation and (potentially) updates the accumulator `Result`.

`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.

Referenced by clang::transformer::MatchComputation< T >::eval().

## ◆ eval() [2/2]

template<typename T >

llvm::Expected< T > clang::transformer::MatchComputation< T >::eval | ( | const ast_matchers::MatchFinder::MatchResult & | R | ) | const

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

Definition at line 94 of file MatchConsumer.h.

References clang::transformer::MatchComputation< T >::eval(), and clang::transformer::ifBound().

## ◆ operator=()

template<typename T >

MatchComputation& clang::transformer::MatchComputation< T >::operator= | ( | const MatchComputation< T > & |  | ) |
| protected default

## ◆ toString()

template<typename T >

virtual std::string clang::transformer::MatchComputation< T >::toString | ( |  | ) | const
| pure virtual

Constructs a string representation of the computation, for informational purposes.

The representation must be deterministic, but is not required to be unique.

The documentation for this class was generated from the following file:

- include/clang/Tooling/Transformer/MatchConsumer.h