clang  12.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions
clang::transformer Namespace Reference

Namespaces

 detail
 The following three functions are a low-level part of the RewriteRule API.
 

Classes

struct  ASTEdit
 
struct  Edit
 A concrete description of a source edit, represented by a character range in the source to be replaced and a corresponding replacement string. More...
 
class  MatchComputation
 A failable computation over nodes bound by AST matchers, with (limited) reflection via the toString method. More...
 
struct  RewriteRule
 Description of a source-code transformation. More...
 

Typedefs

template<typename T >
using MatchConsumer = std::function< Expected< T >(const ast_matchers::MatchFinder::MatchResult &)>
 A failable computation over nodes bound by AST matchers. More...
 
using RangeSelector = MatchConsumer< CharSourceRange >
 
using EditGenerator = MatchConsumer< llvm::SmallVector< Edit, 1 > >
 Maps a match result to a list of concrete edits (with possible failure). More...
 
using TextGenerator = std::shared_ptr< MatchComputation< std::string > >
 
using StencilInterface = MatchComputation< std::string >
 
using Stencil = std::shared_ptr< StencilInterface >
 A sequence of code fragments, references to parameters and code-generation operations that together can be evaluated to (a fragment of) source code or a diagnostic message, given a match result. More...
 

Enumerations

enum  IncludeFormat { IncludeFormat::Quoted, IncludeFormat::Angled }
 Format of the path in an include directive – angle brackets or quotes. More...
 

Functions

llvm::Error notBoundError (llvm::StringRef Id)
 Creates an error that signals that a MatchConsumer expected a certain node to be bound by AST matchers, but it was not actually bound. More...
 
template<typename T >
MatchConsumer< T > ifBound (std::string ID, MatchConsumer< T > TrueC, MatchConsumer< T > FalseC)
 Chooses between the two consumers, based on whether ID is bound in the match. More...
 
llvm::Expected< RangeSelectorparseRangeSelector (llvm::StringRef Input)
 Parses a string representation of a RangeSelector. More...
 
RangeSelector charRange (CharSourceRange R)
 
RangeSelector enclose (RangeSelector Begin, RangeSelector End)
 Selects from the start of Begin and to the end of End. More...
 
RangeSelector encloseNodes (std::string BeginID, std::string EndID)
 Convenience version of range where end-points are bound nodes. More...
 
RangeSelector range (RangeSelector Begin, RangeSelector End)
 DEPRECATED. Use enclose. More...
 
RangeSelector range (std::string BeginID, std::string EndID)
 DEPRECATED. Use encloseNodes. More...
 
RangeSelector before (RangeSelector Selector)
 Selects the (empty) range [B,B) when Selector selects the range [B,E). More...
 
RangeSelector after (RangeSelector Selector)
 Selects the the point immediately following Selector. More...
 
RangeSelector node (std::string ID)
 Selects a node, including trailing semicolon (for non-expression statements). More...
 
RangeSelector statement (std::string ID)
 Selects a node, including trailing semicolon (always). More...
 
RangeSelector member (std::string ID)
 Given a MemberExpr, selects the member token. More...
 
RangeSelector name (std::string ID)
 Given a node with a "name", (like NamedDecl, DeclRefExpr or CxxCtorInitializer) selects the name's token. More...
 
RangeSelector callArgs (std::string ID)
 
RangeSelector statements (std::string ID)
 
RangeSelector initListElements (std::string ID)
 
RangeSelector elseBranch (std::string ID)
 Given an (bound to ID), selects the range of the else branch, starting from the else keyword. More...
 
RangeSelector expansion (RangeSelector S)
 Selects the range from which S was expanded (possibly along with other source), if S is an expansion, and S itself, otherwise. More...
 
EditGenerator editList (llvm::SmallVector< ASTEdit, 1 > Edits)
 Lifts a list of ASTEdits into an EditGenerator. More...
 
EditGenerator edit (ASTEdit)
 
