From 295d20d66fac1cf89448d58b8700f1b392aa7081 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 16 Dec 2014 23:49:18 +0000 Subject: [PATCH] PR21909: Don't try (and crash) to generate debug info for explicit instantiations of explicit specializations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224394 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 3 ++- .../debug-info-template-explicit-specialization.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 87bd955a6c..25aaa30855 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -3283,7 +3283,8 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { case Decl::ClassTemplateSpecialization: { const auto *Spec = cast(D); if (DebugInfo && - Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition) + Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition && + Spec->hasDefinition()) DebugInfo->completeTemplateDefinition(*Spec); break; } diff --git a/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp b/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp index 506c0d5357..461303884b 100644 --- a/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp +++ b/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp @@ -91,3 +91,11 @@ struct j { extern template class j; j jj; // CHECK: ; [ DW_TAG_structure_type ] [j] + +template +struct k { +}; +template <> +struct k; +template struct k; +// CHECK-NOT: ; [ DW_TAG_structure_type ] [k] -- 2.40.0