[cfe-commits] r150291 - in /cfe/trunk: test/Index/index-refs.cpp tools/libclang/IndexTypeSourceInfo.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Feb 10 18:00:00 PST 2012


Author: akirtzidis
Date: Fri Feb 10 20:00:00 2012
New Revision: 150291

URL: http://llvm.org/viewvc/llvm-project?rev=150291&view=rev
Log:
[libclang] For a reference of an implicit template instantiation just give
a reference for the instantiation decl. Also test that its location is correct
after previous commit.

Modified:
    cfe/trunk/test/Index/index-refs.cpp
    cfe/trunk/tools/libclang/IndexTypeSourceInfo.cpp

Modified: cfe/trunk/test/Index/index-refs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-refs.cpp?rev=150291&r1=150290&r2=150291&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-refs.cpp (original)
+++ cfe/trunk/test/Index/index-refs.cpp Fri Feb 10 20:00:00 2012
@@ -43,6 +43,17 @@
 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 @@
 // 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 at TS>#t0.0#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp at 593@SP>1#T at TS>#t0.0#I at 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 at TS>#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp at 593@S at TS>#I at 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 at TS>#I | {{.*}} | loc: 55:3

Modified: cfe/trunk/tools/libclang/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexTypeSourceInfo.cpp?rev=150291&r1=150290&r2=150291&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/tools/libclang/IndexTypeSourceInfo.cpp Fri Feb 10 20:00:00 2012
@@ -73,9 +73,6 @@
 
   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);





More information about the cfe-commits mailing list