[clang-tools-extra] 9c9119a - [clangd] Extend SymbolOrigin, stop serializing it
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 12 23:28:56 PST 2022
Author: Sam McCall
Date: 2022-01-13T08:26:12+01:00
New Revision: 9c9119ab364b0179af4a96a764f806d51878b37f
URL: https://github.com/llvm/llvm-project/commit/9c9119ab364b0179af4a96a764f806d51878b37f
DIFF: https://github.com/llvm/llvm-project/commit/9c9119ab364b0179af4a96a764f806d51878b37f.diff
LOG: [clangd] Extend SymbolOrigin, stop serializing it
New values:
- Split Dynamic into Open/Preamble
- Add Background (previously was just Unknown)
- Soon: stdlib index
This requires extending to 16 bits, which fits within the padding of Symbol.
Unfortunately we're also *serializing* SymbolOrigin as a fixed 8 bits.
Stop serializing SymbolOrigin:
- conceptually, the source is whoever indexes or *deserializes* a symbol
- deserialization takes SymbolOrigin as a parameter and stamps it on each sym
- this is a breaking format change
Differential Revision: https://reviews.llvm.org/D115243
Added:
Modified:
clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/Serialization.h
clang-tools-extra/clangd/index/SymbolOrigin.cpp
clang-tools-extra/clangd/index/SymbolOrigin.h
clang-tools-extra/clangd/index/YAMLSerialization.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/index/remote/Index.proto
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/IndexTests.cpp
clang-tools-extra/clangd/unittests/SerializationTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
index ed1662ff5988..26934daf00a7 100644
--- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -58,7 +58,8 @@ class DiskBackedIndexStorage : public BackgroundIndexStorage {
auto Buffer = llvm::MemoryBuffer::getFile(ShardPath);
if (!Buffer)
return nullptr;
- if (auto I = readIndexFile(Buffer->get()->getBuffer()))
+ if (auto I =
+ readIndexFile(Buffer->get()->getBuffer(), SymbolOrigin::Background))
return std::make_unique<IndexFileIn>(std::move(*I));
else
elog("Error while reading shard {0}: {1}", ShardIdentifier,
diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp
index fa58c6ff6fb1..5f460d8af887 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -27,14 +27,12 @@
#include "clang/AST/ASTContext.h"
#include "clang/Index/IndexingAction.h"
#include "clang/Index/IndexingOptions.h"
-#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
#include <algorithm>
#include <memory>
#include <tuple>
@@ -54,7 +52,8 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
CollectorOpts.CollectIncludePath = true;
CollectorOpts.Includes = &Includes;
CollectorOpts.CountReferences = false;
- CollectorOpts.Origin = SymbolOrigin::Dynamic;
+ CollectorOpts.Origin =
+ IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble;
CollectorOpts.CollectMainFileRefs = CollectMainFileRefs;
// We want stdlib implementation details in the index only if we've opened the
// file in question. This does means xrefs won't work, though.
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index f488220ff92f..8c4b97f6ad28 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -320,7 +320,6 @@ void writeSymbol(const Symbol &Sym, const StringTableOut &Strings,
writeLocation(Sym.CanonicalDeclaration, Strings, OS);
writeVar(Sym.References, OS);
OS.write(static_cast<uint8_t>(Sym.Flags));
- OS.write(static_cast<uint8_t>(Sym.Origin));
writeVar(Strings.index(Sym.Signature), OS);
writeVar(Strings.index(Sym.CompletionSnippetSuffix), OS);
writeVar(Strings.index(Sym.Documentation), OS);
@@ -336,7 +335,8 @@ void writeSymbol(const Symbol &Sym, const StringTableOut &Strings,
WriteInclude(Include);
}
-Symbol readSymbol(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings) {
+Symbol readSymbol(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings,
+ SymbolOrigin Origin) {
Symbol Sym;
Sym.ID = Data.consumeID();
Sym.SymInfo.Kind = static_cast<index::SymbolKind>(Data.consume8());
@@ -348,7 +348,7 @@ Symbol readSymbol(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings) {
Sym.CanonicalDeclaration = readLocation(Data, Strings);
Sym.References = Data.consumeVar();
Sym.Flags = static_cast<Symbol::SymbolFlag>(Data.consume8());
- Sym.Origin = static_cast<SymbolOrigin>(Data.consume8());
+ Sym.Origin = Origin;
Sym.Signature = Data.consumeString(Strings);
Sym.CompletionSnippetSuffix = Data.consumeString(Strings);
Sym.Documentation = Data.consumeString(Strings);
@@ -452,9 +452,10 @@ readCompileCommand(Reader CmdReader, llvm::ArrayRef<llvm::StringRef> Strings) {
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 16;
+constexpr static uint32_t Version = 17;
-llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
+llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data,
+ SymbolOrigin Origin) {
auto RIFF = riff::readFile(Data);
if (!RIFF)
return RIFF.takeError();
@@ -503,7 +504,7 @@ llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
Reader SymbolReader(Chunks.lookup("symb"));
SymbolSlab::Builder Symbols;
while (!SymbolReader.eof())
- Symbols.insert(readSymbol(SymbolReader, Strings->Strings));
+ Symbols.insert(readSymbol(SymbolReader, Strings->Strings, Origin));
if (SymbolReader.err())
return error("malformed or truncated symbol");
Result.Symbols = std::move(Symbols).build();
@@ -670,7 +671,7 @@ void writeRIFF(const IndexFileOut &Data, llvm::raw_ostream &OS) {
// Defined in YAMLSerialization.cpp.
void writeYAML(const IndexFileOut &, llvm::raw_ostream &);
-llvm::Expected<IndexFileIn> readYAML(llvm::StringRef);
+llvm::Expected<IndexFileIn> readYAML(llvm::StringRef, SymbolOrigin Origin);
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O) {
switch (O.Format) {
@@ -684,11 +685,12 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O) {
return OS;
}
-llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef Data) {
+llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef Data,
+ SymbolOrigin Origin) {
if (Data.startswith("RIFF")) {
- return readRIFF(Data);
+ return readRIFF(Data, Origin);
}
- if (auto YAMLContents = readYAML(Data)) {
+ if (auto YAMLContents = readYAML(Data, Origin)) {
return std::move(*YAMLContents);
} else {
return error("Not a RIFF file and failed to parse as YAML: {0}",
@@ -697,7 +699,7 @@ llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef Data) {
}
std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef SymbolFilename,
- bool UseDex) {
+ SymbolOrigin Origin, bool UseDex) {
trace::Span OverallTracer("LoadIndex");
auto Buffer = llvm::MemoryBuffer::getFile(SymbolFilename);
if (!Buffer) {
@@ -710,7 +712,7 @@ std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef SymbolFilename,
RelationSlab Relations;
{
trace::Span Tracer("ParseIndex");
- if (auto I = readIndexFile(Buffer->get()->getBuffer())) {
+ if (auto I = readIndexFile(Buffer->get()->getBuffer(), Origin)) {
if (I->Symbols)
Symbols = std::move(*I->Symbols);
if (I->Refs)
diff --git a/clang-tools-extra/clangd/index/Serialization.h b/clang-tools-extra/clangd/index/Serialization.h
index 936939e4abc6..40d8bfda361c 100644
--- a/clang-tools-extra/clangd/index/Serialization.h
+++ b/clang-tools-extra/clangd/index/Serialization.h
@@ -49,7 +49,7 @@ struct IndexFileIn {
llvm::Optional<tooling::CompileCommand> Cmd;
};
// Parse an index file. The input must be a RIFF or YAML file.
-llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef);
+llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef, SymbolOrigin);
// Specifies the contents of an index file to be written.
struct IndexFileOut {
@@ -79,16 +79,10 @@ std::string toYAML(const std::pair<SymbolID, ArrayRef<Ref>> &);
std::string toYAML(const Relation &);
std::string toYAML(const Ref &);
-// Deserialize a single symbol from YAML.
-llvm::Expected<clangd::Symbol> symbolFromYAML(StringRef YAML,
- llvm::UniqueStringSaver *Strings);
-llvm::Expected<clangd::Ref> refFromYAML(StringRef YAML,
- llvm::UniqueStringSaver *Strings);
-
// Build an in-memory static index from an index file.
// The size should be relatively small, so data can be managed in memory.
std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef Filename,
- bool UseDex = true);
+ SymbolOrigin Origin, bool UseDex = true);
} // namespace clangd
} // namespace clang
diff --git a/clang-tools-extra/clangd/index/SymbolOrigin.cpp b/clang-tools-extra/clangd/index/SymbolOrigin.cpp
index 79e32137f7b8..46a84f2ca984 100644
--- a/clang-tools-extra/clangd/index/SymbolOrigin.cpp
+++ b/clang-tools-extra/clangd/index/SymbolOrigin.cpp
@@ -14,9 +14,9 @@ namespace clangd {
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SymbolOrigin O) {
if (O == SymbolOrigin::Unknown)
return OS << "unknown";
- constexpr static char Sigils[] = "ADSMIR67";
+ constexpr static char Sigils[] = "AOSMIRP7B9012345";
for (unsigned I = 0; I < sizeof(Sigils); ++I)
- if (static_cast<uint8_t>(O) & 1u << I)
+ if (static_cast<uint16_t>(O) & 1u << I)
OS << Sigils[I];
return OS;
}
diff --git a/clang-tools-extra/clangd/index/SymbolOrigin.h b/clang-tools-extra/clangd/index/SymbolOrigin.h
index 0ed81c6a3e28..18e3616d5a9c 100644
--- a/clang-tools-extra/clangd/index/SymbolOrigin.h
+++ b/clang-tools-extra/clangd/index/SymbolOrigin.h
@@ -18,27 +18,29 @@ namespace clangd {
// Describes the source of information about a symbol.
// Mainly useful for debugging, e.g. understanding code completion results.
// This is a bitfield as information can be combined from several sources.
-enum class SymbolOrigin : uint8_t {
+enum class SymbolOrigin : uint16_t {
Unknown = 0,
AST = 1 << 0, // Directly from the AST (indexes should not set this).
- Dynamic = 1 << 1, // From the dynamic index of opened files.
- Static = 1 << 2, // From the static, externally-built index.
+ Open = 1 << 1, // From the dynamic index of open files.
+ Static = 1 << 2, // From a static, externally-built index.
Merge = 1 << 3, // A non-trivial index merge was performed.
Identifier = 1 << 4, // Raw identifiers in file.
Remote = 1 << 5, // Remote index.
- // Remaining bits reserved for index implementations.
+ Preamble = 1 << 6, // From the dynamic index of preambles.
+ // 7 reserved
+ Background = 1 << 8, // From the automatic project index.
};
inline SymbolOrigin operator|(SymbolOrigin A, SymbolOrigin B) {
- return static_cast<SymbolOrigin>(static_cast<uint8_t>(A) |
- static_cast<uint8_t>(B));
+ return static_cast<SymbolOrigin>(static_cast<uint16_t>(A) |
+ static_cast<uint16_t>(B));
}
inline SymbolOrigin &operator|=(SymbolOrigin &A, SymbolOrigin B) {
return A = A | B;
}
inline SymbolOrigin operator&(SymbolOrigin A, SymbolOrigin B) {
- return static_cast<SymbolOrigin>(static_cast<uint8_t>(A) &
- static_cast<uint8_t>(B));
+ return static_cast<SymbolOrigin>(static_cast<uint16_t>(A) &
+ static_cast<uint16_t>(B));
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &, SymbolOrigin);
diff --git a/clang-tools-extra/clangd/index/YAMLSerialization.cpp b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
index 86293aba1329..84bf5146b411 100644
--- a/clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -69,7 +69,6 @@ using clang::clangd::RelationKind;
using clang::clangd::Symbol;
using clang::clangd::SymbolID;
using clang::clangd::SymbolLocation;
-using clang::clangd::SymbolOrigin;
using clang::index::SymbolInfo;
using clang::index::SymbolKind;
using clang::index::SymbolLanguage;
@@ -108,17 +107,6 @@ struct NormalizedSymbolFlag {
uint8_t Flag = 0;
};
-struct NormalizedSymbolOrigin {
- NormalizedSymbolOrigin(IO &) {}
- NormalizedSymbolOrigin(IO &, SymbolOrigin O) {
- Origin = static_cast<uint8_t>(O);
- }
-
- SymbolOrigin denormalize(IO &) { return static_cast<SymbolOrigin>(Origin); }
-
- uint8_t Origin = 0;
-};
-
template <> struct MappingTraits<YPosition> {
static void mapping(IO &IO, YPosition &Value) {
IO.mapRequired("Line", Value.Line);
@@ -194,8 +182,6 @@ template <> struct MappingTraits<Symbol> {
MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO, Sym.ID);
MappingNormalization<NormalizedSymbolFlag, Symbol::SymbolFlag> NSymbolFlag(
IO, Sym.Flags);
- MappingNormalization<NormalizedSymbolOrigin, SymbolOrigin> NSymbolOrigin(
- IO, Sym.Origin);
IO.mapRequired("ID", NSymbolID->HexString);
IO.mapRequired("Name", Sym.Name);
IO.mapRequired("Scope", Sym.Scope);
@@ -204,7 +190,6 @@ template <> struct MappingTraits<Symbol> {
SymbolLocation());
IO.mapOptional("Definition", Sym.Definition, SymbolLocation());
IO.mapOptional("References", Sym.References, 0u);
- IO.mapOptional("Origin", NSymbolOrigin->Origin);
IO.mapOptional("Flags", NSymbolFlag->Flag);
IO.mapOptional("Signature", Sym.Signature);
IO.mapOptional("TemplateSpecializationArgs",
@@ -436,7 +421,8 @@ void writeYAML(const IndexFileOut &O, llvm::raw_ostream &OS) {
}
}
-llvm::Expected<IndexFileIn> readYAML(llvm::StringRef Data) {
+llvm::Expected<IndexFileIn> readYAML(llvm::StringRef Data,
+ SymbolOrigin Origin) {
SymbolSlab::Builder Symbols;
RefSlab::Builder Refs;
RelationSlab::Builder Relations;
@@ -453,8 +439,10 @@ llvm::Expected<IndexFileIn> readYAML(llvm::StringRef Data) {
if (Yin.error())
return llvm::errorCodeToError(Yin.error());
- if (Variant.Symbol)
+ if (Variant.Symbol) {
+ Variant.Symbol->Origin = Origin;
Symbols.insert(*Variant.Symbol);
+ }
if (Variant.Refs)
for (const auto &Ref : Variant.Refs->second)
Refs.insert(Variant.Refs->first, Ref);
@@ -528,25 +516,5 @@ std::string toYAML(const Ref &R) {
return Buf;
}
-llvm::Expected<clangd::Symbol>
-symbolFromYAML(StringRef YAML, llvm::UniqueStringSaver *Strings) {
- clangd::Symbol Deserialized;
- llvm::yaml::Input YAMLInput(YAML, Strings);
- if (YAMLInput.error())
- return error("Unable to deserialize Symbol from YAML: {0}", YAML);
- YAMLInput >> Deserialized;
- return Deserialized;
-}
-
-llvm::Expected<clangd::Ref> refFromYAML(StringRef YAML,
- llvm::UniqueStringSaver *Strings) {
- clangd::Ref Deserialized;
- llvm::yaml::Input YAMLInput(YAML, Strings);
- if (YAMLInput.error())
- return error("Unable to deserialize Symbol from YAML: {0}", YAML);
- YAMLInput >> Deserialized;
- return Deserialized;
-}
-
} // namespace clangd
} // namespace clang
diff --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 581dae755729..14911daec34c 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -334,7 +334,8 @@ class Export : public Command {
}
// Auto-detects input format when parsing
- auto IndexIn = clang::clangd::readIndexFile(Buffer->get()->getBuffer());
+ auto IndexIn = clang::clangd::readIndexFile(Buffer->get()->getBuffer(),
+ SymbolOrigin::Static);
if (!IndexIn) {
llvm::errs() << llvm::toString(IndexIn.takeError()) << "\n";
return;
@@ -374,7 +375,7 @@ std::unique_ptr<SymbolIndex> openIndex(llvm::StringRef Index) {
return Index.startswith("remote:")
? remote::getClient(Index.drop_front(strlen("remote:")),
ProjectRoot)
- : loadIndex(Index, /*UseDex=*/true);
+ : loadIndex(Index, SymbolOrigin::Static, /*UseDex=*/true);
}
bool runCommand(std::string Request, const SymbolIndex &Index) {
diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto
index 27d17c77192b..aa5bcc0b1797 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -66,7 +66,7 @@ message Symbol {
optional string scope = 5;
optional SymbolLocation canonical_declaration = 6;
optional int32 references = 7;
- optional uint32 origin = 8;
+ reserved 8;
optional string signature = 9;
optional string template_specialization_args = 10;
optional string completion_snippet_suffix = 11;
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index a96a6ef1ea7a..488f5794d353 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -269,7 +269,6 @@ llvm::Expected<Symbol> Marshaller::toProtobuf(const clangd::Symbol &From) {
return Declaration.takeError();
*Result.mutable_canonical_declaration() = *Declaration;
Result.set_references(From.References);
- Result.set_origin(static_cast<uint32_t>(From.Origin));
Result.set_signature(From.Signature.str());
Result.set_template_specialization_args(
From.TemplateSpecializationArgs.str());
diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 396268053225..b5acb5d030b9 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -395,7 +395,8 @@ void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
"{0}, new index was modified at {1}. Attempting to reload.",
LastStatus.getLastModificationTime(), Status->getLastModificationTime());
LastStatus = *Status;
- std::unique_ptr<clang::clangd::SymbolIndex> NewIndex = loadIndex(IndexPath);
+ std::unique_ptr<clang::clangd::SymbolIndex> NewIndex =
+ loadIndex(IndexPath, SymbolOrigin::Static);
if (!NewIndex) {
elog("Failed to load new index. Old index will be served.");
return;
diff --git a/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
index ba462592d2f6..91e9e5f5dbb1 100644
Binary files a/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx and b/clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
diff er
diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index 605114233780..8cd6b2d760aa 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -602,7 +602,7 @@ loadExternalIndex(const Config::ExternalIndexSpec &External,
auto NewIndex = std::make_unique<SwapIndex>(std::make_unique<MemIndex>());
auto IndexLoadTask = [File = External.Location,
PlaceHolder = NewIndex.get()] {
- if (auto Idx = loadIndex(File, /*UseDex=*/true))
+ if (auto Idx = loadIndex(File, SymbolOrigin::Static, /*UseDex=*/true))
PlaceHolder->reset(std::move(Idx));
};
if (Tasks) {
diff --git a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
index 79da2f059a8c..9b60d6209ae3 100644
--- a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -73,7 +73,8 @@ class MemoryShardStorage : public BackgroundIndexStorage {
if (Storage.find(ShardIdentifier) == Storage.end()) {
return nullptr;
}
- auto IndexFile = readIndexFile(Storage[ShardIdentifier]);
+ auto IndexFile =
+ readIndexFile(Storage[ShardIdentifier], SymbolOrigin::Background);
if (!IndexFile) {
ADD_FAILURE() << "Error while reading " << ShardIdentifier << ':'
<< IndexFile.takeError();
diff --git a/clang-tools-extra/clangd/unittests/IndexTests.cpp b/clang-tools-extra/clangd/unittests/IndexTests.cpp
index 18eedcb7498b..0ba157419bf8 100644
--- a/clang-tools-extra/clangd/unittests/IndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/IndexTests.cpp
@@ -392,7 +392,7 @@ TEST(MergeTest, Merge) {
L.Signature = "()"; // present in left only
R.CompletionSnippetSuffix = "{$1:0}"; // present in right only
R.Documentation = "--doc--";
- L.Origin = SymbolOrigin::Dynamic;
+ L.Origin = SymbolOrigin::Preamble;
R.Origin = SymbolOrigin::Static;
R.Type = "expectedType";
@@ -404,8 +404,8 @@ TEST(MergeTest, Merge) {
EXPECT_EQ(M.CompletionSnippetSuffix, "{$1:0}");
EXPECT_EQ(M.Documentation, "--doc--");
EXPECT_EQ(M.Type, "expectedType");
- EXPECT_EQ(M.Origin,
- SymbolOrigin::Dynamic | SymbolOrigin::Static | SymbolOrigin::Merge);
+ EXPECT_EQ(M.Origin, SymbolOrigin::Preamble | SymbolOrigin::Static |
+ SymbolOrigin::Merge);
}
TEST(MergeTest, PreferSymbolWithDefn) {
diff --git a/clang-tools-extra/clangd/unittests/SerializationTests.cpp b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
index 548b02759965..f27775ea2f2d 100644
--- a/clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -49,7 +49,6 @@ Scope: 'clang::'
End:
Line: 1
Column: 1
-Origin: 128
Flags: 129
Documentation: 'Foo doc'
ReturnType: 'int'
@@ -121,6 +120,10 @@ MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") {
return (arg.IncludeHeader == IncludeHeader) && (arg.References == References);
}
+auto readIndexFile(llvm::StringRef Text) {
+ return readIndexFile(Text, SymbolOrigin::Static);
+}
+
TEST(SerializationTest, NoCrashOnEmptyYAML) {
EXPECT_TRUE(bool(readIndexFile("")));
}
@@ -143,7 +146,7 @@ TEST(SerializationTest, YAMLConversions) {
EXPECT_EQ(Sym1.Documentation, "Foo doc");
EXPECT_EQ(Sym1.ReturnType, "int");
EXPECT_EQ(StringRef(Sym1.CanonicalDeclaration.FileURI), "file:///path/foo.h");
- EXPECT_EQ(Sym1.Origin, static_cast<SymbolOrigin>(1 << 7));
+ EXPECT_EQ(Sym1.Origin, SymbolOrigin::Static);
EXPECT_EQ(static_cast<uint8_t>(Sym1.Flags), 129);
EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion);
EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated);
More information about the cfe-commits
mailing list