RewriteRule makeRule (ast_matchers::internal::DynTypedMatcher M, EditGenerator Edits, TextGenerator Explanation=nullptr)
 Convenience function for constructing a simple RewriteRule. More...
 
RewriteRule makeRule (ast_matchers::internal::DynTypedMatcher M, llvm::SmallVector< ASTEdit, 1 > Edits, TextGenerator Explanation=nullptr)
 Convenience function for constructing a RewriteRule from multiple ASTEdits. More...
 
RewriteRule makeRule (ast_matchers::internal::DynTypedMatcher M, ASTEdit Edit, TextGenerator Explanation=nullptr)
 Convenience overload of makeRule for common case of only one edit. More...
 
void addInclude (RewriteRule &Rule, llvm::StringRef Header, IncludeFormat Format=IncludeFormat::Quoted)
 For every case in Rule, adds an include directive for the given header. More...
 
RewriteRule applyFirst (ArrayRef< RewriteRule > Rules)
 Applies the first rule whose pattern matches; other rules are ignored. More...
 
ASTEdit changeTo (RangeSelector Target, TextGenerator Replacement)
 Replaces a portion of the source text with Replacement. More...
 
ASTEdit change (RangeSelector Target, TextGenerator Replacement)
 DEPRECATED: use changeTo. More...
 
ASTEdit changeTo (TextGenerator Replacement)
 Replaces the entirety of a RewriteRule's match with Replacement. More...
 
ASTEdit change (TextGenerator Replacement)
 DEPRECATED: use changeTo. More...
 
ASTEdit insertBefore (RangeSelector S, TextGenerator Replacement)
 Inserts Replacement before S, leaving the source selected by unchanged. More...
 
ASTEdit insertAfter (RangeSelector S, TextGenerator Replacement)
 Inserts Replacement after S, leaving the source selected by unchanged. More...
 
ASTEdit remove (RangeSelector S)
 Removes the source selected by S. More...
 
ASTEdit withMetadata (ASTEdit edit, llvm::Any Metadata)
 
Stencil catVector (std::vector< Stencil > Parts)
 Constructs the string representing the concatenation of the given Parts. More...
 
template<typename... Ts>
Stencil cat (Ts &&... Parts)
 Concatenates 0+ stencil pieces into a single stencil. More...
 
Stencil expression (llvm::StringRef Id)
 Generates the source of the expression bound to Id, wrapping it in parentheses if it may parse differently depending on context. More...
 
Stencil deref (llvm::StringRef ExprId)
 Constructs an idiomatic dereferencing of the expression bound to ExprId. More...
 
Stencil maybeDeref (llvm::StringRef ExprId)
 If ExprId is of pointer type, constructs an idiomatic dereferencing of the expression bound to ExprId, including wrapping it in parentheses, if needed. More...
 
Stencil addressOf (llvm::StringRef ExprId)
 Constructs an expression that idiomatically takes the address of the expression bound to ExprId. More...
 
Stencil maybeAddressOf (llvm::StringRef ExprId)
 If ExprId is not a pointer type, constructs an expression that idiomatically takes the address of the expression bound to ExprId, including wrapping ExprId in parentheses, if needed. More...
 
Stencil access (llvm::StringRef BaseId, Stencil Member)
 Constructs a MemberExpr that accesses the named member (Member) of the object bound to BaseId. More...
 
Stencil access (llvm::StringRef BaseId, llvm::StringRef Member)
 
Stencil ifBound (llvm::StringRef Id, Stencil TrueStencil, Stencil FalseStencil)
 Chooses between the two stencil parts, based on whether ID is bound in the match. More...
 
Stencil ifBound (llvm::StringRef Id, llvm::StringRef TrueText, llvm::StringRef FalseText)
 Chooses between the two strings, based on whether ID is bound in the match. More...
 
Stencil run (MatchConsumer< std::string > C)
 Wraps a MatchConsumer in a Stencil, so that it can be used in a Stencil. More...
 
