clang 20.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.
 
llvm::Expected< Teval (const ast_matchers::MatchFinder::MatchResult &R) const
 Convenience version of eval, for the case where the computation is being evaluated on its own.
 
virtual std::string toString () const =0
 Constructs a string representation of the computation, for informational purposes.
 

Protected Member Functions

 MatchComputation ()=default
 
 MatchComputation (const MatchComputation &)=default
 
MatchComputationoperator= (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 ( )
virtualdefault

◆ MatchComputation() [1/2]

template<typename T >
clang::transformer::MatchComputation< T >::MatchComputation ( )
protecteddefault

◆ MatchComputation() [2/2]

template<typename T >
clang::transformer::MatchComputation< T >::MatchComputation ( const MatchComputation< T > &  )
protecteddefault

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.

◆ eval() [2/2]

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::T.

◆ operator=()

template<typename T >
MatchComputation & clang::transformer::MatchComputation< T >::operator= ( const MatchComputation< T > &  )
protecteddefault

◆ 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: