llvm/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

//===-- SymbolCollectorTests.cpp  -------------------------------*- 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 "Annotations.h"
#include "TestFS.h"
#include "TestTU.h"
#include "URI.h"
#include "clang-include-cleaner/Record.h"
#include "index/SymbolCollector.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Index/IndexingAction.h"
#include "clang/Index/IndexingOptions.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>

namespace clang {
namespace clangd {
namespace {

_;
AllOf;
Contains;
Each;
ElementsAre;
Field;
IsEmpty;
Not;
Pair;
UnorderedElementsAre;
UnorderedElementsAreArray;

// GMock helpers for matching Symbol.
MATCHER_P(labeled, Label, "") {}
MATCHER_P(returnType, D, "") {}
MATCHER_P(doc, D, "") {}
MATCHER_P(snippet, S, "") {}
MATCHER_P(qName, Name, "") {}
MATCHER_P(hasName, Name, "") {}
MATCHER_P(templateArgs, TemplArgs, "") {}
MATCHER_P(hasKind, Kind, "") {}
MATCHER_P(declURI, P, "") {}
MATCHER_P(defURI, P, "") {}
MATCHER(includeHeader, "") {}
MATCHER_P(includeHeader, P, "") {}
MATCHER_P2(IncludeHeaderWithRef, includeHeader, References, "") {}
bool rangesMatch(const SymbolLocation &Loc, const Range &R) {}
MATCHER_P(declRange, Pos, "") {}
MATCHER_P(defRange, Pos, "") {}
MATCHER_P(refCount, R, "") {}
MATCHER_P(forCodeCompletion, IsIndexedForCodeCompletion, "") {}
MATCHER(deprecated, "") {}
MATCHER(implementationDetail, "") {}
MATCHER(visibleOutsideFile, "") {}
MATCHER(refRange, "") {}
MATCHER_P2(OverriddenBy, Subject, Object, "") {}
MATCHER(isSpelled, "") {}
::testing::Matcher<const std::vector<Ref> &>
haveRanges(const std::vector<Range> Ranges) {}

class ShouldCollectSymbolTest : public ::testing::Test {};

TEST_F(ShouldCollectSymbolTest, ShouldCollectSymbol) {}

TEST_F(ShouldCollectSymbolTest, CollectLocalClassesAndVirtualMethods) {}

TEST_F(ShouldCollectSymbolTest, NoPrivateProtoSymbol) {}

TEST_F(ShouldCollectSymbolTest, DoubleCheckProtoHeaderComment) {}

class SymbolIndexActionFactory : public tooling::FrontendActionFactory {};

class SymbolCollectorTest : public ::testing::Test {};

TEST_F(SymbolCollectorTest, CollectSymbols) {}

TEST_F(SymbolCollectorTest, FileLocal) {}

TEST_F(SymbolCollectorTest, Template) {}

TEST_F(SymbolCollectorTest, templateArgs) {}

TEST_F(SymbolCollectorTest, ObjCRefs) {}

TEST_F(SymbolCollectorTest, ObjCSymbols) {}

TEST_F(SymbolCollectorTest, ObjCPropertyImpl) {}

TEST_F(SymbolCollectorTest, ObjCLocations) {}

TEST_F(SymbolCollectorTest, ObjCForwardDecls) {}

TEST_F(SymbolCollectorTest, ObjCClassExtensions) {}

TEST_F(SymbolCollectorTest, ObjCFrameworkIncludeHeader) {}

TEST_F(SymbolCollectorTest, Locations) {}

TEST_F(SymbolCollectorTest, Refs) {}

TEST_F(SymbolCollectorTest, RefContainers) {}

TEST_F(SymbolCollectorTest, MacroRefInHeader) {}

TEST_F(SymbolCollectorTest, MacroRefWithoutCollectingSymbol) {}

TEST_F(SymbolCollectorTest, MacrosWithRefFilter) {}

TEST_F(SymbolCollectorTest, SpelledReferences) {}

TEST_F(SymbolCollectorTest, NameReferences) {}

TEST_F(SymbolCollectorTest, RefsOnMacros) {}

TEST_F(SymbolCollectorTest, HeaderAsMainFile) {}

TEST_F(SymbolCollectorTest, RefsInHeaders) {}

TEST_F(SymbolCollectorTest, BaseOfRelations) {}

TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {}

TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {}

TEST_F(SymbolCollectorTest, CountReferences) {}

TEST_F(SymbolCollectorTest, SymbolRelativeNoFallback) {}

TEST_F(SymbolCollectorTest, SymbolRelativeWithFallback) {}

TEST_F(SymbolCollectorTest, UnittestURIScheme) {}

TEST_F(SymbolCollectorTest, IncludeEnums) {}

TEST_F(SymbolCollectorTest, NamelessSymbols) {}

TEST_F(SymbolCollectorTest, SymbolFormedFromRegisteredSchemeFromMacro) {}

TEST_F(SymbolCollectorTest, SymbolFormedByCLI) {}

TEST_F(SymbolCollectorTest, SymbolsInMainFile) {}

TEST_F(SymbolCollectorTest, Documentation) {}

TEST_F(SymbolCollectorTest, DocumentationInMain) {}

TEST_F(SymbolCollectorTest, DocumentationAtDeclThenDef) {}

TEST_F(SymbolCollectorTest, DocumentationAtDefThenDecl) {}

TEST_F(SymbolCollectorTest, ClassMembers) {}

TEST_F(SymbolCollectorTest, Scopes) {}

TEST_F(SymbolCollectorTest, ExternC) {}

TEST_F(SymbolCollectorTest, SkipInlineNamespace) {}

TEST_F(SymbolCollectorTest, SymbolWithDocumentation) {}

TEST_F(SymbolCollectorTest, snippet) {}

TEST_F(SymbolCollectorTest, IncludeHeaderSameAsFileURI) {}

TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {}

TEST_F(SymbolCollectorTest, IWYUPragma) {}

TEST_F(SymbolCollectorTest, IWYUPragmaWithDoubleQuotes) {}

TEST_F(SymbolCollectorTest, IWYUPragmaExport) {}

TEST_F(SymbolCollectorTest, MainFileIsHeaderWhenSkipIncFile) {}

TEST_F(SymbolCollectorTest, IncFileInNonHeader) {}

// Features that depend on header-guards are fragile. Header guards are only
// recognized when the file ends, so we have to defer checking for them.
TEST_F(SymbolCollectorTest, HeaderGuardDetected) {}

TEST_F(SymbolCollectorTest, NonModularHeader) {}

TEST_F(SymbolCollectorTest, AvoidUsingFwdDeclsAsCanonicalDecls) {}

TEST_F(SymbolCollectorTest, ClassForwardDeclarationIsCanonical) {}

TEST_F(SymbolCollectorTest, UTF16Character) {}

TEST_F(SymbolCollectorTest, DoNotIndexSymbolsInFriendDecl) {}

TEST_F(SymbolCollectorTest, ReferencesInFriendDecl) {}

TEST_F(SymbolCollectorTest, Origin) {}

TEST_F(SymbolCollectorTest, CollectMacros) {}

TEST_F(SymbolCollectorTest, DeprecatedSymbols) {}

TEST_F(SymbolCollectorTest, implementationDetail) {}

TEST_F(SymbolCollectorTest, UsingDecl) {}

TEST_F(SymbolCollectorTest, CBuiltins) {}

TEST_F(SymbolCollectorTest, InvalidSourceLoc) {}

TEST_F(SymbolCollectorTest, BadUTF8) {}

TEST_F(SymbolCollectorTest, MacrosInHeaders) {}

// Regression test for a crash-bug we used to have.
TEST_F(SymbolCollectorTest, UndefOfModuleMacro) {}

TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {}

TEST_F(SymbolCollectorTest, Reserved) {}

TEST_F(SymbolCollectorTest, Concepts) {}

TEST_F(SymbolCollectorTest, IncludeHeaderForwardDecls) {}
} // namespace
} // namespace clangd
} // namespace clang