This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Merge results from static/dynamic index.
ClosedPublic

Authored by sammccall on Jan 14 2018, 11:43 PM.

Details

Summary

We now hide the static/dynamic split from the code completion, behind a
new implementation of the SymbolIndex interface. This will reduce the
complexity of the sema/index merging that needs to be done by
CodeComplete, at a fairly small cost in flexibility.

Event Timeline

sammccall created this revision.Jan 14 2018, 11:43 PM
hokein added inline comments.Jan 15 2018, 1:21 AM
clangd/index/Merge.cpp
30

Maybe add another FIXME, saying filer out symbols in static index, but are removed in dynamic index?

35

IIUC, Dyn is a local variable, which holds all the underlying data of Symbol, the Symbol returned in the callback of fuzzyFind would be invalid after the fuzzyFind(..) function call is finished.

Our previous assumption is that Symbol is valid as long as the SymbolIndex exists?

76

Don't we need CompletionDetail?

sammccall updated this revision to Diff 129824.Jan 15 2018, 3:02 AM
sammccall marked 2 inline comments as done.

Fixed bug where we wrote into the underlying index's symbols.
Extended testcase.
Added documentation around contracts.

sammccall added inline comments.Jan 15 2018, 3:18 AM
clangd/index/Merge.cpp
30

Done (function-level comment, because it's not a localized fix)

35

Our previous assumption is that Symbol is valid as long as the SymbolIndex exists?

No, it's only valid for the callback. Valid for the life of the index would make life hard for remote indexes.
Added documentation to SymbolIndex.

76

Sure. I was assuming it wasn't optional (should be present and match if USR matches), but i'm not 100% sure.

76

This was a bug. It'd be caught by marking Symbol::Detail const. Added a TODO.

hokein accepted this revision.Jan 15 2018, 4:26 AM

looks good.

clangd/index/Merge.cpp
35

I see, that makes sense.

This revision is now accepted and ready to land.Jan 15 2018, 4:26 AM
This revision was automatically updated to reflect the committed changes.