Sema code complete in the recovery mode is generally useless. For many
cases, sema first completes in recovery context and then recovers to more useful
context, in which it's favorable to ignore results from recovery (as results are
often bad e.g. all builtin symbols and top-level symbols). There is also case
where only sema would fail to recover e.g. completions in excluded #if block.
Sema would try to give results, but the results are often useless (see the updated
excluded #if block test).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I like this idea, of course hard to know how it will affect all practical cases.
Is it easy to get have internal stats on how many wins/losses this has?
clangd/CodeComplete.cpp | ||
---|---|---|
596 ↗ | (On Diff #154971) | might |
596 ↗ | (On Diff #154971) | This might also be a case where we can trial identifier-based completion. (Eventually I think we'd want it in other contexts too) |
Thanks! That's a simple fix that makes things better overall!
LGTM with a NIT about the comment in the test.
unittests/clangd/CodeCompleteTests.cpp | ||
---|---|---|
797 ↗ | (On Diff #154971) | NIT. I would argue the results were actually useful here and we introduced a regression. |
This would fix bad completion results when sema could recover to the normal mode (e.g. completion in macros like EXPECT_THAT, expressions in if statements). From the code completion metrics I collected from existing code, the number of completions where no result was found dropped by 30%. The loss seems to be we will get no result in recovery mode rather than bad results (e.g. in excluded preprocessor branches).