llvm/clang/lib/Tooling/Transformer/RangeSelector.cpp

//===--- RangeSelector.cpp - RangeSelector implementations ------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "clang/Tooling/Transformer/RangeSelector.h"
#include "clang/AST/Expr.h"
#include "clang/AST/TypeLoc.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Lex/Lexer.h"
#include "clang/Tooling/Transformer/SourceCode.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include <string>
#include <utility>
#include <vector>

usingnamespaceclang;
usingnamespacetransformer;

MatchFinder;
Error;
StringError;

MatchResult;

static Error invalidArgumentError(Twine Message) {}

static Error typeError(StringRef ID, const ASTNodeKind &Kind) {}

static Error typeError(StringRef ID, const ASTNodeKind &Kind,
                       Twine ExpectedType) {}

static Error missingPropertyError(StringRef ID, Twine Description,
                                  StringRef Property) {}

static Expected<DynTypedNode> getNode(const ast_matchers::BoundNodes &Nodes,
                                      StringRef ID) {}

// FIXME: handling of macros should be configurable.
static SourceLocation findPreviousTokenStart(SourceLocation Start,
                                             const SourceManager &SM,
                                             const LangOptions &LangOpts) {}

// Finds the start location of the previous token of kind \p TK.
// FIXME: handling of macros should be configurable.
static SourceLocation findPreviousTokenKind(SourceLocation Start,
                                            const SourceManager &SM,
                                            const LangOptions &LangOpts,
                                            tok::TokenKind TK) {}

RangeSelector transformer::before(RangeSelector Selector) {}

RangeSelector transformer::after(RangeSelector Selector) {}

RangeSelector transformer::node(std::string ID) {}

RangeSelector transformer::statement(std::string ID) {}

RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {}

RangeSelector transformer::encloseNodes(std::string BeginID,
                                        std::string EndID) {}

RangeSelector transformer::member(std::string ID) {}

RangeSelector transformer::name(std::string ID) {}

namespace {
// FIXME: make this available in the public API for users to easily create their
// own selectors.

// Creates a selector from a range-selection function \p Func, which selects a
// range that is relative to a bound node id.  \c T is the node type expected by
// \p Func.
template <typename T, CharSourceRange (*Func)(const MatchResult &, const T &)>
class RelativeSelector {};
} // namespace

// FIXME: Change the following functions from being in an anonymous namespace
// to static functions, after the minimum Visual C++ has _MSC_VER >= 1915
// (equivalent to Visual Studio 2017 v15.8 or higher). Using the anonymous
// namespace works around a bug in earlier versions.
namespace {
// Returns the range of the statements (all source between the braces).
CharSourceRange getStatementsRange(const MatchResult &,
                                   const CompoundStmt &CS) {}
} // namespace

RangeSelector transformer::statements(std::string ID) {}

namespace {

SourceLocation getRLoc(const CallExpr &E) {}

SourceLocation getRLoc(const CXXConstructExpr &E) {}

tok::TokenKind getStartToken(const CallExpr &E) {}

tok::TokenKind getStartToken(const CXXConstructExpr &E) {}

template <typename ExprWithArgs>
SourceLocation findArgStartDelimiter(const ExprWithArgs &E, SourceLocation RLoc,
                                     const SourceManager &SM,
                                     const LangOptions &LangOpts) {}
// Returns the range of the source between the call's or construct expr's
// parentheses/braces.
template <typename ExprWithArgs>
CharSourceRange getArgumentsRange(const MatchResult &Result,
                                  const ExprWithArgs &CE) {}
} // namespace

RangeSelector transformer::callArgs(std::string ID) {}

RangeSelector transformer::constructExprArgs(std::string ID) {}

namespace {
// Returns the range of the elements of the initializer list. Includes all
// source between the braces.
CharSourceRange getElementsRange(const MatchResult &,
                                 const InitListExpr &E) {}
} // namespace

RangeSelector transformer::initListElements(std::string ID) {}

namespace {
// Returns the range of the else branch, including the `else` keyword.
CharSourceRange getElseRange(const MatchResult &Result, const IfStmt &S) {}
} // namespace

RangeSelector transformer::elseBranch(std::string ID) {}

RangeSelector transformer::expansion(RangeSelector S) {}