This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Handle multiple callbacks from Sema's completion
ClosedPublic

Authored by ilya-biryukov on Mar 16 2018, 7:31 AM.

Details

Summary

When parser backtracks, we might receive multiple code completion
callbacks.
Previously we had a failing assertion there, now we take first results
and hope they are good enough.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Mar 16 2018, 7:31 AM

As a follow-up to an offline discussion: I opted for not excluding results from 'Recovery' contexts, because they are actually somewhat semantically relevant (i.e. contain only local variables from the current function). One example where this is useful are skipped PP branches (see CompleteInExcludedPPBranch test).

sammccall accepted this revision.Mar 16 2018, 7:42 AM
sammccall added inline comments.
clangd/CodeComplete.cpp
454 ↗(On Diff #138702)

Suggest some hint in the log that helps readers who don't know the code structure. (It's easy to find the code structure by searching.

E.g. "Multiple code complete callbacks (parser backtracked?). Dropping results from context {0}, keeping results from {1}."

unittests/clangd/CodeCompleteTests.cpp
623 ↗(On Diff #138702)

dead code? delete it or add an assertion

This revision is now accepted and ready to land.Mar 16 2018, 7:42 AM
ilya-biryukov marked 2 inline comments as done.
  • Address review comments
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.