clang 20.0.0git
|
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"
Public Types | |
using | ChangeSetConsumer = std::function< void(Expected< llvm::MutableArrayRef< AtomicChange > > Changes)> |
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< typename detail::type_identity< MetadataT >::type > >)> 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 | run (const MatchResult &Result)=0 |
Called on every match by the MatchFinder . | |
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< TraversalKind > | getCheckTraversalKind () const |
TraversalKind to use while matching and processing the result nodes. | |
Handles the matcher and callback registration for a single RewriteRule
, as defined by the arguments of the constructor.
Definition at line 63 of file Transformer.h.
using clang::tooling::Transformer::ChangeSetConsumer = std::function<void( Expected<llvm::MutableArrayRef<AtomicChange> > Changes)> |
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 71 of file Transformer.h.
|
inlineexplicit |
Consumer | receives 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 79 of file Transformer.h.
References clang::Result.
|
explicit |
Consumer | receives 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 201 of file Transformer.h.
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 71 of file Transformer.cpp.
References clang::ast_matchers::MatchFinder::addDynamicMatcher().
|
overridevirtual |
Not called directly by users – called by the framework, via base class pointer.
Implements clang::ast_matchers::MatchFinder::MatchCallback.
Definition at line 76 of file Transformer.cpp.
References clang::Result.