This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Collect main file refs by default
ClosedPublic

Authored by nridge on Nov 23 2020, 6:00 PM.

Details

Summary

This is needed for call hierarchy to be able to find callers of
main-file-only functions.

Diff Detail

Event Timeline

nridge created this revision.Nov 23 2020, 6:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2020, 6:00 PM
nridge requested review of this revision.Nov 23 2020, 6:00 PM

i remember discussing this in the past, and having "negative" feelings about it. I couldn't find the discussion on the issues page tho, could you toss me the link if you can find it? (it might've been an offline discussion as well, sorry if that's the case for not dumping a summary).

But if there were no discussions before, it would be nice to see some numbers, for increase in memory and disk usage for LLVM.

Note, the call hierarchy feature is pretty significantly impaired without this. See the example of Selection::createEach() discussed in this comment.

kadircet accepted this revision.Nov 25 2020, 3:59 AM

Thanks, LGTM.

clang-tools-extra/clangd/tool/ClangdMain.cpp
497

can we just change the default in ClangdServer::Options and also use that one in here (i.e. ClangdServer::Options().CollectMainFileRefs)? without plumbing the change to symbolcollector and fileindex ?

This revision is now accepted and ready to land.Nov 25 2020, 3:59 AM

One thing that just occurred to me: does this need an index version bump?

nope, as it doesn't change the serialization format. but any existing shards won't have refs from the main file, they'll accumulate over time as sources gets modified. (i don't think it is worth bumping the version to invalidate existing shards, if a user cares enough they can manually delete their cache)

nridge updated this revision to Diff 307730.Nov 25 2020, 5:32 PM

Address review comment

This revision was landed with ongoing or failed builds.Nov 25 2020, 5:34 PM
This revision was automatically updated to reflect the committed changes.