This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Perform merging for stale symbols in MergeIndex
ClosedPublic

Authored by kadircet on Mar 12 2021, 10:57 AM.

Details

Summary

Clangd drops symbols from static index whenever the dynamic index is
authoritative for the file. This results in regressions when static and
dynamic index contains different set of information, e.g.
IncludeHeaders.

After this patch, we'll choose to merge symbols from static index with
dynamic one rather than just dropping. This implies correctness problems
when the definition/documentation of the symbol is deleted. But seems
like it is worth having in more cases.

We still drop symbols if dynamic index owns the file and didn't report
the symbol, which means symbol is deleted.

Diff Detail

Event Timeline

kadircet created this revision.Mar 12 2021, 10:57 AM
kadircet requested review of this revision.Mar 12 2021, 10:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2021, 4:30 AM
sammccall accepted this revision.Mar 24 2021, 10:00 AM
sammccall added inline comments.
clang-tools-extra/clangd/index/Merge.cpp
67

we could SPAN_ATTACH a counter for this too, e.g. static_dropped

(and possibly hoist ++StaticCount to the top, static_dropped can be a subset)

73

this bool seems complicated enough & duplicated that you could consider pulling out

static bool indexIsAuthoritative(const SymbolIndex::IndexedFiles&, const Symbol &S);

(The IndexedFiles typedef doesn't exist, but it should!)

clang-tools-extra/clangd/unittests/IndexTests.cpp
318

Bah, this is actually incorrect, for the given example, right? We point to a definition that doesn't exist, in a file where the index is up to date.
Can we at least hint why we do this?
("This seems wrong, but is generic behavior we want for e.g. include headers which are always missing from the dynamic index")

This revision is now accepted and ready to land.Mar 24 2021, 10:00 AM
kadircet updated this revision to Diff 333956.Mar 29 2021, 12:03 PM
kadircet marked 3 inline comments as done.
  • Add comments to the unittest to explain why we chose incorrect behaviour.
  • Extract authorization logic to a helper.
  • Count dropped symbols separately in fuzzyfind tracer stats.
This revision was automatically updated to reflect the committed changes.