Skip to content

Commit 40177ac

Browse files
committed
[clangd] Bump index version and get rid of wrong assertion
Summary: After rL360344, BackgroundIndex expects symbols with zero refcounts. Therefore existing index files are no longer valid. Assertion regarding finding target of a reference was wrong, since background-index might still be going on or we might've loaded only some part of the shards and might be missing the declaring shards for the symbol. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61734 llvm-svn: 360349
1 parent 0268083 commit 40177ac

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang-tools-extra/clangd/index/FileIndex.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle) {
138138
for (const RefSlab *Refs : MainFileRefs)
139139
for (const auto &Sym : *Refs) {
140140
auto It = Merged.find(Sym.first);
141-
assert(It != Merged.end() && "Reference to unknown symbol");
141+
// This might happen while background-index is still running.
142+
if (It == Merged.end())
143+
continue;
142144
It->getSecond().References += Sym.second.size();
143145
}
144146
SymsStorage.reserve(Merged.size());

clang-tools-extra/clangd/index/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ readRefs(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings) {
370370
// The current versioning scheme is simple - non-current versions are rejected.
371371
// If you make a breaking change, bump this version number to invalidate stored
372372
// data. Later we may want to support some backward compatibility.
373-
constexpr static uint32_t Version = 9;
373+
constexpr static uint32_t Version = 10;
374374

375375
llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
376376
auto RIFF = riff::readFile(Data);

0 commit comments

Comments
 (0)