diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -336,6 +336,7 @@ clang::RQ_None; ///< Indicates ref-qualifier of ///< C++ member function if present. ///< Is RQ_None otherwise. + DWARFFormValue preferred_name; }; #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -396,6 +396,12 @@ case DW_AT_reference: ref_qual = clang::RQ_LValue; break; + + // TODO: Could check this in ParseStructureLikeDIE since it's specific + // to DW_TAG_structure_type + case DW_AT_LLVM_preferred_name: + preferred_name = form_value; + break; } } } @@ -2200,6 +2206,30 @@ GetClangASTImporter().SetRecordLayout(record_decl, layout_info); } + // TODO: only gets resolved after second call to 'v'. + // TODO: doesn't work for 'p'. + // + // Need to set preferred name here since the type that + // the typedef links back to is probably in the process + // of being created. + ParsedDWARFTypeAttributes attrs(die); + if (attrs.preferred_name.IsValid()) { + Type *lldb_type = die.ResolveTypeUID(attrs.preferred_name.Reference()); + if (lldb_type) { + CompilerType pref_name = lldb_type->GetFullCompilerType(); + + clang::CXXRecordDecl *record_decl = + m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType()); + if (record_decl && pref_name.IsValid()) { + clang::QualType pref_name_type = ClangUtil::GetQualType(pref_name); + if (!pref_name_type.isNull()) + record_decl->addAttr(clang::PreferredNameAttr::CreateImplicit( + m_ast.getASTContext(), + m_ast.getASTContext().getTrivialTypeSourceInfo(pref_name_type))); + } + } + } + return (bool)clang_type; } diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1714,6 +1714,7 @@ class_template_specialization_decl->setDeclName( class_template_decl->getDeclName()); SetOwningModule(class_template_specialization_decl, owning_module); + decl_ctx->addDecl(class_template_specialization_decl); class_template_specialization_decl->setSpecializationKind( @@ -3828,6 +3829,8 @@ qual_type = RemoveWrappingTypes(qual_type, {clang::Type::Typedef, clang::Type::Atomic}); + GetCompleteQualType(&getASTContext(), qual_type); + // For a typedef just return the qualified name. if (const auto *typedef_type = qual_type->getAs()) { const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();