clang 22.0.0git
|
The following three functions are a low-level part of the RewriteRule API. More...
Functions | |
EditGenerator | injectEdits (ASTEdit E) |
Helper function to construct an EditGenerator . | |
EditGenerator | injectEdits (EditGenerator G) |
RewriteRule | makeRule (ast_matchers::internal::DynTypedMatcher M, EditGenerator Edits) |
template<typename MetadataT> | |
RewriteRuleWith< MetadataT > | makeRule (ast_matchers::internal::DynTypedMatcher M, EditGenerator Edits, Generator< MetadataT > Metadata) |
EditGenerator | makeEditGenerator (EditGenerator Edits) |
EditGenerator | makeEditGenerator (llvm::SmallVector< ASTEdit, 1 > Edits) |
EditGenerator | makeEditGenerator (ASTEdit Edit) |
ast_matchers::internal::DynTypedMatcher | buildMatcher (const RewriteRuleBase &Rule) |
Builds a single matcher for the rule, covering all of the rule's cases. | |
std::vector< ast_matchers::internal::DynTypedMatcher > | buildMatchers (const RewriteRuleBase &Rule) |
Builds a set of matchers that cover the rule. | |
SourceLocation | getRuleMatchLoc (const ast_matchers::MatchFinder::MatchResult &Result) |
Gets the beginning location of the source matched by a rewrite rule. | |
size_t | findSelectedCase (const ast_matchers::MatchFinder::MatchResult &Result, const RewriteRuleBase &Rule) |
Returns the index of the Case of Rule that was selected in the match result. | |
Stencil | makeStencil (llvm::StringRef Text) |
Convenience function to construct a Stencil . | |
Stencil | makeStencil (RangeSelector Selector) |
Stencil | makeStencil (Stencil S) |
llvm::Expected< SmallVector< Edit, 1 > > | rewriteDescendants (const Decl &Node, RewriteRule Rule, const ast_matchers::MatchFinder::MatchResult &Result) |
The following overload set is a version of rewriteDescendants that operates directly on the AST, rather than generating a Transformer combinator. | |
llvm::Expected< SmallVector< Edit, 1 > > | rewriteDescendants (const Stmt &Node, RewriteRule Rule, const ast_matchers::MatchFinder::MatchResult &Result) |
llvm::Expected< SmallVector< Edit, 1 > > | rewriteDescendants (const TypeLoc &Node, RewriteRule Rule, const ast_matchers::MatchFinder::MatchResult &Result) |
llvm::Expected< SmallVector< Edit, 1 > > | rewriteDescendants (const DynTypedNode &Node, RewriteRule Rule, const ast_matchers::MatchFinder::MatchResult &Result) |
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::transformer::detail::buildMatcher | ( | const RewriteRuleBase & | Rule | ) |
Builds a single matcher for the rule, covering all of the rule's cases.
Only supports Rules whose cases' matchers share the same base "kind" (Stmt, Decl, etc.) Deprecated: use buildMatchers instead, which supports mixing matchers of different kinds.
Definition at line 441 of file RewriteRule.cpp.
References buildMatchers().
std::vector< DynTypedMatcher > clang::transformer::detail::buildMatchers | ( | const RewriteRuleBase & | Rule | ) |
Builds a set of matchers that cover the rule.
One matcher is built for each distinct node matcher base kind: Stmt, Decl, etc. Node-matchers for QualType and Type are not permitted, since such nodes carry no source location information and are therefore not relevant for rewriting. If any such matchers are included, will return an empty vector.
Definition at line 409 of file RewriteRule.cpp.
References hasValidKind(), clang::transformer::RootID, taggedMatchers(), and clang::TK_AsIs.
Referenced by buildMatcher().
size_t clang::transformer::detail::findSelectedCase | ( | const ast_matchers::MatchFinder::MatchResult & | Result, |
const RewriteRuleBase & | Rule ) |
Returns the index of the Case
of Rule
that was selected in the match result.
Assumes a matcher built with buildMatcher
.
References clang::Result.
SourceLocation clang::transformer::detail::getRuleMatchLoc | ( | const ast_matchers::MatchFinder::MatchResult & | Result | ) |
Gets the beginning location of the source matched by a rewrite rule.
If the match occurs within a macro expansion, returns the beginning of the expansion point. Result must come from the matching of a rewrite rule.
References clang::Result.
|
inline |
Helper function to construct an EditGenerator
.
Overloaded for common cases so that user doesn't need to specify which factory function to use. This pattern gives benefits similar to implicit constructors, while maintaing a higher degree of explicitness.
Definition at line 168 of file RewriteRule.h.
References clang::transformer::edit().
Referenced by clang::transformer::flatten().
|
inline |
Definition at line 169 of file RewriteRule.h.
EditGenerator clang::transformer::detail::makeEditGenerator | ( | ASTEdit | Edit | ) |
Definition at line 189 of file RewriteRule.cpp.
References clang::transformer::edit().
|
inline |
Definition at line 318 of file RewriteRule.h.
Referenced by clang::transformer::makeRule(), clang::transformer::makeRule(), clang::transformer::makeRule(), and clang::transformer::makeRule().
EditGenerator clang::transformer::detail::makeEditGenerator | ( | llvm::SmallVector< ASTEdit, 1 > | Edits | ) |
Definition at line 185 of file RewriteRule.cpp.
References clang::transformer::editList().
RewriteRule clang::transformer::detail::makeRule | ( | ast_matchers::internal::DynTypedMatcher | M, |
EditGenerator | Edits ) |
RewriteRuleWith< MetadataT > clang::transformer::detail::makeRule | ( | ast_matchers::internal::DynTypedMatcher | M, |
EditGenerator | Edits, | ||
Generator< MetadataT > | Metadata ) |
Definition at line 309 of file RewriteRule.h.
References clang::transformer::RewriteRuleBase::Cases, and clang::transformer::RewriteRuleWith< MetadataT >::Metadata.
Stencil clang::transformer::detail::makeStencil | ( | llvm::StringRef | Text | ) |
Convenience function to construct a Stencil
.
Overloaded for common cases so that user doesn't need to specify which factory function to use. This pattern gives benefits similar to implicit constructors, while maintaing a higher degree of explicitness.
References clang::Text.
Referenced by clang::transformer::access(), clang::transformer::cat(), and clang::transformer::ifBound().
Stencil clang::transformer::detail::makeStencil | ( | RangeSelector | Selector | ) |
Definition at line 434 of file Stencil.cpp.
llvm::Expected< SmallVector< Edit, 1 > > clang::transformer::detail::rewriteDescendants | ( | const Decl & | Node, |
RewriteRule | Rule, | ||
const ast_matchers::MatchFinder::MatchResult & | Result ) |
The following overload set is a version of rewriteDescendants that operates directly on the AST, rather than generating a Transformer combinator.
It applies Rule to all descendants of Node, although not Node itself. Rule can refer to nodes bound in Result.
For example, assuming that "body" is bound to a function body in MatchResult Results, this will produce edits to change all appearances of x in that body to 3.
References clang::Result.
Referenced by clang::transformer::rewriteDescendants().
llvm::Expected< SmallVector< Edit, 1 > > clang::transformer::detail::rewriteDescendants | ( | const DynTypedNode & | Node, |
RewriteRule | Rule, | ||
const ast_matchers::MatchFinder::MatchResult & | Result ) |
References clang::Result.
llvm::Expected< SmallVector< Edit, 1 > > clang::transformer::detail::rewriteDescendants | ( | const Stmt & | Node, |
RewriteRule | Rule, | ||
const ast_matchers::MatchFinder::MatchResult & | Result ) |
References clang::Result.
llvm::Expected< SmallVector< Edit, 1 > > clang::transformer::detail::rewriteDescendants | ( | const TypeLoc & | Node, |
RewriteRule | Rule, | ||
const ast_matchers::MatchFinder::MatchResult & | Result ) |
References clang::Result.