class Transformer

Declaration

class Transformer : public MatchCallback { /* full declaration omitted */ };

Description

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

Declared at: clang/include/clang/Tooling/Transformer/Transformer.h:63

Inherits from: MatchFinder::MatchCallback

Member Variables

private std::unique_ptr<detail::TransformerImpl> Impl

Method Overview

  • public Transformer(transformer::RewriteRuleWith<void> Rule, clang::tooling::Transformer::ChangeSetConsumer Consumer)
  • public template <typename MetadataT> Transformer(transformer::RewriteRuleWith<MetadataT> Rule, std::function<void (llvm::Expected<TransformerResult<typename detail::type_identity<MetadataT>::type>>)> Consumer)
  • public void registerMatchers(ast_matchers::MatchFinder * MatchFinder)
  • public void run(const ast_matchers::MatchFinder::MatchResult & Result)

Inherited from MatchFinder::MatchCallback:

Methods

Transformer(
    transformer::RewriteRuleWith<void> Rule,
    clang::tooling::Transformer::ChangeSetConsumer
        Consumer)

Declared at: clang/include/clang/Tooling/Transformer/Transformer.h:79

Parameters

transformer::RewriteRuleWith<void> Rule
clang::tooling::Transformer::ChangeSetConsumer 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 \c AtomicChanges conflict with each other.

template <typename MetadataT>
Transformer(
    transformer::RewriteRuleWith<MetadataT> Rule,
    std::function<void(
        llvm::Expected<TransformerResult<
            typename detail::type_identity<
                MetadataT>::type>>)> Consumer)

Declared at: clang/include/clang/Tooling/Transformer/Transformer.h:96

Templates

MetadataT

Parameters

transformer::RewriteRuleWith<MetadataT> Rule
std::function<void( llvm::Expected<TransformerResult< typename detail::type_identity< MetadataT>::type>>)> 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 \c AtomicChanges conflict with each other.

void registerMatchers(
    ast_matchers::MatchFinder* MatchFinder)

Description

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

Declared at: clang/include/clang/Tooling/Transformer/Transformer.h:104

Parameters

ast_matchers::MatchFinder* MatchFinder

void run(
    const ast_matchers::MatchFinder::MatchResult&
        Result)

Description

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

Declared at: clang/include/clang/Tooling/Transformer/Transformer.h:108

Parameters

const ast_matchers::MatchFinder::MatchResult& Result