#include "TestVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Tooling/Refactoring/ASTSelection.h"
#include <optional>
usingnamespaceclang;
usingnamespacetooling;
namespace {
struct FileLocation { … };
FileRange;
class SelectionFinderVisitor : public TestVisitor<SelectionFinderVisitor> { … };
void findSelectedASTNodesWithRange(
StringRef Source, FileLocation Location,
std::optional<FileRange> SelectionRange,
llvm::function_ref<void(SourceRange SelectionRange,
std::optional<SelectedASTNode>)>
Consumer,
SelectionFinderVisitor::Language Language =
SelectionFinderVisitor::Lang_CXX11) { … }
void findSelectedASTNodes(
StringRef Source, FileLocation Location,
std::optional<FileRange> SelectionRange,
llvm::function_ref<void(std::optional<SelectedASTNode>)> Consumer,
SelectionFinderVisitor::Language Language =
SelectionFinderVisitor::Lang_CXX11) { … }
void checkNodeImpl(bool IsTypeMatched, const SelectedASTNode &Node,
SourceSelectionKind SelectionKind, unsigned NumChildren) { … }
void checkDeclName(const SelectedASTNode &Node, StringRef Name) { … }
template <typename T>
const SelectedASTNode &
checkNode(const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0,
std::enable_if_t<std::is_base_of_v<Stmt, T>, T> *StmtOverloadChecker =
nullptr) { … }
template <typename T>
const SelectedASTNode &
checkNode(const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0, StringRef Name = "",
std::enable_if_t<std::is_base_of_v<Decl, T>, T> *DeclOverloadChecker =
nullptr) { … }
struct ForAllChildrenOf { … };
ForAllChildrenOf allChildrenOf(const SelectedASTNode &Node) { … }
TEST(ASTSelectionFinder, CursorNoSelection) { … }
TEST(ASTSelectionFinder, CursorAtStartOfFunction) { … }
TEST(ASTSelectionFinder, RangeNoSelection) { … }
TEST(ASTSelectionFinder, EmptyRangeFallbackToCursor) { … }
TEST(ASTSelectionFinder, WholeFunctionSelection) { … }
TEST(ASTSelectionFinder, MultipleFunctionSelection) { … }
TEST(ASTSelectionFinder, MultipleStatementSelection) { … }
TEST(ASTSelectionFinder, SelectionInFunctionInObjCImplementation) { … }
TEST(ASTSelectionFinder, FunctionInObjCImplementationCarefulWithEarlyExit) { … }
TEST(ASTSelectionFinder, AvoidImplicitDeclarations) { … }
TEST(ASTSelectionFinder, CorrectEndForObjectiveCImplementation) { … }
const SelectedASTNode &checkFnBody(const std::optional<SelectedASTNode> &Node,
StringRef Name) { … }
TEST(ASTSelectionFinder, SelectObjectiveCPseudoObjectExprs) { … }
TEST(ASTSelectionFinder, SimpleCodeRangeASTSelection) { … }
TEST(ASTSelectionFinder, OutOfBodyCodeRange) { … }
TEST(ASTSelectionFinder, SelectVarDeclStmt) { … }
TEST(ASTSelectionFinder, SelectEntireDeclStmtRange) { … }
TEST(ASTSelectionFinder, SelectEntireDeclStmtRangeWithMultipleDecls) { … }
TEST(ASTSelectionFinder, SimpleCodeRangeASTSelectionInObjCMethod) { … }
TEST(ASTSelectionFinder, CanonicalizeObjCStringLiteral) { … }
TEST(ASTSelectionFinder, CanonicalizeMemberCalleeToCall) { … }
TEST(ASTSelectionFinder, CanonicalizeFuncCalleeToCall) { … }
}