[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
This commit is contained in:
Kadir Cetinkaya 2019-05-09 15:07:53 +00:00
parent 0268083329
commit 40177ac6d1
2 changed files with 4 additions and 2 deletions

View File

@ -138,7 +138,9 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle) {
for (const RefSlab *Refs : MainFileRefs)
for (const auto &Sym : *Refs) {
auto It = Merged.find(Sym.first);
assert(It != Merged.end() && "Reference to unknown symbol");
// This might happen while background-index is still running.
if (It == Merged.end())
continue;
It->getSecond().References += Sym.second.size();
}
SymsStorage.reserve(Merged.size());

View File

@ -370,7 +370,7 @@ readRefs(Reader &Data, 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 = 9;
constexpr static uint32_t Version = 10;
llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data) {
auto RIFF = riff::readFile(Data);