This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Don't query index when completing inside classes
ClosedPublic

Authored by ilya-biryukov on May 12 2018, 12:14 PM.

Details

Summary

We used to query the index when completing after class qualifiers,
e.g. 'ClassName::^'. We should not do that for the same reasons we
don't query the index for member access expressions.

Diff Detail

Event Timeline

ilya-biryukov created this revision.May 12 2018, 12:14 PM
sammccall accepted this revision.May 14 2018, 1:02 AM
sammccall added inline comments.
clangd/CodeComplete.cpp
810

we could use a high level comment here explaining what the rest of the function is about. e.g.

// We also avoid ClassName::bar (but allow namespace::bar).

or just take the "we only query the index" comment, hoist it a bit, and generalize it (to not assume we're in name:: context)

826

(nit: this seems like undue weight, and could just be a trailing line comment // Unresolved inside a template)

unittests/clangd/CodeCompleteTests.cpp
829

Can we avoid disabling clang-format here? I do find it useful, and it adds noise.
IIRC moving the .items into the EXPECT_THAT results in sensible formatting.

837

I think you should also include "Foo::SomeNameInTheIndex" in the index. At first glance this doesn't seem to actually test all the failure modes (though I think it tested the one we actually had)

845

I think one of these would be enough, but up to you

This revision is now accepted and ready to land.May 14 2018, 1:02 AM
ilya-biryukov marked 5 inline comments as done.
  • Address review comments
unittests/clangd/CodeCompleteTests.cpp
829

Thanks! I struggled to rewrite code in a way that makes clang-format happy.

845

Those test different kinds of NestedNameSpecifiers (Type, TypeSpecWithTemplate and Identifier), so I'd keep all of them to make sure we have good coverage on that front.

This revision was automatically updated to reflect the committed changes.