llvm/clang/unittests/Tooling/RangeSelectorTest.cpp

//===- unittest/Tooling/RangeSelectorTest.cpp -----------------------------===//
//
// 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/ASTMatchers/ASTMatchers.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Tooling/Transformer/Parsing.h"
#include "clang/Tooling/Transformer/SourceCode.h"
#include "llvm/Support/Error.h"
#include "llvm/Testing/Support/Error.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

usingnamespaceclang;
usingnamespacetransformer;
usingnamespaceast_matchers;

namespace {
Expected;
Failed;
HasValue;
StringError;
AllOf;
HasSubstr;

MatchResult;

struct TestMatch {};

template <typename M> TestMatch matchCode(StringRef Code, M Matcher) {}

// Applies \p Selector to \p Match and, on success, returns the selected source.
Expected<StringRef> select(RangeSelector Selector, const TestMatch &Match) {}

// Applies \p Selector to a trivial match with only a single bound node with id
// "bound_node_id".  For use in testing unbound-node errors.
Expected<CharSourceRange> selectFromTrivial(const RangeSelector &Selector) {}

// Matches the message expected for unbound-node failures.
testing::Matcher<StringError> withUnboundNodeMessage() {}

// Applies \p Selector to code containing assorted node types, where the match
// binds each one: a statement ("stmt"), a (non-member) ctor-initializer
// ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
// to test failures caused by applying selectors to nodes of the wrong type.
Expected<CharSourceRange> selectFromAssorted(RangeSelector Selector) {}

// Matches the message expected for type-error failures.
testing::Matcher<StringError> withTypeErrorMessage(const std::string &NodeID) {}

TEST(RangeSelectorTest, UnboundNode) {}

MATCHER_P(EqualsCharSourceRange, Range, "") {}

// FIXME: here and elsewhere: use llvm::Annotations library to explicitly mark
// points and ranges of interest, enabling more readable tests.
TEST(RangeSelectorTest, BeforeOp) {}

TEST(RangeSelectorTest, BeforeOpParsed) {}

TEST(RangeSelectorTest, AfterOp) {}

// Gets the spelling location `Length` characters after the start of AST node
// `Id`.
static SourceLocation getSpellingLocAfter(const MatchResult &Result,
                                          StringRef Id, int Length) {}

// Test with a range that is the entire macro arg, but does not end the
// expansion itself.
TEST(RangeSelectorTest, AfterOpInMacroArg) {}

// Test with a range that is the entire macro arg and ends the expansion itself.
TEST(RangeSelectorTest, AfterOpInMacroArgEndsExpansion) {}

TEST(RangeSelectorTest, AfterOpInPartOfMacroArg) {}

TEST(RangeSelectorTest, BetweenOp) {}

TEST(RangeSelectorTest, BetweenOpParsed) {}

// Node-id specific version.
TEST(RangeSelectorTest, EncloseOpNodes) {}

TEST(RangeSelectorTest, EncloseOpGeneral) {}

TEST(RangeSelectorTest, EncloseOpNodesParsed) {}

TEST(RangeSelectorTest, EncloseOpGeneralParsed) {}

TEST(RangeSelectorTest, NodeOpStatement) {}

TEST(RangeSelectorTest, NodeOpExpression) {}

TEST(RangeSelectorTest, StatementOp) {}

TEST(RangeSelectorTest, StatementOpParsed) {}

TEST(RangeSelectorTest, MemberOp) {}

// Tests that member does not select any qualifiers on the member name.
TEST(RangeSelectorTest, MemberOpQualified) {}

TEST(RangeSelectorTest, MemberOpTemplate) {}

TEST(RangeSelectorTest, MemberOpOperator) {}

TEST(RangeSelectorTest, NameOpNamedDecl) {}

TEST(RangeSelectorTest, NameOpDeclRef) {}

TEST(RangeSelectorTest, NameOpCtorInitializer) {}

TEST(RangeSelectorTest, NameOpTypeLoc) {}

TEST(RangeSelectorTest, NameOpTemplateSpecializationTypeLoc) {}

TEST(RangeSelectorTest, NameOpErrors) {}

TEST(RangeSelectorTest, NameOpDeclRefError) {}

TEST(RangeSelectorTest, CallArgsOp) {}

TEST(RangeSelectorTest, CallArgsOpNoArgs) {}

TEST(RangeSelectorTest, CallArgsOpNoArgsWithComments) {}

// Tests that arguments are extracted correctly when a temporary (with parens)
// is used.
TEST(RangeSelectorTest, CallArgsOpWithParens) {}

TEST(RangeSelectorTest, CallArgsOpLeadingComments) {}

TEST(RangeSelectorTest, CallArgsOpTrailingComments) {}

TEST(RangeSelectorTest, CallArgsOpEolComments) {}

TEST(RangeSelectorTest, CallArgsErrors) {}

TEST(RangeSelectorTest, ConstructExprArgs) {}

TEST(RangeSelectorTest, ConstructExprBracedArgs) {}

TEST(RangeSelectorTest, ConstructExprNoArgs) {}

TEST(RangeSelectorTest, StatementsOp) {}

TEST(RangeSelectorTest, StatementsOpEmptyList) {}

TEST(RangeSelectorTest, StatementsOpErrors) {}

TEST(RangeSelectorTest, ElementsOp) {}

TEST(RangeSelectorTest, ElementsOpEmptyList) {}

TEST(RangeSelectorTest, ElementsOpErrors) {}

TEST(RangeSelectorTest, ElseBranchOpSingleStatement) {}

TEST(RangeSelectorTest, ElseBranchOpCompoundStatement) {}

// Tests case where the matched node is the complete expanded text.
TEST(RangeSelectorTest, ExpansionOp) {}

// Tests case where the matched node is (only) part of the expanded text.
TEST(RangeSelectorTest, ExpansionOpPartial) {}

TEST(RangeSelectorTest, IfBoundOpBound) {}

TEST(RangeSelectorTest, IfBoundOpUnbound) {}

} // namespace