clang
9.0.0
|
The following three functions are a low-level part of the RewriteRule API. More...
Classes | |
struct | Transformation |
A source "transformation," represented by a character range in the source to be replaced and a corresponding replacement string. More... | |
Functions | |
ast_matchers::internal::DynTypedMatcher | buildMatcher (const RewriteRule &Rule) |
Builds a single matcher for the rule, covering all of the rule's cases. More... | |
const RewriteRule::Case & | findSelectedCase (const ast_matchers::MatchFinder::MatchResult &Result, const RewriteRule &Rule) |
Returns the Case of Rule that was selected in the match result. More... | |
Expected< SmallVector< Transformation, 1 > > | translateEdits (const ast_matchers::MatchFinder::MatchResult &Result, llvm::ArrayRef< ASTEdit > Edits) |
Attempts to translate Edits , which are in terms of AST nodes bound in the match Result , into Transformations, which are in terms of the source code text. More... | |
The following three functions are a low-level part of the RewriteRule API.
We expose them for use in implementing the fixtures that interpret RewriteRule, like Transformer and TransfomerTidy, or for more advanced users.
DynTypedMatcher clang::tooling::detail::buildMatcher | ( | const RewriteRule & | Rule | ) |
Builds a single matcher for the rule, covering all of the rule's cases.
Definition at line 184 of file Transformer.cpp.
References joinCaseMatchers(), and clang::tooling::RewriteRule::RootID.
Referenced by clang::tooling::Transformer::registerMatchers().
const RewriteRule::Case & clang::tooling::detail::findSelectedCase | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const RewriteRule & | Rule | ||
) |
Returns the Case
of Rule
that was selected in the match result.
Assumes a matcher built with buildMatcher
.
Definition at line 194 of file Transformer.cpp.
References clang::tooling::RewriteRule::Cases, i, and clang::tooling::RewriteRule::RootID.
Referenced by clang::tooling::Transformer::run().
Expected< SmallVector< tooling::detail::Transformation, 1 > > clang::tooling::detail::translateEdits | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
llvm::ArrayRef< ASTEdit > | Edits | ||
) |
Attempts to translate Edits
, which are in terms of AST nodes bound in the match Result
, into Transformations, which are in terms of the source code text.
Returns an empty vector if any of the edits apply to portions of the source that are ineligible for rewriting (certain interactions with macros, for example). Fails if any invariants are violated relating to bound nodes in the match. However, it does not fail in the case of conflicting edits – conflict handling is left to clients. We recommend use of the AtomicChange
or Replacements
classes for assistance in detecting such conflicts.
Definition at line 71 of file Transformer.cpp.
References isOriginMacroBody(), clang::tooling::detail::Transformation::Range, clang::tooling::Replacement::Replacement(), and clang::tooling::detail::Transformation::Replacement.
Referenced by clang::tooling::Transformer::run().