https://github.com/skadewdl3 created https://github.com/llvm/llvm-project/pull/210610
Fixes #210234 As per my investigation (mostly following stack traces and dumping variable values), a default empty `DeclarationNameInfo` was being returned after template substitution [over here](https://github.com/llvm/llvm-project/blob/c45b4e4d00bed488d6ece5608560561732ae5b9e/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp#L3270). ```cpp // D-.>getNameInfo() has actual data here DeclarationNameInfo NameInfo = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs); // NameInfo has default values ``` This was being passed on directly to `CXXDestructorDecl::Create` leading to the assertion being hit. This PR adds a check that ensures `NameInfo` actually contains a valid destructor name before constructing a `CXXDestructorDecl`. This fixes the assertion being hit in the reproducer from the linked issue. >From 28cd7775fba49e938db8f79d1ce8c55adbeebccb Mon Sep 17 00:00:00 2001 From: Soham Karandikar <[email protected]> Date: Sun, 19 Jul 2026 21:55:54 +0530 Subject: [PATCH] Added a check for `NameInfo` actually containing a valid destructor name --- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index c2e90624b8a6e..30ddad02f63c2 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3287,7 +3287,10 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl( TrailingRequiresClause); Method->setRangeEnd(Constructor->getEndLoc()); } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) { - Method = CXXDestructorDecl::Create( + if (NameInfo.getName().getNameKind() != DeclarationName::NameKind::CXXDestructorName) { + return nullptr; + } + Method = CXXDestructorDecl::Create( SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo, Destructor->UsesFPIntrin(), Destructor->isInlineSpecified(), false, Destructor->getConstexprKind(), TrailingRequiresClause); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
