clang 22.0.0git
clang::tooling::Transformer Class Reference

Handles the matcher and callback registration for a single RewriteRule, as defined by the arguments of the constructor. More...

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

Inheritance diagram for clang::tooling::Transformer:
[legend]

Public Types

using ChangeSetConsumer
 Provides the set of changes to the consumer.

Public Member Functions

 Transformer (transformer::RewriteRuleWith< void > Rule, ChangeSetConsumer Consumer)
template<typename MetadataT>
 Transformer (transformer::RewriteRuleWith< MetadataT > Rule, std::function< void(llvm::Expected< TransformerResult< llvm::type_identity_t< MetadataT > > >)> Consumer)
void registerMatchers (ast_matchers::MatchFinder *MatchFinder)
 N.B.
void run (const ast_matchers::MatchFinder::MatchResult &Result) override
 Not called directly by users – called by the framework, via base class pointer.
Public Member Functions inherited from clang::ast_matchers::MatchFinder::MatchCallback
virtual ~MatchCallback ()
virtual void onStartOfTranslationUnit ()
 Called at the start of each translation unit.
virtual void onEndOfTranslationUnit ()
 Called at the end of each translation unit.
virtual StringRef getID () const
 An id used to group the matchers.
virtual std::optional< TraversalKindgetCheckTraversalKind () const
 TraversalKind to use while matching and processing the result nodes.

Detailed Description

Handles the matcher and callback registration for a single RewriteRule, as defined by the arguments of the constructor.

Definition at line 58 of file Transformer.h.

Member Typedef Documentation

◆ ChangeSetConsumer

Initial value:

Provides the set of changes to the consumer.

The callback is free to move or destructively consume the changes as needed.

We use MutableArrayRef as an abstraction to provide decoupling, and we expect the majority of consumers to copy or move the individual values into a separate data structure.

Definition at line 66 of file Transformer.h.

Constructor & Destructor Documentation

◆ Transformer() [1/2]

clang::tooling::Transformer::Transformer ( transformer::RewriteRuleWith< void > Rule,
ChangeSetConsumer Consumer )
inlineexplicit
Parameters
Consumerreceives all rewrites for a single match, or an error. Will not necessarily be called for each match; for example, if the rule generates no edits but does not fail. Note that clients are responsible for handling the case that independent AtomicChanges conflict with each other.

Definition at line 74 of file Transformer.h.

References clang::Result, and Transformer().

Referenced by Transformer().

◆ Transformer() [2/2]

template<typename MetadataT>
clang::tooling::Transformer::Transformer ( transformer::RewriteRuleWith< MetadataT > Rule,
std::function< void(llvm::Expected< TransformerResult< llvm::type_identity_t< MetadataT > > >)> Consumer )
explicit
Parameters
Consumerreceives all rewrites and the associated metadata for a single match, or an error. Will always be called for each match, even if the rule generates no edits. Note that clients are responsible for handling the case that independent AtomicChanges conflict with each other.

Definition at line 196 of file Transformer.h.

References std::function.

Member Function Documentation

◆ registerMatchers()

void clang::tooling::Transformer::registerMatchers ( ast_matchers::MatchFinder * MatchFinder)

N.B.

Passes this pointer to MatchFinder. So, this object should not be moved after this call.

Definition at line 70 of file Transformer.cpp.

References clang::ast_matchers::MatchFinder::addDynamicMatcher().

◆ run()

void clang::tooling::Transformer::run ( const ast_matchers::MatchFinder::MatchResult & Result)
overridevirtual

Not called directly by users – called by the framework, via base class pointer.

Implements clang::ast_matchers::MatchFinder::MatchCallback.

Definition at line 75 of file Transformer.cpp.

References clang::Result.


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