This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Collect refs from headers.
ClosedPublic

Authored by hokein on Oct 16 2018, 6:33 AM.

Details

Summary

Add a flag to SymbolCollector to collect refs fdrom headers.

Note that we collect refs from headers in static index, and we don't do it for
dynamic index because of the preamble (we skip function body in preamble,
collecting it will result incomplete results).

Diff Detail

Event Timeline

hokein created this revision.Oct 16 2018, 6:33 AM
hokein added a comment.EditedOct 16 2018, 6:36 AM

For references, the binary-format index file (for whole llvm project) size:

BeforeWithRef
size50MB91MB
memory255MB412MB

There are 300,000 symbols.

This looks reasonable. +80% to index size is a shame, but not disastrous, and we have ways to shave it.

Can you check:

  • how much we're increasing the in-memory size (Dex)
  • that we're not outputting duplicate refs when preambles overlap between TUs
clangd/index/IndexAction.h
24

just "all references are collected"?

clangd/index/SymbolCollector.cpp
498

maybe pull out

auto GetURI = [&](clang::FileID FID) -> Optional<StringRef> {
  ... look up or populate cache entry ...
}

then both the outer if and inner lookups can be written as:
if (auto MainFileURI = GetURI(SM.getMainFileID())) {
etc

506

I think you probably also want to cache this case - using an empty string is fine

clangd/index/SymbolCollector.h
62

available -> meaningful

63

having "true" mean don't do something is a bit confusing.

What about bool RefsInHeaders = false?

sammccall accepted this revision.Oct 16 2018, 8:38 AM

(please do check there are no duplicates in the output)

This revision is now accepted and ready to land.Oct 16 2018, 8:38 AM
hokein updated this revision to Diff 169963.Oct 17 2018, 1:25 AM
hokein marked 5 inline comments as done.

Address review comments.

(please do check there are no duplicates in the output)

We do deduplication when building the RefSlab. And double-checked with the output, no duplications there.

hokein updated this revision to Diff 169967.Oct 17 2018, 1:39 AM

minor cleanup.

This revision was automatically updated to reflect the committed changes.