]> granicus.if.org Git - clang/commitdiff
[libclang] For a reference of an implicit template instantiation just give
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 11 Feb 2012 02:00:00 +0000 (02:00 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 11 Feb 2012 02:00:00 +0000 (02:00 +0000)
a reference for the instantiation decl. Also test that its location is correct
after previous commit.

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

test/Index/index-refs.cpp
tools/libclang/IndexTypeSourceInfo.cpp

index be272f518d97e4b0d924285fb921d6dba253a634..e4c438896712f82b19b44b593997285e565268fc 100644 (file)
@@ -43,6 +43,17 @@ using namespace NS;
 using namespace NS::Inn;
 using NS::Foo;
 
+template <typename T1, typename T2>
+struct TS { };
+
+template <typename T>
+struct TS<T, int> {
+  typedef int MyInt;
+};
+
+void foo3() {
+  TS<int, int> s;
+}
 
 // RUN: c-index-test -index-file %s | FileCheck %s
 // CHECK:      [indexDeclaration]: kind: namespace | name: NS
@@ -74,3 +85,11 @@ using NS::Foo;
 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: Inn | {{.*}} | loc: 43:21
 // CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 44:7
 // CHECK-NEXT: [indexEntityReference]: kind: typedef | name: Foo | {{.*}} | loc: 44:11
+
+// CHECK:      [indexDeclaration]: kind: c++-class-template | name: TS | {{.*}} | loc: 47:8
+// CHECK-NEXT: [indexDeclaration]: kind: struct-template-partial-spec | name: TS | USR: c:@SP>1#T@TS>#t0.0#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@SP>1#T@TS>#t0.0#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+// CHECK-NEXT: [indexDeclaration]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@S@TS>#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo3
+// CHECK-NEXT: [indexEntityReference]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 55:3
index 012e422ef585ec31c0ddbf08608eec9d66c7be8c..1e753781054e09f54ca201c706b39d35458e1fbd 100644 (file)
@@ -73,9 +73,6 @@ public:
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
     if (const TemplateSpecializationType *T = TL.getTypePtr()) {
-      if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
-        IndexCtx.handleReference(D, TL.getTemplateNameLoc(),
-                                 Parent, ParentDC);
       if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
         IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
                                  Parent, ParentDC);