[PATCH] D42073: [clangd] Query all visible scopes based on all visible using-namespace declarationsand containing namespace for global qualified code completion.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 10:27:43 PST 2018

sammccall added inline comments.

Comment at: clangd/CodeComplete.cpp:270
+  /// namespace scopes which are visible to the qualified-id completion token.
+  std::vector<std::string> Scopes;
ilya-biryukov wrote:
> sammccall wrote:
> > Just to check, if the user types:
> > "vec" --> None
> > "::vec" --> {""}
> > "std::vec" --> {"std"}
> > "using namespace std; vec" --> None
> > "using namespace std; ::vec" --> {"", "std"}
> > 
> > is this right?
> I think the idea was to have (I only highlight the differences):
> "vec" --> {""}
> "using namespace std; vec" --> {"", "std"}
> @hokein , or am I getting it wrong?
You're probably right, just want to be sure we're talking about the same thing.

There's two layers here: the context detected from sema, and what we're going to send the index. The layering is more relevant now that more of this moves out of clangd.

for "vec", we should be sending {""} to the index for now, and later move towards doing global completion.
But if possible the detection code should report None, and the query-index code should translate it - there's no reason the detection code needs to be wrong just because clangd can't do qualifier insertion/smart ranking/etc.

That said, per our discussion this morning, the detected state shouldn't really be Optional<vector<string>>, but rather struct { vector<string> AccessibleScope, optional<string> UnresolvedQualifier } or something like that...

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list