This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Index Interfaces for Xrefs
ClosedPublic

Authored by hokein on Jul 23 2018, 12:04 AM.

Details

Summary

This is the first step of implementing Xrefs in clangd:

  • add index interfaces, and related data structures.

Diff Detail

Repository
rL LLVM

Event Timeline

hokein created this revision.Jul 23 2018, 12:04 AM

Mostly LG.

I think we can simplify in a couple of places, and you should decide if this patch is *implementing* the new index operation or not. (Currently it implements it for 1/3 implementations, which doesn't seem that useful).

clangd/index/FileIndex.cpp
111 ↗(On Diff #156724)

add a log?

111 ↗(On Diff #156724)

Can we either implement this for FileIndex/MemIndex/MergedIndex, or none of them?
ATM the scope of the patch is unclear. If we don't implement it, then no need to add Slab etc. If we do, then we get 3 callsites to make sure all that stuff actually works well :-)

clangd/index/Index.cpp
138 ↗(On Diff #156724)

this is a bitfield, there are at least 8 legal values.

If you intend each occurrence to have only one type, and only the filter to have multiple values, these should probably be different types.

Do we actually need operator<< in this patch, or is the default (print the number) OK for tests?

clangd/index/Index.h
313 ↗(On Diff #156724)

Hmm, remove the bit about slab? That's only going to be true in a smaller set of cases than with Symbol.
Not owning the data is a good note, but probably belongs on the struct rather than the member.

345 ↗(On Diff #156724)

Again, I'm not sure the builder/slab split is justifiable here. Can we start without it? Cost is ~8 bytes per unique filename, which should be pretty trivial.

429 ↗(On Diff #156724)

nit: Results are returned in arbitrary order.?
(Usually we want to document from the POV of a caller, rather than an implementation)

clangd/index/MemIndex.cpp
97 ↗(On Diff #156724)

cast to bool rather than int32_t?

clangd/index/MemIndex.h
26 ↗(On Diff #156724)

nit: I'm not sure default args make sense here unless we intend for this to be forever an optional feature

29 ↗(On Diff #156724)

occurrences here too

hokein updated this revision to Diff 158507.Aug 1 2018, 5:21 AM
hokein marked 4 inline comments as done.

Scope the patch to interfaces only.

hokein added a comment.Aug 1 2018, 5:29 AM

Mostly LG.

I think we can simplify in a couple of places, and you should decide if this patch is *implementing* the new index operation or not. (Currently it implements it for 1/3 implementations, which doesn't seem that useful).

Implementing all index operations in the patch would be end up with a large patch, I intend to split the patch as small as possible. Let's scope this patch to interface only.

hokein edited the summary of this revision. (Show Details)Aug 1 2018, 5:30 AM
hokein added reviewers: ilya-biryukov, ioeric.

Picking it up since @sammccall is OOO.

Implementing all index operations in the patch would be end up with a large patch, I intend to split the patch as small as possible. Let's scope this patch to interface only.

LG as interface-only patch. just a few nits

clangd/index/Index.h
288 ↗(On Diff #158507)

Any strong reason to keep the values in sync with SymbolRole?
It intention is to have tricky conversions (i.e. apply a bit mask and cast to the other type)?

clangd/index/Merge.cpp
81 ↗(On Diff #158507)

It's not intended to be called, right?
If that's the case let's assert(false) here. Having those statements does not seem too useful.

hokein marked 2 inline comments as done.Aug 6 2018, 3:13 AM
hokein added inline comments.
clangd/index/Index.h
288 ↗(On Diff #158507)

Yeah, this is intended. Our goal here is to align with clang::index library as much as possible rather than diverge too far from it, because we will end up using index-while-build.

clangd/index/Merge.cpp
81 ↗(On Diff #158507)

I'm not sure assert(false) is a good fit here, I think this is just a note reminding us that it is not implemented. Anyway, it is a matter of personal taste here.

hokein updated this revision to Diff 159287.Aug 6 2018, 6:13 AM
hokein marked 2 inline comments as done.

Rebase

This revision was not accepted when it landed; it landed in state Needs Review.Aug 6 2018, 6:15 AM
This revision was automatically updated to reflect the committed changes.