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

//===-- SerializationTests.cpp - Binary and YAML serialization unit tests -===//
//
// 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 "Headers.h"
#include "RIFF.h"
#include "index/Serialization.h"
#include "support/Logger.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/Support/Compression.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ScopedPrinter.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#ifdef LLVM_ON_UNIX
#include <sys/resource.h>
#endif

ElementsAre;
Pair;
UnorderedElementsAre;
UnorderedElementsAreArray;

namespace clang {
namespace clangd {
namespace {

const char *YAML =;

MATCHER_P(id, I, "") {}
MATCHER_P(qName, Name, "") {}
MATCHER_P3(IncludeHeaderWithRefAndDirectives, IncludeHeader, References,
           SupportedDirectives, "") {}

auto readIndexFile(llvm::StringRef Text) {}

TEST(SerializationTest, NoCrashOnEmptyYAML) {}

TEST(SerializationTest, YAMLConversions) {}

std::vector<std::string> yamlFromSymbols(const SymbolSlab &Slab) {}
std::vector<std::string> yamlFromRefs(const RefSlab &Slab) {}

std::vector<std::string> yamlFromRelations(const RelationSlab &Slab) {}

TEST(SerializationTest, BinaryConversions) {}

TEST(SerializationTest, SrcsTest) {}

TEST(SerializationTest, CmdlTest) {}

// rlimit is part of POSIX. RLIMIT_AS does not exist in OpenBSD.
// Sanitizers use a lot of address space, so we can't apply strict limits.
#if LLVM_ON_UNIX && defined(RLIMIT_AS) && !LLVM_ADDRESS_SANITIZER_BUILD &&     \
    !LLVM_MEMORY_SANITIZER_BUILD && !LLVM_THREAD_SANITIZER_BUILD
class ScopedMemoryLimit {};
#else
class ScopedMemoryLimit {
public:
  ScopedMemoryLimit(unsigned Bytes) { log("rlimit unsupported"); }
};
#endif

// Test that our deserialization detects invalid array sizes without allocating.
// If this detection fails, the test should allocate a huge array and crash.
TEST(SerializationTest, NoCrashOnBadArraySize) {}

// Check we detect invalid string table size size without allocating it first.
// If this detection fails, the test should allocate a huge array and crash.
TEST(SerializationTest, NoCrashOnBadStringTableSize) {}

} // namespace
} // namespace clangd
} // namespace clang