[PATCH] D53571: [clangd] Don't show base class versions of members as completions.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 23 06:51:44 PDT 2018
sammccall created this revision.
sammccall added a reviewer: ioeric.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
These are available via qualifiers, but signal to noise level is low.
Keep required quailifier machinery around though, for cross-ns completion.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D53571
Files:
clangd/CodeComplete.cpp
unittests/clangd/CodeCompleteTests.cpp
Index: unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -371,20 +371,26 @@
TEST(CompletionTest, Qualifiers) {
auto Results = completions(R"cpp(
+ namespace x {
+ int foo();
class Foo {
public: int foo() const;
int bar() const;
};
class Bar : public Foo {
int foo() const;
};
void test() { Bar().^ }
+ }
)cpp");
EXPECT_THAT(Results.Completions,
- HasSubsequence(AllOf(Qualifier(""), Named("bar")),
- AllOf(Qualifier("Foo::"), Named("foo"))));
+ Contains(AllOf(Qualifier(""), Named("bar"))));
+ // Hidden members are not shown.
+ EXPECT_THAT(Results.Completions,
+ Not(Contains(AllOf(Qualifier("Foo::"), Named("foo")))));
+ // Private members are not shown.
EXPECT_THAT(Results.Completions,
- Not(Contains(AllOf(Qualifier(""), Named("foo"))))); // private
+ Not(Contains(AllOf(Qualifier(""), Named("foo")))));
}
TEST(CompletionTest, InjectedTypename) {
Index: clangd/CodeComplete.cpp
===================================================================
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -728,9 +728,9 @@
// Retain the results we might want.
for (unsigned I = 0; I < NumResults; ++I) {
auto &Result = InResults[I];
- // Drop hidden items which cannot be found by lookup after completion.
- // Exception: some items can be named by using a qualifier.
- if (Result.Hidden && (!Result.Qualifier || Result.QualifierIsInformative))
+ // Class members that are shadowed by subclasses are usually noise.
+ if (Result.Hidden && Result.Declaration &&
+ Result.Declaration->isCXXClassMember())
continue;
if (!Opts.IncludeIneligibleResults &&
(Result.Availability == CXAvailability_NotAvailable ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53571.170632.patch
Type: text/x-patch
Size: 2021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181023/b7d08d66/attachment.bin>
More information about the cfe-commits
mailing list