[PATCH] D52331: [Index] Report specialization bases as references when IndexImplicitInstantiation is true

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 23 01:25:35 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342831: [Index] Report specialization bases as references when… (authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52331

Files:
  cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
  cfe/trunk/test/Index/index-template-specialization.cpp


Index: cfe/trunk/test/Index/index-template-specialization.cpp
===================================================================
--- cfe/trunk/test/Index/index-template-specialization.cpp
+++ cfe/trunk/test/Index/index-template-specialization.cpp
@@ -9,11 +9,21 @@
   foo.f(0);
 }
 
+template <typename T>
+struct B {};
+
+template <typename T>
+struct D : B<T> {};
+
 // FIXME: if c-index-test uses OrigD for symbol info, refererences below should
 // refer to template specialization decls.
 // RUN: env CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS=1 c-index-test -index-file %s | FileCheck %s
 // CHECK: [indexDeclaration]: kind: c++-class-template | name: Foo
 // CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: f
 // CHECK-NEXT: [indexDeclaration]: kind: function | name: g
 // CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: Foo | USR: c:@ST>1#T at Foo
 // CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: f | USR: c:@ST>1#T at Foo@F at f#t0.0#
+
+// CHECK: [indexDeclaration]: kind: c++-class-template | name: D
+// CHECK-NEXT: <base>: kind: c++-class-template | name: B
+// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: B
Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
===================================================================
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
@@ -130,14 +130,15 @@
   bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
     if (const auto *T = TL.getTypePtr()) {
       if (IndexCtx.shouldIndexImplicitInstantiation()) {
-        if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+        if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
           IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
                                    Parent, ParentDC, SymbolRoleSet(), Relations);
-      } else {
-        if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-          IndexCtx.handleReference(D, TL.getTemplateNameLoc(),
-                                   Parent, ParentDC, SymbolRoleSet(), Relations);
+          return true;
+        }
       }
+      if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
+        IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
+                                 SymbolRoleSet(), Relations);
     }
     return true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52331.166631.patch
Type: text/x-patch
Size: 2410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180923/926ea60c/attachment-0001.bin>


More information about the cfe-commits mailing list