PR21909: Don't try (and crash) to generate debug info for explicit instantiations...
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 16 Dec 2014 23:49:18 +0000 (23:49 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 16 Dec 2014 23:49:18 +0000 (23:49 +0000)
llvm-svn: 224394

clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp

index 87bd955..25aaa30 100644 (file)
@@ -3283,7 +3283,8 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
   case Decl::ClassTemplateSpecialization: {
     const auto *Spec = cast<ClassTemplateSpecializationDecl>(D);
     if (DebugInfo &&
-        Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition)
+        Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition &&
+        Spec->hasDefinition())
       DebugInfo->completeTemplateDefinition(*Spec);
     break;
   }
index 506c0d5..4613038 100644 (file)
@@ -91,3 +91,11 @@ struct j {
 extern template class j<int>;
 j<int> jj;
 // CHECK: ; [ DW_TAG_structure_type ] [j<int, int>]
+
+template <typename T>
+struct k {
+};
+template <>
+struct k<int>;
+template struct k<int>;
+// CHECK-NOT: ; [ DW_TAG_structure_type ] [k<int>]