[PATCH] D47183: [clangd] Support multiple sema code completion callbacks.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 22 01:38:35 PDT 2018

ilya-biryukov added inline comments.

Comment at: clangd/CodeComplete.cpp:457
       Result.StartsNestedNameSpecifier = false;
+      // FIXME: the same result can be added multiple times as the callback can
+      // be called more than once. We may want to deduplicate identical results.
Could we fix this in the first attempt?
All the code around completion is really not prepared for multiple callbacks: index will be queried multiple times, we will store and log only the last CCContext, not all of them, etc.
I'd argue we should aim to either provide a single-callback completion or rewrite the whole code around completion to properly handle multiple callbacks (i.e. with deduplication and proper merging of the results coming from multiple callbacks, proper logging, no multiple identical requests to the index).

I would suggest the following measures as a hacky intermediate solution:
- Ignore natural language completion. The rationale: VSCode does analogous completion on empty results anyway, AFAIK clang does not provide any useful results on top of that. Other clients that we have can (and should?) probably do the same.
- Only record the first non-natural language completion attempt. Ignore the rest and log the failed attempts.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list