https://github.com/tgs-sc updated https://github.com/llvm/llvm-project/pull/154123
>From f19ba133d67af221c8ccba6d697d1b3cac88c943 Mon Sep 17 00:00:00 2001 From: Timur Golubovich <timur.golubov...@syntacore.com> Date: Mon, 18 Aug 2025 17:29:01 +0300 Subject: [PATCH] [lldb][DWARFASTParserClang] Added a check for the specialization existence While debugging an application with incorrect dwarf information, where DW_TAG_template_value_parameter was lost, I found that lldb does not check that the corresponding specialization exists. As a result, at the stage when ASTImporter works, the type is completed in such a way that it inherits from itself. And during the calculation of layout, an infinite recursion occurs. To catch this error, I added a corresponding check at the stage of restoring the type from dwarf information. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index c76d67b47b336..6643751cd237a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1873,6 +1873,22 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, clang_type = m_ast.CreateClassTemplateSpecializationType(class_specialization_decl); + // Try to find an existing specialization with these template arguments and + // template parameter list. + void *InsertPos = nullptr; + if (!class_template_decl->findSpecialization(template_param_infos.GetArgs(), + InsertPos)) + // Add this specialization to the class template. + class_template_decl->AddSpecialization(class_specialization_decl, + InsertPos); + else { + dwarf->GetObjectFile()->GetModule()->ReportError( + "SymbolFileDWARF({0:p}) - Specialization for " + "clang::ClassTemplateDecl({1:p}) already exists.", + static_cast<void *>(this), static_cast<void *>(class_template_decl)); + return TypeSP(); + } + m_ast.SetMetadata(class_template_decl, metadata); m_ast.SetMetadata(class_specialization_decl, metadata); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits