[index] Nested class declarations should be annotated with the

"specializationOf" relation if they pseudo-override a type in the base template

This commit fixes an issue where Xcode's renaming engine couldn't find the
reference to the second occurrence of "InnerClass" in this example:

template<typename T> struct Ts { template<typename U> struct InnerClass { }; };

template<> struct Ts<int> {
template<typename U> struct InnerClass; // This occurrence wasn't renamed
};

rdar://31884960

Differential Revision: https://reviews.llvm.org/D34392

llvm-svn: 305911
This commit is contained in:
Alex Lorenz 2017-06-21 13:51:04 +00:00
parent 5309b7d5c9
commit d283dd4e06
2 changed files with 20 additions and 1 deletions

View File

@ -351,9 +351,11 @@ public:
IndexCtx.indexTagDecl(D, Relations);
} else {
auto *Parent = dyn_cast<NamedDecl>(D->getDeclContext());
SmallVector<SymbolRelation, 1> Relations;
gatherTemplatePseudoOverrides(D, Relations);
return IndexCtx.handleReference(D, D->getLocation(), Parent,
D->getLexicalDeclContext(),
SymbolRoleSet());
SymbolRoleSet(), Relations);
}
}
return true;

View File

@ -134,6 +134,9 @@ class PseudoOverridesInSpecializations {
template<typename U> struct InnerTemplate { };
template<typename U> struct InnerTemplate <U*> { };
template<typename U>
class InnerClass { };
};
template<>
@ -195,8 +198,22 @@ class PseudoOverridesInSpecializations<double, int> {
// CHECK-NEXT: RelChild
// CHECK-NEXT: RelSpecialization | InnerTemplate | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerTemplate
template<typename U> struct InnerTemplate <U*> { };
template<typename U>
class InnerClass;
// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | <no-cgname> | Ref,RelCont,RelSpecialization | rel: 2
// CHECK-NEXT: RelCont
// CHECK-NEXT: RelSpecialization | InnerClass | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerClass
};
template<typename U>
class PseudoOverridesInSpecializations<double, int>::InnerClass {
};
// CHECK: [[@LINE-2]]:54 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | <no-cgname> | Def,RelChild | rel: 1
// CHECK-NEXT: RelChild
// CHECK: [[@LINE-4]]:7 | class(Gen)/C++ | PseudoOverridesInSpecializations | c:@ST>2#T#T@PseudoOverridesInSpecializations | <no-cgname> | Ref,RelCont | rel: 1
// CHECK-NEXT: RelCont
template<typename S>
class PseudoOverridesInSpecializations<float, S> {
typedef float TypealiasOrRecord;