]> granicus.if.org Git - clang/commitdiff
[index] Nested class declarations should be annotated with the
authorAlex Lorenz <arphaman@gmail.com>
Wed, 21 Jun 2017 13:51:04 +0000 (13:51 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Wed, 21 Jun 2017 13:51:04 +0000 (13:51 +0000)
"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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305911 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Index/IndexDecl.cpp
test/Index/Core/index-source.cpp

index 2162c039c48b86f5873b5bf58386846e3067aebe..2b0368131bb956c2e3e9163216cbc656dbaca6bf 100644 (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;
index 10f2d8f77747540312e4ab2afa12a812d1bbcb8c..76fdc551c009681105dc1672a953093f9779e223 100644 (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;