This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Run code completion on each token coverd by --check-lines
ClosedPublic

Authored by adamcz on Jun 2 2021, 10:48 AM.

Details

Summary

In --check mode we do not run code completion because it is too slow,
especially on larger files. With the introducation of --check-lines we
can narrow down the scope and thus we can afford to do code completion.

We vlog() the top completion result, but that's not really the point.
The most value will come from being able to reproduce crashes that occur
during code completion and require preamble build or index (and thus are
more difficult to reproduce with -code-complete-at).

Diff Detail

Event Timeline

adamcz created this revision.Jun 2 2021, 10:48 AM
adamcz requested review of this revision.Jun 2 2021, 10:48 AM
kadircet accepted this revision.Jun 2 2021, 1:47 PM

Thanks, LGTM.


A little bit thinking out loud, was there a particular reason to introduce --check-line into ClangdMain.cpp rather than Check.cpp?

It feels like we should have --check related flags in Check.cpp instead. That way both the signature of check stays more reasonable and ClangdMain won't accumulate flag to internal value logic.

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

nit: it is not common to have const on params that are copied (especially when they are just builtins)

This revision is now accepted and ready to land.Jun 2 2021, 1:47 PM
adamcz marked an inline comment as done.Jun 4 2021, 8:01 AM

I didn't put much thought into where --check-lines goes. It's an interesting thought.

I think having all the flags in one place is more valuable than trying to split them in some way. We contain all flags in the same place, close to main() and check() gets all it's data from arguments, rather than some side channel. It makes check() easier to re-use and/or test. It also allows us to complain about flag misuse, such as specifying --check-lines without --check, etc.

I'm going to commit as-is, since you LGTMed this, but feel free to continue discussion here and if we decide to move the flags somewhere else I'll happily submit another change.

adamcz updated this revision to Diff 349878.Jun 4 2021, 8:01 AM

review comments