r247373 - [sema] Fix assertion hit when using libclang to index a particular C++ snippet involving templates.

Argyrios Kyrtzidis via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 18:44:57 PDT 2015


Author: akirtzidis
Date: Thu Sep 10 20:44:56 2015
New Revision: 247373

URL: http://llvm.org/viewvc/llvm-project?rev=247373&view=rev
Log:
[sema] Fix assertion hit when using libclang to index a particular C++ snippet involving templates.

Assertion hit was in ClassTemplateSpecializationDecl::getSourceRange().

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/Index/index-file.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=247373&r1=247372&r2=247373&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Sep 10 20:44:56 2015
@@ -7386,11 +7386,16 @@ Sema::ActOnExplicitInstantiation(Scope *
       }
     }
 
+    // Set the template specialization kind. Make sure it is set before
+    // instantiating the members which will trigger ASTConsumer callbacks.
+    Specialization->setTemplateSpecializationKind(TSK);
     InstantiateClassTemplateSpecializationMembers(TemplateNameLoc, Def, TSK);
+  } else {
+
+    // Set the template specialization kind.
+    Specialization->setTemplateSpecializationKind(TSK);
   }
 
-  // Set the template specialization kind.
-  Specialization->setTemplateSpecializationKind(TSK);
   return Specialization;
 }
 

Modified: cfe/trunk/test/Index/index-file.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-file.cpp?rev=247373&r1=247372&r2=247373&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-file.cpp (original)
+++ cfe/trunk/test/Index/index-file.cpp Thu Sep 10 20:44:56 2015
@@ -15,9 +15,19 @@ void tfoo() {}
 void tfoo<int>() {}
 }
 
+namespace crash1 {
+template<typename T> class A {
+  A(A &) = delete;
+  void meth();
+};
+template <> void A<int>::meth();
+template class A<int>;
+}
+
 // RUN: c-index-test -index-file %s > %t
 // RUN: FileCheck %s -input-file=%t
 
 // CHECK: [indexDeclaration]: kind: type-alias | name: MyTypeAlias | {{.*}} | loc: 1:7
 // CHECK: [indexDeclaration]: kind: struct-template-spec | name: TS | {{.*}} | loc: 11:8
 // CHECK: [indexDeclaration]: kind: function-template-spec | name: tfoo | {{.*}} | loc: 15:6
+// CHECK: [indexDeclaration]: kind: c++-instance-method | name: meth | {{.*}} | loc: 23:26




More information about the cfe-commits mailing list