mirror of https://github.com/microsoft/clang.git
PR13699: Include friend declarations in code completion results if they had a
prior visible declaration. Prefer to take template parameter names from the first declaration. Testcase from a patch by Francisco Lopes! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226083 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f34d1d658
commit
e533cc869e
|
@ -495,7 +495,6 @@ bool ResultBuilder::isInterestingDecl(const NamedDecl *ND,
|
|||
AsNestedNameSpecifier = false;
|
||||
|
||||
ND = ND->getUnderlyingDecl();
|
||||
unsigned IDNS = ND->getIdentifierNamespace();
|
||||
|
||||
// Skip unnamed entities.
|
||||
if (!ND->getDeclName())
|
||||
|
@ -503,7 +502,7 @@ bool ResultBuilder::isInterestingDecl(const NamedDecl *ND,
|
|||
|
||||
// Friend declarations and declarations introduced due to friends are never
|
||||
// added as results.
|
||||
if (IDNS & (Decl::IDNS_OrdinaryFriend | Decl::IDNS_TagFriend))
|
||||
if (ND->getFriendObjectKind() == Decl::FOK_Undeclared)
|
||||
return false;
|
||||
|
||||
// Class template (partial) specializations are never added as results.
|
||||
|
@ -2310,6 +2309,10 @@ static void AddTemplateParameterChunks(ASTContext &Context,
|
|||
bool InDefaultArg = false) {
|
||||
bool FirstParameter = true;
|
||||
|
||||
// Prefer to take the template parameter names from the first declaration of
|
||||
// the template.
|
||||
Template = cast<TemplateDecl>(Template->getCanonicalDecl());
|
||||
|
||||
TemplateParameterList *Params = Template->getTemplateParameters();
|
||||
TemplateParameterList::iterator PEnd = Params->end();
|
||||
if (MaxParameters)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// The run lines are below, because this test is line- and
|
||||
// column-number sensitive.
|
||||
|
||||
namespace N {
|
||||
template<typename T> struct A {
|
||||
template<typename U> friend class B;
|
||||
};
|
||||
|
||||
template<typename T> struct B { };
|
||||
}
|
||||
|
||||
void foo() {
|
||||
N::A<int> a1;
|
||||
N::A<int> a2;
|
||||
}
|
||||
|
||||
namespace M {
|
||||
template<typename T> struct C {
|
||||
template<typename U> friend struct C;
|
||||
};
|
||||
}
|
||||
|
||||
void bar() {
|
||||
M::C<int> c1;
|
||||
M::C<int> c2;
|
||||
}
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:14:6 %s | FileCheck -check-prefix=CHECK-ACCESS-1 %s
|
||||
// CHECK-ACCESS-1: ClassTemplate:{TypedText A}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
|
||||
// CHECK-ACCESS-1: ClassTemplate:{TypedText B}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:25:6 %s | FileCheck -check-prefix=CHECK-ACCESS-2 %s
|
||||
// CHECK-ACCESS-2: ClassTemplate:{TypedText C}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
|
Loading…
Reference in New Issue