This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Collect references for externally visible main-file symbols
ClosedPublic

Authored by ArcsinX on Jul 24 2020, 4:35 AM.

Details

Summary

Without this patch clangd does not collect references for main-file symbols if there is no public declaration in preamble.
Example:
test1.c

void f1() {}

test2.c

extern void f1();
void f2() {
  f^1();
}

Find all references does not show definition of f1() in the result, but GTD works OK.

Diff Detail

Event Timeline

ArcsinX created this revision.Jul 24 2020, 4:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2020, 4:35 AM
kadircet marked an inline comment as done.Jul 24 2020, 6:00 AM

thanks, this looks good in general, but it would be nice to make sure we are not blowing the index memory and disk usage.

could you grab some numbers for these two before/after this patch?

clang-tools-extra/clangd/index/Serialization.cpp
422 ↗(On Diff #280405)

this isn't really necessary as we are not changing the serialization format. you would need to delete the existing clangd caches from your machine instead.

clang-tools-extra/clangd/index/SymbolCollector.cpp
317–318

this will result in calculation and caching of linkage. it should be OK to do so though, as we run indexing after parsing finishes. (no action needed, just some notes for future travellers).

ArcsinX updated this revision to Diff 280713.Jul 26 2020, 3:41 AM

Remove version bump

thanks, this looks good in general, but it would be nice to make sure we are not blowing the index memory and disk usage.

could you grab some numbers for these two before/after this patch?

Project: LLVM with clang and clang-tools-extra (~3700 records in compile_commands.json)

Before:
Index size on disk: 96461310 bytes
BackgroundIndex: serving version 39 (596622326 bytes)

After:
Index size of disk: 97425346 bytes.
BackgroundIndex: serving version 39 (601094341 bytes)

Diff:
Size on disk: +1%
Memory: +0.7%

this isn't really necessary as we are not changing the serialization format. you would need to delete the existing clangd caches from your machine instead.

Removed version bump.

kadircet accepted this revision.Jul 27 2020, 4:24 AM

thanks! numbers and the patch LGTM.

This revision is now accepted and ready to land.Jul 27 2020, 4:24 AM
This revision was automatically updated to reflect the committed changes.