From: Ilya Biryukov Date: Fri, 4 Oct 2019 08:10:27 +0000 (+0000) Subject: [CodeComplete] Ensure object is the same in compareOverloads() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=889c2156fe00f4b40d4da60509a6216037118673;p=clang [CodeComplete] Ensure object is the same in compareOverloads() Summary: This fixes a regression that led to size() not being available in clangd when completing 'deque().^' and using libc++. Reviewers: sammccall Reviewed By: sammccall Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68335 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373710 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index e4bbee86e3..f24c3b234f 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1185,6 +1185,9 @@ static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, 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() != diff --git a/test/CodeCompletion/member-access-qualifiers.cpp b/test/CodeCompletion/member-access-qualifiers.cpp new file mode 100644 index 0000000000..93af02c239 --- /dev/null +++ b/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()