16#include "llvm/ADT/StringRef.h" 
   17#include "llvm/Support/Errc.h" 
   18#include "llvm/Support/Error.h" 
   27using llvm::StringError;
 
   32  return llvm::make_error<StringError>(llvm::errc::invalid_argument, Message);
 
 
   37                              " kind=" + Kind.asStringRef() + 
")");
 
 
   44                              " kind=" + Kind.asStringRef() + 
")");
 
 
   50                              "' (node id=" + ID + 
")");
 
 
   55  auto &NodesMap = Nodes.
getMap();
 
   56  auto It = NodesMap.find(ID);
 
   57  if (It == NodesMap.end())
 
 
   92      return T.getLocation();
 
 
  102      return SelectedRange.takeError();
 
 
  111      return SelectedRange.takeError();
 
  113    if (SelectedRange->isTokenRange()) {
 
  123      if (
Range.isInvalid())
 
  125            "after: can't resolve sub-range to valid source range");
 
  126      End = 
Range.getEnd();
 
 
  137      return Node.takeError();
 
  138    return (Node->get<
Decl>() != 
nullptr ||
 
  139            (Node->get<
Stmt>() != 
nullptr && Node->get<
Expr>() == 
nullptr))
 
 
  150      return Node.takeError();
 
 
  160      return BeginRange.takeError();
 
  163      return EndRange.takeError();
 
  168    if (
Result.SourceManager->isBeforeInTranslationUnit(E, B)) {
 
 
  184      return Node.takeError();
 
  187          M->getMemberNameInfo().getSourceRange());
 
  188    return typeError(ID, Node->getNodeKind(), 
"MemberExpr");
 
 
  196      return N.takeError();
 
  198    if (
const auto *D = Node.get<
NamedDecl>()) {
 
  199      if (!D->getDeclName().isIdentifier())
 
  213      if (!E->getNameInfo().getName().isIdentifier())
 
  219      if (!I->isMemberInitializer() && I->isWritten())
 
  224    if (
const auto *
T = Node.get<
TypeLoc>()) {
 
  231                     "DeclRefExpr, NamedDecl, CXXCtorInitializer, TypeLoc");
 
 
  242template <
typename T, CharSourceRange (*Func)(const MatchResult &, const T &)>
 
  243class RelativeSelector {
 
  247  RelativeSelector(std::string ID) : ID(
std::move(ID)) {}
 
  252      return N.takeError();
 
  253    if (
const auto *Arg = N->get<
T>())
 
  254      return Func(Result, *Arg);
 
  274  return RelativeSelector<CompoundStmt, getStatementsRange>(std::move(ID));
 
 
  291  for (
int i = CE.
getNumArgs() - 1; i >= 0; --i) {
 
  305      findArgStartDelimiter(CE, RLoc, *Result.SourceManager,
 
  306                            Result.Context->getLangOpts())
 
  307          .getLocWithOffset(1),
 
  318                                   Result.Context->getLangOpts()),
 
  325        findLastArgEnd(CE, *Result.SourceManager,
 
  326                       Result.Context->getLangOpts()));
 
  335  return RelativeSelector<CallExpr, getCallArgumentsRange>(std::move(ID));
 
 
  339  return RelativeSelector<CXXConstructExpr, getConstructArgumentsRange>(
 
 
  354  return RelativeSelector<InitListExpr, getElementsRange>(std::move(ID));
 
 
  362      tok::TokenKind::semi, *
Result.Context);
 
  367  return RelativeSelector<IfStmt, getElseRange>(std::move(ID));
 
 
  374      return SRange.takeError();
 
  375    return Result.SourceManager->getExpansionRange(*SRange);
 
 
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.
SourceRange getParenOrBraceRange() const
Expr * getArg(unsigned Arg)
Return the specified argument.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ base or member initializer.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
SourceLocation getRParenLoc() const
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.
This represents one expression.
IfStmt - This represents an if/then/else.
SourceLocation getElseLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an C or C++ initializer list.
SourceLocation getLBraceLoc() const
SourceLocation getRBraceLoc() const
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.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source 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.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
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.
const IDToNodeMap & getMap() const
Retrieve mapping from binding identifiers to bound nodes.
A class to allow finding matches over the Clang AST.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ Result
The result type of a method or function.
const FunctionProtoType * T
llvm::Expected< QualType > ExpectedType
Contains all information for a given match.