Stencil dPrint (llvm::StringRef Id)
 For debug use only; semantics are not guaranteed. More...
 

Typedef Documentation

◆ EditGenerator

Maps a match result to a list of concrete edits (with possible failure).

This type is a building block of rewrite rules, but users will generally work in terms of ASTEdits (below) rather than directly in terms of EditGenerator.

Definition at line 46 of file RewriteRule.h.

◆ MatchConsumer

template<typename T >
using clang::transformer::MatchConsumer = typedef std::function<Expected<T>(const ast_matchers::MatchFinder::MatchResult &)>

A failable computation over nodes bound by AST matchers.

The computation should report any errors though its return value (rather than terminating the program) to enable usage in interactive scenarios like clang-query.

This is a central abstraction of the Transformer framework.

Definition at line 35 of file MatchConsumer.h.

◆ RangeSelector

Definition at line 27 of file RangeSelector.h.

◆ Stencil

using clang::transformer::Stencil = typedef std::shared_ptr<StencilInterface>

A sequence of code fragments, references to parameters and code-generation operations that together can be evaluated to (a fragment of) source code or a diagnostic message, given a match result.

We use a shared_ptr to allow for easy and cheap copying of stencils. Since StencilInterface is an immutable interface, the sharing doesn't impose any risks. Otherwise, we would have to add a virtual copy method to the API and implement it for all derived classes.

Definition at line 46 of file Stencil.h.

◆ StencilInterface

Definition at line 36 of file Stencil.h.

◆ TextGenerator

using clang::transformer::TextGenerator = typedef std::shared_ptr<MatchComputation<std::string> >

Definition at line 48 of file RewriteRule.h.

Enumeration Type Documentation

◆ IncludeFormat

Format of the path in an include directive – angle brackets or quotes.

Enumerator
Quoted 
Angled 

Definition at line 107 of file RewriteRule.h.

Function Documentation

◆ access() [1/2]

Stencil clang::transformer::access ( llvm::StringRef  BaseId,
Stencil  Member 
)

Constructs a MemberExpr that accesses the named member (Member) of the object bound to BaseId.

The access is constructed idiomatically: if BaseId is bound to e and Member identifies member m, then returns e->m, when e is a pointer, e2->m when e = *e2 and e.m otherwise. Additionally, e is wrapped in parentheses, if needed.

Referenced by access(), cat(), clang::Sema::CheckFriendAccess(), and maybeAddressOf().

◆ access() [2/2]

Stencil clang::transformer::access ( llvm::StringRef  BaseId,
llvm::StringRef  Member 
)
inline

Definition at line 106 of file Stencil.h.

References access(), ifBound(), and clang::transformer::detail::makeStencil().

◆ addInclude()

void clang::transformer::addInclude ( RewriteRule Rule,
llvm::StringRef  Header,
IncludeFormat  Format = IncludeFormat::Quoted 
)

For every case in Rule, adds an include directive for the given header.

The common use is assumed to be a rule with only one case. For example, to replace a function call and add headers corresponding to the new code, one could write:

auto R = makeRule(callExpr(callee(functionDecl(hasName("foo")))),
changeTo(cat("bar()")));
AddInclude(R, "path/to/bar_header.h");
AddInclude(R, "vector", IncludeFormat::Angled);

Referenced by makeRule().

◆ addressOf()

Stencil clang::transformer::addressOf ( llvm::StringRef  ExprId)

Constructs an expression that idiomatically takes the address of the expression bound to ExprId.

ExprId is wrapped in parentheses, if needed.

Definition at line 352 of file Stencil.cpp.

Referenced by cat().

◆ after()

RangeSelector clang::transformer::after ( RangeSelector  Selector)

Selects the the point immediately following Selector.

