This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Only add global scope to completion query scopes for TU context.
AbandonedPublic

Authored by ioeric on Oct 31 2018, 3:59 AM.

Details

Reviewers
sammccall
Summary

This avoids duplicated scopes in the query e.g. when anonymous namespace
is present.

Event Timeline

ioeric created this revision.Oct 31 2018, 3:59 AM
ilya-biryukov added inline comments.Oct 31 2018, 7:44 AM
clangd/CodeComplete.cpp
563

Anonymous namespace inside other namespaces will also produce duplicate scopes.
Maybe simply remove the duplicates from the vector before we return it?

ioeric added inline comments.Oct 31 2018, 7:47 AM
clangd/CodeComplete.cpp
563

printNamespaceScope() will return "" for all anonymous namespaces, which should be covered as well.

ilya-biryukov added inline comments.Oct 31 2018, 8:06 AM
clangd/CodeComplete.cpp
563

I don't think that's the case.
My understanding is that printNamespaceScope("foo::<anonymous>::bar::<anonymous>") will return "foo::bar::".

ioeric updated this revision to Diff 171924.Oct 31 2018, 8:16 AM
  • Clarify documentation for printNamespaceScope
ioeric updated this revision to Diff 171928.Oct 31 2018, 8:22 AM
  • revert wrong comment
ioeric planned changes to this revision.Oct 31 2018, 8:28 AM

I got the behavior of printNamespaceScope wrong in this patch. Will update.

ioeric abandoned this revision.Nov 5 2018, 7:54 AM
ioeric marked an inline comment as done.
ioeric added inline comments.
clangd/CodeComplete.cpp
563

Thanks for the catch! Switched to deduplicate scopes instead (D54105)