ΒΆllvm::Expected<SmallVector<Edit, 1>>
rewriteDescendants(
const clang::Decl& Node,
clang::transformer::RewriteRule Rule,
const ast_matchers::MatchFinder::MatchResult&
Result)
llvm::Expected<SmallVector<Edit, 1>>
rewriteDescendants(
const clang::Decl& Node,
clang::transformer::RewriteRule Rule,
const ast_matchers::MatchFinder::MatchResult&
Result)
Description
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`. ``` auto InlineX = makeRule(declRefExpr(to(varDecl(hasName("x")))), changeTo(cat("3"))); const auto *Node = Results.Nodes.getNodeAs <Stmt >("body"); auto Edits = rewriteDescendants(*Node, InlineX, Results); ``` @ {
Declared at: clang/include/clang/Tooling/Transformer/RewriteRule.h:488
Parameters
- const clang::Decl& Node
- clang::transformer::RewriteRule Rule
- const ast_matchers::MatchFinder::MatchResult& Result