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

//===-- ParsedASTTests.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
//
//===----------------------------------------------------------------------===//
//
// These tests cover clangd's logic to build a TU, which generally uses the APIs
// in ParsedAST and Preamble, via the TestTU helper.
//
//===----------------------------------------------------------------------===//

#include "../../clang-tidy/ClangTidyCheck.h"
#include "AST.h"
#include "Compiler.h"
#include "Config.h"
#include "Diagnostics.h"
#include "Headers.h"
#include "ParsedAST.h"
#include "Preamble.h"
#include "SourceCode.h"
#include "TestFS.h"
#include "TestTU.h"
#include "TidyProvider.h"
#include "support/Context.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Tooling/Syntax/Tokens.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Testing/Annotations/Annotations.h"
#include "llvm/Testing/Support/Error.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <memory>
#include <string_view>
#include <utility>
#include <vector>

namespace clang {
namespace clangd {
namespace {

AllOf;
Contains;
ElementsAre;
ElementsAreArray;
IsEmpty;

MATCHER_P(declNamed, Name, "") {}

MATCHER_P(declKind, Kind, "") {}

// Matches if the Decl has template args equal to ArgName. If the decl is a
// NamedDecl and ArgName is an empty string it also matches.
MATCHER_P(withTemplateArgs, ArgName, "") {}

MATCHER_P(pragmaTrivia, P, "") {}

MATCHER(eqInc, "") {}

TEST(ParsedASTTest, TopLevelDecls) {}

TEST(ParsedASTTest, DoesNotGetIncludedTopDecls) {}

TEST(ParsedASTTest, DoesNotGetImplicitTemplateTopDecls) {}

TEST(ParsedASTTest,
     GetsExplicitInstantiationAndSpecializationTemplateTopDecls) {}

TEST(ParsedASTTest, IgnoresDelayedTemplateParsing) {}

TEST(ParsedASTTest, TokensAfterPreamble) {}

TEST(ParsedASTTest, NoCrashOnTokensWithTidyCheck) {}

TEST(ParsedASTTest, CanBuildInvocationWithUnknownArgs) {}

TEST(ParsedASTTest, CollectsMainFileMacroExpansions) {}

MATCHER_P(withFileName, Inc, "") {}

TEST(ParsedASTTest, PatchesAdditionalIncludes) {}

TEST(ParsedASTTest, PatchesDeletedIncludes) {}

// Returns Code guarded by #ifndef guards
std::string guard(llvm::StringRef Code) {}

std::string once(llvm::StringRef Code) {}

bool mainIsGuarded(const ParsedAST &AST) {}

MATCHER_P(diag, Desc, "") {}

// Check our understanding of whether the main file is header guarded or not.
TEST(ParsedASTTest, HeaderGuards) {}

// Check our handling of files that include themselves.
// Ideally we allow this if the file has header guards.
//
// Note: the semicolons (empty statements) are significant!
// - they force the preamble to end and the body to begin. Directives can have
//   different effects in the preamble vs main file (which we try to hide).
// - if the preamble would otherwise cover the whole file, a trailing semicolon
//   forces their sizes to be different. This is significant because the file
//   size is part of the lookup key for HeaderFileInfo, and we don't want to
//   rely on the preamble's HFI being looked up when parsing the main file.
TEST(ParsedASTTest, HeaderGuardsSelfInclude) {}

// Tests how we handle common idioms for splitting a header-only library
// into interface and implementation files (e.g. *.h vs *.inl).
// These files mutually include each other, and need careful handling of include
// guards (which interact with preambles).
TEST(ParsedASTTest, HeaderGuardsImplIface) {}

TEST(ParsedASTTest, DiscoversPragmaMarks) {}

TEST(ParsedASTTest, GracefulFailureOnAssemblyFile) {}

TEST(ParsedASTTest, PreambleWithDifferentTarget) {}
} // namespace
} // namespace clangd
} // namespace clang