clang 10.0.0git

Public Types | Public Member Functions | List of all members
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]
Collaboration diagram for clang::tooling::Transformer:
[legend]

## Public Types
using | ChangeConsumer = std::function< void(Expected< clang::tooling::AtomicChange > Change)>

## Public Member Functions
| Transformer (transformer::RewriteRule Rule, ChangeConsumer Consumer)
void | registerMatchers (ast_matchers::MatchFinder *MatchFinder)
| N.B. More...
void | run (const ast_matchers::MatchFinder::MatchResult &Result) override
| Not called directly by users – called by the framework, via base class pointer. More...
Public Member Functions inherited from clang::ast_matchers::MatchFinder::MatchCallback
virtual | ~MatchCallback ()
virtual void | onStartOfTranslationUnit ()
| Called at the start of each translation unit. More...
virtual void | onEndOfTranslationUnit ()
| Called at the end of each translation unit. More...
virtual StringRef | getID () const
| An id used to group the matchers. More...

## Detailed Description

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

Definition at line 23 of file Transformer.h.

## Member Typedef Documentation

## ◆ ChangeConsumer

using clang::tooling::Transformer::ChangeConsumer = std::function<void(Expected<clang::tooling::AtomicChange> Change)>

Definition at line 26 of file Transformer.h.

## Constructor & Destructor Documentation

## ◆ Transformer()

clang::tooling::Transformer::Transformer | ( | transformer::RewriteRule | Rule,
|  | ChangeConsumer | Consumer
| ) |  |
| inline

Parameters

  Consumer | Receives each rewrite or error. Will not necessarily be called for each match; for example, if the rewrite is not applicable because of macros, but doesn't fail. Note that clients are responsible for handling the case that independent `AtomicChanges` conflict with each other.

Definition at line 33 of file Transformer.h.

References registerMatchers(), and run().

## Member Function Documentation

## ◆ registerMatchers()

void 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 23 of file Transformer.cpp.

Referenced by Transformer().

## ◆ run()

void Transformer::run | ( | const ast_matchers::MatchFinder::MatchResult & | Result | ) |
| override virtual

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

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

Definition at line 28 of file Transformer.cpp.

References clang::transformer::RewriteRule::Case::AddedIncludes, clang::transformer::Angled, clang::ast_matchers::MatchFinder::MatchResult::Context, clang::transformer::RewriteRule::Case::Edits, clang::transformer::detail::findSelectedCase(), clang::ASTContext::getDiagnostics(), clang::transformer::detail::getRuleMatchLoc(), clang::DiagnosticsEngine::hasErrorOccurred(), clang::SourceLocation::print(), clang::transformer::Quoted, clang::ast_matchers::MatchFinder::MatchResult::SourceManager, and clang::transformer::detail::translateEdits().

Referenced by Transformer().

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

- include/clang/Tooling/Transformer/Transformer.h
- lib/Tooling/Transformer/Transformer.cpp