;
24using namespacetransformer;
28usingllvm::StringError;
33 returnllvm::make_error<StringError>(llvm::errc::invalid_argument, Message);
38 " kind="+ Kind.asStringRef() +
")");
45 " kind="+ Kind.asStringRef() +
")");
51 "' (node id="+ ID +
")");
56 auto&NodesMap =
Nodes.getMap();
57 autoIt = NodesMap.find(ID);
58 if(It == NodesMap.end())
93 return T.getLocation();
103 returnSelectedRange.takeError();
112 returnSelectedRange.takeError();
114 if(SelectedRange->isTokenRange()) {
123*Result.SourceManager, Result.Context->
getLangOpts());
126 "after: can't resolve sub-range to valid source range");
138 return Node.takeError();
151 return Node.takeError();
161 returnBeginRange.takeError();
164 returnEndRange.takeError();
169 if(Result.SourceManager->isBeforeInTranslationUnit(
E, B)) {
185 return Node.takeError();
188M->getMemberNameInfo().getSourceRange());
197 returnN.takeError();
200 if(!
D->getDeclName().isIdentifier())
214 if(!
E->getNameInfo().getName().isIdentifier())
220 if(!I->isMemberInitializer() && I->isWritten())
229 Loc= ET.getNamedTypeLoc();
236 "DeclRefExpr, NamedDecl, CXXCtorInitializer, TypeLoc");
247template<
typenameT, CharSourceRange (*Func)(const MatchResult &, const T &)>
248classRelativeSelector {
252RelativeSelector(std::string ID) : ID(
std::move(ID)) {}
257 returnN.takeError();
258 if(
const auto*Arg = N->get<
T>())
259 return Func(Result, *Arg);
279 returnRelativeSelector<CompoundStmt, getStatementsRange>(std::move(ID));
287 return E.getParenOrBraceRange().getEnd();
291 returntok::TokenKind::l_paren;
295 returnisa<CXXTemporaryObjectExpr>(
E) ? tok::TokenKind::l_paren
296: tok::TokenKind::l_brace;
299template<
typenameExprWithArgs>
308template<
typenameExprWithArgs>
310 constExprWithArgs &CE) {
313findArgStartDelimiter(CE, RLoc, *Result.SourceManager,
315.getLocWithOffset(1),
321 returnRelativeSelector<CallExpr, getArgumentsRange<CallExpr>>(std::move(ID));
326getArgumentsRange<CXXConstructExpr>>(std::move(ID));
340 returnRelativeSelector<InitListExpr, getElementsRange>(std::move(ID));
348tok::TokenKind::semi, *Result.Context);
353 returnRelativeSelector<IfStmt, getElseRange>(std::move(ID));
360 returnSRange.takeError();
361 returnResult.SourceManager->getExpansionRange(*SRange);
BoundNodesTreeBuilder Nodes
static Error invalidArgumentError(Twine Message)
static SourceLocation findPreviousTokenKind(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts, tok::TokenKind TK)
static SourceLocation findPreviousTokenStart(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts)
static Error missingPropertyError(StringRef ID, Twine Description, StringRef Property)
static Error typeError(StringRef ID, const ASTNodeKind &Kind)
static Expected< DynTypedNode > getNode(const ast_matchers::BoundNodes &Nodes, StringRef ID)
Defines a combinator library supporting the definition of selectors, which select source ranges based...
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TypeLoc interface and its subclasses.
Represents a call to a C++ constructor.
Represents a C++ base or member initializer.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CompoundStmt - This represents a group of statements like { stmt stmt }.
SourceLocation getLBracLoc() const
SourceLocation getRBracLoc() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
ASTNodeKind getNodeKind() const
SourceRange getSourceRange() const
For nodes which represent textual entities in the source code, return their SourceRange.
const T * get() const
Retrieve the stored node as type T.
This represents one expression.
IfStmt - This represents an if/then/else.
Describes an C or C++ initializer list.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static CharSourceRange makeFileCharRange(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
Accepts a range and returns a character range with file locations.
static SourceLocation GetBeginningOfToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Given a location any where in a source buffer, find the location that corresponds to the beginning of...
static bool getRawToken(SourceLocation Loc, Token &Result, const SourceManager &SM, const LangOptions &LangOpts, bool IgnoreWhiteSpace=false)
Relex the token at the specified location.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
This represents a decl that may have a name.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
Stmt - This represents one statement.
SourceLocation getBeginLoc() const LLVM_READONLY
Token - This structure provides full information about a lexed token.
Base wrapper for a particular "section" of type source info.
Maps string IDs to AST nodes matched by parts of a matcher.
A class to allow finding matches over the Clang AST.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
RangeSelector initListElements(std::string ID)
RangeSelector enclose(RangeSelector Begin, RangeSelector End)
Selects from the start of Begin and to the end of End.
RangeSelector member(std::string ID)
Given a MemberExpr, selects the member token.
RangeSelector elseBranch(std::string ID)
Given an \IfStmt (bound to ID), selects the range of the else branch, starting from the else keyword.
RangeSelector node(std::string ID)
Selects a node, including trailing semicolon, if any (for declarations and non-expression statements)...
MatchConsumer< CharSourceRange > RangeSelector
RangeSelector encloseNodes(std::string BeginID, std::string EndID)
Convenience version of range where end-points are bound nodes.
RangeSelector after(RangeSelector Selector)
Selects the point immediately following Selector.
RangeSelector constructExprArgs(std::string ID)
RangeSelector callArgs(std::string ID)
RangeSelector before(RangeSelector Selector)
Selects the (empty) range [B,B) when Selector selects the range [B,E).
RangeSelector statement(std::string ID)
Selects a node, including trailing semicolon (always).
RangeSelector expansion(RangeSelector S)
Selects the range from which S was expanded (possibly along with other source), if S is an expansion,...
RangeSelector statements(std::string ID)
RangeSelector name(std::string ID)
Given a node with a "name", (like NamedDecl, DeclRefExpr, CxxCtorInitializer, and TypeLoc) selects th...
The JSON file list parser is used to communicate input to InstallAPI.
@ Property
The type of a property.
const FunctionProtoType * T
Contains all information for a given match.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4