From: Alex Lorenz Date: Wed, 21 Jun 2017 13:51:04 +0000 (+0000) Subject: [index] Nested class declarations should be annotated with the X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a8ecfcda38f13f785093ebac220c85a62c3a944;p=clang [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 struct Ts { template struct InnerClass { }; }; template<> struct Ts { template struct InnerClass; // This occurrence wasn't renamed }; rdar://31884960 Differential Revision: https://reviews.llvm.org/D34392 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305911 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/IndexDecl.cpp b/lib/Index/IndexDecl.cpp index 2162c039c4..2b0368131b 100644 --- a/lib/Index/IndexDecl.cpp +++ b/lib/Index/IndexDecl.cpp @@ -351,9 +351,11 @@ public: IndexCtx.indexTagDecl(D, Relations); } else { auto *Parent = dyn_cast(D->getDeclContext()); + SmallVector Relations; + gatherTemplatePseudoOverrides(D, Relations); return IndexCtx.handleReference(D, D->getLocation(), Parent, D->getLexicalDeclContext(), - SymbolRoleSet()); + SymbolRoleSet(), Relations); } } return true; diff --git a/test/Index/Core/index-source.cpp b/test/Index/Core/index-source.cpp index 10f2d8f777..76fdc551c0 100644 --- a/test/Index/Core/index-source.cpp +++ b/test/Index/Core/index-source.cpp @@ -134,6 +134,9 @@ class PseudoOverridesInSpecializations { template struct InnerTemplate { }; template struct InnerTemplate { }; + + template + class InnerClass { }; }; template<> @@ -195,8 +198,22 @@ class PseudoOverridesInSpecializations { // CHECK-NEXT: RelChild // CHECK-NEXT: RelSpecialization | InnerTemplate | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerTemplate template struct InnerTemplate { }; + + template + class InnerClass; +// CHECK: [[@LINE-1]]:9 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | | Ref,RelCont,RelSpecialization | rel: 2 +// CHECK-NEXT: RelCont +// CHECK-NEXT: RelSpecialization | InnerClass | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerClass }; +template +class PseudoOverridesInSpecializations::InnerClass { +}; +// CHECK: [[@LINE-2]]:54 | class(Gen)/C++ | InnerClass | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerClass | | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild +// CHECK: [[@LINE-4]]:7 | class(Gen)/C++ | PseudoOverridesInSpecializations | c:@ST>2#T#T@PseudoOverridesInSpecializations | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont + template class PseudoOverridesInSpecializations { typedef float TypealiasOrRecord;