[clang-tools-extra] r360349 - [clangd] Bump index version and get rid of wrong assertion
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Thu May 9 08:07:53 PDT 2019
Author: kadircet
Date: Thu May 9 08:07:53 2019
New Revision: 360349
URL: http://llvm.org/viewvc/llvm-project?rev=360349&view=rev
Log:
[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
Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/Serialization.cpp
Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=360349&r1=360348&r2=360349&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Thu May 9 08:07:53 2019
@@ -138,7 +138,9 @@ FileSymbols::buildIndex(IndexType Type,
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());
Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=360349&r1=360348&r2=360349&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Thu May 9 08:07:53 2019
@@ -370,7 +370,7 @@ readRefs(Reader &Data, llvm::ArrayRef<ll
// 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);
More information about the cfe-commits
mailing list