Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp @@ -1185,6 +1185,9 @@ const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind) { + // Base/derived shadowing is handled elsewhere. + if (Candidate.getDeclContext() != Incumbent.getDeclContext()) + return OverloadCompare::BothViable; if (Candidate.isVariadic() != Incumbent.isVariadic() || Candidate.getNumParams() != Incumbent.getNumParams() || Candidate.getMinRequiredArguments() != Index: cfe/trunk/test/CodeCompletion/member-access-qualifiers.cpp =================================================================== --- cfe/trunk/test/CodeCompletion/member-access-qualifiers.cpp +++ cfe/trunk/test/CodeCompletion/member-access-qualifiers.cpp @@ -0,0 +1,13 @@ +struct deque_base { + int &size(); + const int &size() const; +}; + +struct deque : private deque_base { + int size() const; +}; + +auto x = deque(). +// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:18 %s -o - | FileCheck %s +// CHECK: COMPLETION: size : [#int#]size()[# const#] +// CHECK: COMPLETION: size (Hidden,InBase,Inaccessible) : [#int &#]deque_base::size() Index: clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp @@ -2546,6 +2546,25 @@ UnorderedElementsAre(AllOf(Qualifier(""), Named("ABCDE")))); } +TEST(CompletionTest, DerivedMethodsAreAlwaysVisible) { + // Despite the fact that base method matches the ref-qualifier better, + // completion results should only include the derived method. + auto Completions = completions(R"cpp( + struct deque_base { + float size(); + double size() const; + }; + struct deque : deque_base { + int size() const; + }; + + auto x = deque().^ + )cpp") + .Completions; + EXPECT_THAT(Completions, + ElementsAre(AllOf(ReturnType("int"), Named("size")))); +} + TEST(NoCompileCompletionTest, Basic) { auto Results = completionsNoCompile(R"cpp( void func() {