[clangd] Drop dangling relations while sharding

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78359
This commit is contained in:
Kadir Cetinkaya 2020-04-17 13:19:52 +02:00
parent c82faea9fb
commit 4503cf5f23
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 5 additions and 3 deletions

View File

@ -174,9 +174,9 @@ FileShardedIndex::FileShardedIndex(IndexFileIn Input, PathRef HintPath)
// not have been indexed, see SymbolCollector::processRelations for details.
if (Index.Relations) {
for (const auto &R : *Index.Relations) {
auto *File = SymbolIDToFile.lookup(R.Subject);
assert(File && "unknown subject in relation");
File->Relations.insert(&R);
// FIXME: RelationSlab shouldn't contain dangling relations.
if (auto *File = SymbolIDToFile.lookup(R.Subject))
File->Relations.insert(&R);
}
}
// Store only the direct includes of a file in a shard.

View File

@ -540,6 +540,8 @@ TEST(FileShardedIndexTest, Sharding) {
B.insert(Relation{Sym1.ID, RelationKind::BaseOf, Sym2.ID});
// Should be stored in b.h
B.insert(Relation{Sym2.ID, RelationKind::BaseOf, Sym1.ID});
// Dangling relation should be dropped.
B.insert(Relation{symbol("3").ID, RelationKind::BaseOf, Sym1.ID});
IF.Relations = std::move(B).build();
}