Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1759,24 +1759,20 @@ metadata.SetUserID(die.GetID()); metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die)); - if (attrs.name.GetStringRef().contains('<')) { + const llvm::StringRef name = attrs.name.GetStringRef(); + if (name.contains('<')) { TypeSystemClang::TemplateParameterInfos template_param_infos; if (ParseTemplateParameterInfos(die, template_param_infos)) { + // name is in the format 'name' but the name that + // TypeSystemClang wants is just the 'name' prefix, so strip the + // '' suffix here. + const llvm::StringRef template_name = name.substr(0, name.find('<')); clang::ClassTemplateDecl *class_template_decl = - m_ast.ParseClassTemplateDecl( - decl_ctx, GetOwningClangModule(die), attrs.accessibility, - attrs.name.GetCString(), tag_decl_kind, template_param_infos); - if (!class_template_decl) { - if (log) { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, - "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" " - "clang::ClassTemplateDecl failed to return a decl.", - static_cast(this), die.GetOffset(), - DW_TAG_value_to_name(tag), attrs.name.GetCString()); - } - return TypeSP(); - } + m_ast.CreateClassTemplateDecl(decl_ctx, GetOwningClangModule(die), + attrs.accessibility, template_name, + tag_decl_kind, template_param_infos); + assert(class_template_decl && + "CreateClassTemplateDecl unexpectedly failed"); clang::ClassTemplateSpecializationDecl *class_specialization_decl = m_ast.CreateClassTemplateSpecializationDecl( @@ -2096,7 +2092,7 @@ break; } } - return template_param_infos.args.size() == template_param_infos.names.size(); + return template_param_infos.IsValid(); } bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -987,11 +987,6 @@ static clang::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type); - clang::ClassTemplateDecl *ParseClassTemplateDecl( - clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, - lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, - const TypeSystemClang::TemplateParameterInfos &template_param_infos); - clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module); Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp =================================================================== --- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1545,6 +1545,9 @@ DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef class_name, int kind, const TemplateParameterInfos &template_param_infos) { + assert(template_param_infos.IsValid() && + "Passed invalid template parameters?"); + ASTContext &ast = getASTContext(); ClassTemplateDecl *class_template_decl = nullptr; @@ -9203,21 +9206,6 @@ } } -clang::ClassTemplateDecl *TypeSystemClang::ParseClassTemplateDecl( - clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, - lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, - const TypeSystemClang::TemplateParameterInfos &template_param_infos) { - if (template_param_infos.IsValid()) { - std::string template_basename(parent_name); - template_basename.erase(template_basename.find('<')); - - return CreateClassTemplateDecl(decl_ctx, owning_module, access_type, - template_basename.c_str(), tag_decl_kind, - template_param_infos); - } - return nullptr; -} - void TypeSystemClang::CompleteTagDecl(clang::TagDecl *decl) { SymbolFile *sym_file = GetSymbolFile(); if (sym_file) {