That is, the (empty) range [E,E), when Selector selects either

  • the CharRange [B,E) or
  • the TokenRange [B,E'] where the token at E' spans the range [E',E).

Definition at line 114 of file RangeSelector.cpp.

References clang::CharSourceRange::getCharRange(), clang::Decl::getLangOpts(), and clang::Lexer::getLocForEndOfToken().

Referenced by getUnaryRangeSelectors(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertWrap(), and range().

◆ applyFirst()

RewriteRule clang::transformer::applyFirst ( ArrayRef< RewriteRule Rules)

Applies the first rule whose pattern matches; other rules are ignored.

If the matchers are independent then order doesn't matter. In that case, applyFirst is simply joining the set of rules into one.

Definition at line 145 of file RewriteRule.cpp.

References clang::transformer::RewriteRule::Cases.

Referenced by makeRule().

◆ before()

RangeSelector clang::transformer::before ( RangeSelector  Selector)

◆ callArgs()

RangeSelector clang::transformer::callArgs ( std::string  ID)

◆ cat()

template<typename... Ts>
Stencil clang::transformer::cat ( Ts &&...  Parts)

Concatenates 0+ stencil pieces into a single stencil.

Arguments can be raw text, ranges in the matched code (RangeSelector) or other Stencils.

Definition at line 64 of file Stencil.h.

References access(), addressOf(), catVector(), deref(), expression(), Id, clang::transformer::detail::makeStencil(), maybeAddressOf(), and maybeDeref().

Referenced by clang::tooling::ArgumentsAdjustingCompilations::getAllCompileCommands(), clang::ASTContext::getVariableArrayDecayedType(), and clang::DiagnosticIDs::isARCDiagnostic().

◆ catVector()

Stencil clang::transformer::catVector ( std::vector< Stencil Parts)

Constructs the string representing the concatenation of the given Parts.

If only one element is passed in Parts, returns that element.

Definition at line 377 of file Stencil.cpp.

Referenced by cat().

◆ change() [1/2]

ASTEdit clang::transformer::change ( RangeSelector  Target,
TextGenerator  Replacement 
)
inline

DEPRECATED: use changeTo.

Definition at line 230 of file RewriteRule.h.

References changeTo().

◆ change() [2/2]

ASTEdit clang::transformer::change ( TextGenerator  Replacement)
inline

DEPRECATED: use changeTo.

Definition at line 245 of file RewriteRule.h.

References changeTo().

◆ changeTo() [1/2]

ASTEdit clang::transformer::changeTo ( RangeSelector  Target,
TextGenerator  Replacement 
)

Replaces a portion of the source text with Replacement.

Definition at line 68 of file RewriteRule.cpp.

References clang::transformer::ASTEdit::Replacement, and clang::transformer::ASTEdit::TargetRange.

Referenced by change(), changeTo(), and makeRule().

◆ changeTo() [2/2]

ASTEdit clang::transformer::changeTo ( TextGenerator  Replacement)
inline

Replaces the entirety of a RewriteRule's match with Replacement.

For example, to replace a function call, one could write:

changeTo(cat("bar()")))

Definition at line 240 of file RewriteRule.h.

References changeTo(), node(), and clang::transformer::RewriteRule::RootID.

◆ charRange()

RangeSelector clang::transformer::charRange ( CharSourceRange  R)
inline

Definition at line 29 of file RangeSelector.h.

References Begin, enclose(), encloseNodes(), and End.

◆ deref()

Stencil clang::transformer::deref ( llvm::StringRef  ExprId)

Constructs an idiomatic dereferencing of the expression bound to ExprId.

ExprId is wrapped in parentheses, if needed.

Definition at line 342 of file Stencil.cpp.

Referenced by AddLazyVectorDecls(), cat(), getDeclForLocalLookup(), and shouldIgnoreMacro().

◆ dPrint()

Stencil clang::transformer::dPrint ( llvm::StringRef  Id)

For debug use only; semantics are not guaranteed.

Returns
the string resulting from calling the node's print() method.

Referenced by ifBound(), and clang::transformer::detail::makeStencil().

◆ edit()

EditGenerator clang::transformer::edit ( ASTEdit  Edit)

Definition at line 62 of file RewriteRule.cpp.

References translateEdits().

Referenced by clang::edit::EditedSource::commit(), makeRule(), and withMetadata().

◆ editList()

EditGenerator clang::transformer::editList ( llvm::SmallVector< ASTEdit, 1 >  Edits)

Lifts a list of ASTEdits into an EditGenerator.

The EditGenerator will return 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) and it will fail 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 56 of file RewriteRule.cpp.

References translateEdits().

Referenced by makeRule().

◆ elseBranch()

RangeSelector clang::transformer::elseBranch ( std::string  ID)

Given an (bound to ID), selects the range of the else branch, starting from the else keyword.

Definition at line 302 of file RangeSelector.cpp.

Referenced by getUnaryStringSelectors(), and range().

◆ enclose()

RangeSelector clang::transformer::enclose ( RangeSelector  Begin,
RangeSelector  End 
)

Selects from the start of Begin and to the end of End.

Definition at line 149 of file RangeSelector.cpp.

References Begin, End, and invalidArgumentError().

Referenced by charRange(), encloseNodes(), and range().

◆ encloseNodes()

RangeSelector clang::transformer::encloseNodes ( std::string  BeginID,
std::string  EndID 
)

Convenience version of range where end-points are bound nodes.

Definition at line 168 of file RangeSelector.cpp.

References enclose(), and node().

Referenced by charRange(), and range().

◆ expansion()

RangeSelector clang::transformer::expansion ( RangeSelector  S)

Selects the range from which S was expanded (possibly along with other source), if S is an expansion, and S itself, otherwise.

Corresponds to SourceManager::getExpansionRange.

Definition at line 306 of file RangeSelector.cpp.

Referenced by getUnaryRangeSelectors(), and range().

◆ expression()

Stencil clang::transformer::expression ( llvm::StringRef  Id)

Generates the source of the expression bound to Id, wrapping it in parentheses if it may parse differently depending on context.

For example, a binary operation is always wrapped, while a variable reference is never wrapped.

Definition at line 337 of file Stencil.cpp.

Referenced by cat(), and clang::syntax::ExpressionStatement::classof().

◆ ifBound() [1/3]

template<typename T >
MatchConsumer<T> clang::transformer::ifBound ( std::string  ID,
MatchConsumer< T >  TrueC,
MatchConsumer< T >  FalseC 
)

Chooses between the two consumers, based on whether ID is bound in the match.

Definition at line 47 of file MatchConsumer.h.

Referenced by access(), clang::transformer::MatchComputation< T >::eval(), ifBound(), and maybeAddressOf().

◆ ifBound() [2/3]

Stencil clang::transformer::ifBound ( llvm::StringRef  Id,
Stencil  TrueStencil,
Stencil  FalseStencil 
)

Chooses between the two stencil parts, based on whether ID is bound in the match.

◆ ifBound() [3/3]

Stencil clang::transformer::ifBound ( llvm::StringRef  Id,
llvm::StringRef  TrueText,
llvm::StringRef  FalseText 
)
inline

Chooses between the two strings, based on whether ID is bound in the match.

Definition at line 116 of file Stencil.h.

References dPrint(), ifBound(), clang::transformer::detail::makeStencil(), and run().

◆ initListElements()

RangeSelector clang::transformer::initListElements ( std::string  ID)

Definition at line 289 of file RangeSelector.cpp.

Referenced by getUnaryStringSelectors(), and range().

◆ insertAfter()

ASTEdit clang::transformer::insertAfter ( RangeSelector  S,
TextGenerator  Replacement 
)
inline

Inserts Replacement after S, leaving the source selected by unchanged.

Definition at line 257 of file RewriteRule.h.

◆ insertBefore()

ASTEdit clang::transformer::insertBefore ( RangeSelector  S,
TextGenerator  Replacement 
)
inline

Inserts Replacement before S, leaving the source selected by unchanged.

Definition at line 251 of file RewriteRule.h.

◆ makeRule() [1/3]

RewriteRule clang::transformer::makeRule ( ast_matchers::internal::DynTypedMatcher  M,
EditGenerator  Edits,
TextGenerator  Explanation = nullptr 
)

Convenience function for constructing a simple RewriteRule.

Definition at line 97 of file RewriteRule.cpp.

References addInclude(), and clang::transformer::RewriteRule::Cases.

Referenced by makeRule().

◆ makeRule() [2/3]

RewriteRule clang::transformer::makeRule ( ast_matchers::internal::DynTypedMatcher  M,
llvm::SmallVector< ASTEdit, 1 >  Edits,
TextGenerator  Explanation = nullptr 
)
inline

Convenience function for constructing a RewriteRule from multiple ASTEdits.

Definition at line 159 of file RewriteRule.h.

References editList(), and makeRule().

◆ makeRule() [3/3]

RewriteRule clang::transformer::makeRule ( ast_matchers::internal::DynTypedMatcher  M,
ASTEdit  Edit,
TextGenerator  Explanation = nullptr 
)
inline

Convenience overload of makeRule for common case of only one edit.

Definition at line 167 of file RewriteRule.h.

References addInclude(), applyFirst(), changeTo(), edit(), makeRule(), Quoted, clang::transformer::Edit::Replacement, and clang::Target.

◆ maybeAddressOf()

Stencil clang::transformer::maybeAddressOf ( llvm::StringRef  ExprId)

If ExprId is not a pointer type, constructs an expression that idiomatically takes the address of the expression bound to ExprId, including wrapping ExprId in parentheses, if needed.

Otherwise, generates the original expression source. FIXME: Identify smart-pointers as pointer types.

Definition at line 357 of file Stencil.cpp.

References access(), Id, and ifBound().

Referenced by cat().

◆ maybeDeref()

Stencil clang::transformer::maybeDeref ( llvm::StringRef  ExprId)

If ExprId is of pointer type, constructs an idiomatic dereferencing of the expression bound to ExprId, including wrapping it in parentheses, if needed.

Otherwise, generates the original expression source. FIXME: Identify smart-pointers as pointer types.

Definition at line 347 of file Stencil.cpp.

Referenced by cat().

◆ member()

RangeSelector clang::transformer::member ( std::string  ID)

Given a MemberExpr, selects the member token.

ID is the node's binding in the match result.

Definition at line 173 of file RangeSelector.cpp.

References getNode(), clang::CharSourceRange::getTokenRange(), Node, and typeError().

Referenced by findRetainCycleOwner(), getUnaryStringSelectors(), isExplicitMemberSpecialization(), and range().

◆ name()

RangeSelector clang::transformer::name ( std::string  ID)

Given a node with a "name", (like NamedDecl, DeclRefExpr or CxxCtorInitializer) selects the name's token.

Only selects the final identifier of a qualified name, but not any qualifiers or template arguments. For example, for ::foo::bar::baz and ::foo::bar::baz<int>, it selects only baz.

Parameters
IDis the node's binding in the match result.

Definition at line 185 of file RangeSelector.cpp.

References clang::DynTypedNode::get(), clang::CharSourceRange::getCharRange(), clang::CompoundStmt::getLBracLoc(), clang::SourceLocation::getLocWithOffset(), getNode(), clang::DynTypedNode::getNodeKind(), clang::CompoundStmt::getRBracLoc(), clang::tooling::getText(), clang::CharSourceRange::getTokenRange(), missingPropertyError(), Node, clang::ast_matchers::MatchFinder::MatchResult::Nodes, and typeError().

Referenced by AddRelativeLayoutOffset(), createLoadInstBefore(), clang::Sema::Diag(), emitArraySubscriptGEP(), clang::CodeGen::CodeGenFunction::EmitBlockLiteral(), clang::CodeGen::CodeGenFunction::emitByrefStructureInit(), clang::CodeGen::CodeGenFunction::GenerateBlockFunction(), clang::CodeGen::CodeGenFunction::getCleanupKind(), getFunctionSourceLocation(), clang::Selector::getInstTypeMethodFamily(), clang::NamedDecl::getObjCFStringFormattingFamily(), clang::ento::BugReporter::getPreprocessor(), clang::CodeGen::CodeGenModule::getTerminateFn(), getUnaryStringSelectors(), handleObjCOwnershipTypeAttr(), clang::CodeGen::ConstantInitFuture::installInGlobal(), clang::NSAPI::isNSNumberLiteralSelector(), clang::NSAPI::isSubclassOfNSClass(), mangleAArch64VectorBase(), MigrateBlockOrFunctionPointerTypeVariable(), range(), clang::ento::CheckerManager::setCurrentCheckerName(), clang::ObjCDeclSpec::setGetterName(), clang::ObjCDeclSpec::setSetterName(), startsWithWord(), and clang::CodeGen::ConstantInitBuilderBase::~ConstantInitBuilderBase().

◆ node()

RangeSelector clang::transformer::node ( std::string  ID)

◆ notBoundError()

llvm::Error clang::transformer::notBoundError ( llvm::StringRef  Id)
inline

Creates an error that signals that a MatchConsumer expected a certain node to be bound by AST matchers, but it was not actually bound.

Definition at line 39 of file MatchConsumer.h.

References Id.

◆ parseRangeSelector()

Expected< RangeSelector > clang::transformer::parseRangeSelector ( llvm::StringRef  Input)

Parses a string representation of a RangeSelector.

The grammar of these strings is closely based on the (sub)grammar of RangeSelectors as they'd appear in C++ code. However, this language constrains the set of permissible strings (for node ids) – it does not support escapes in the string. Additionally, the charRange combinator is not supported, because there is no representation of values of type CharSourceRange in this (little) language.

Definition at line 268 of file Parsing.cpp.

References consumeWhitespace(), makeParseError(), parseRangeSelectorImpl(), and State.

◆ range() [1/2]

RangeSelector clang::transformer::range ( RangeSelector  Begin,
RangeSelector  End 
)
inline

◆ range() [2/2]

RangeSelector clang::transformer::range ( std::string  BeginID,
std::string  EndID 
)
inline

DEPRECATED. Use encloseNodes.

Definition at line 46 of file RangeSelector.h.

References after(), before(), callArgs(), elseBranch(), encloseNodes(), expansion(), initListElements(), member(), name(), node(), statement(), and statements().

◆ remove()

ASTEdit clang::transformer::remove ( RangeSelector  S)

◆ run()

Stencil clang::transformer::run ( MatchConsumer< std::string >  C)

Wraps a MatchConsumer in a Stencil, so that it can be used in a Stencil.

This supports user-defined extensions to the Stencil language.

Definition at line 372 of file Stencil.cpp.

Referenced by clang::tooling::CompilationDatabase::getAllCompileCommands(), clang::consumed::ConsumedAnalyzer::getExpectedReturnState(), ifBound(), clang::tooling::ToolInvocation::setDiagnosticConsumer(), and clang::tooling::ClangTool::setDiagnosticConsumer().

◆ statement()

RangeSelector clang::transformer::statement ( std::string  ID)

Selects a node, including trailing semicolon (always).

Useful for selecting expression statements. ID is the node's binding in the match result.

Definition at line 139 of file RangeSelector.cpp.

References clang::tooling::getExtendedRange(), getNode(), and Node.

Referenced by getUnaryStringSelectors(), and range().

◆ statements()

RangeSelector clang::transformer::statements ( std::string  ID)

◆ withMetadata()

ASTEdit clang::transformer::withMetadata ( ASTEdit  edit,
llvm::Any  Metadata 
)
inline

Definition at line 264 of file RewriteRule.h.

References edit(), and clang::transformer::ASTEdit::Metadata.