summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-05-09 15:07:53 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-05-09 15:07:53 +0000
commit40177ac6d1d567f8c001bc6b4bfbad4ea56c36e6 (patch)
treeeea07e0d9acd8318968d9b8e932c488f6571779a
parent0268083329c3a27d330b8520087320c17e65e007 (diff)
downloadbcm5719-llvm-40177ac6d1d567f8c001bc6b4bfbad4ea56c36e6.tar.gz
bcm5719-llvm-40177ac6d1d567f8c001bc6b4bfbad4ea56c36e6.zip
[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
-rw-r--r--clang-tools-extra/clangd/index/FileIndex.cpp4
-rw-r--r--clang-tools-extra/clangd/index/Serialization.cpp2
2 files changed, 4 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/index/FileIndex.cpp b/clang-tools-extra/clangd/index/FileIndex.cpp
index 22c6e860fb8..49746ae926b 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -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());
diff --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index 62eb3fcdf37..12993eb631c 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -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);
OpenPOWER on IntegriCloud