diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp index de4cce83999b..f955fee17581 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -13,8 +13,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, DIEArray &die_offsets) { const size_t count = die_info_array.size(); for (size_t i = 0; i < count; ++i) - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); } void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, @@ -33,8 +32,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, tag == DW_TAG_structure_type || tag == DW_TAG_class_type; } if (tag_matches) - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); } } } @@ -58,8 +56,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, tag == DW_TAG_structure_type || tag == DW_TAG_class_type; } if (tag_matches) - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); } } } @@ -77,8 +74,7 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray( // We found the one true definition for this class, so only return // that die_offsets.clear(); - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); return; } else { // Put the one true definition as the first entry so it matches first @@ -86,8 +82,7 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray( die_info_array[i].offset); } } else { - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); } } } @@ -99,8 +94,7 @@ void DWARFMappedHash::ExtractTypesFromDIEArray( const size_t count = die_info_array.size(); for (size_t i = 0; i < count; ++i) { if ((die_info_array[i].type_flags & type_flag_mask) == type_flag_value) - die_offsets.emplace_back(die_info_array[i].cu_offset, - die_info_array[i].offset); + die_offsets.emplace_back(die_info_array[i]); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h index 0fbb561448d0..7a7b7bb18439 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h @@ -56,6 +56,8 @@ public: DIEInfo(); DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h); + + explicit operator DIERef() const { return {cu_offset, offset}; } }; struct Atom { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 2e8e1c682387..0a0ffb1906d5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -245,6 +245,7 @@ void ManualDWARFIndex::IndexUnitImpl( } } + DIERef ref(cu_offset, die.GetOffset()); switch (tag) { case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: @@ -258,38 +259,30 @@ void ManualDWARFIndex::IndexUnitImpl( ConstString objc_fullname_no_category_name( objc_method.GetFullNameWithoutCategory(true)); ConstString objc_class_name_no_category(objc_method.GetClassName()); - set.function_fullnames.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.function_fullnames.Insert(ConstString(name), ref); if (objc_class_name_with_category) - set.objc_class_selectors.Insert( - objc_class_name_with_category, - DIERef(cu_offset, die.GetOffset())); + set.objc_class_selectors.Insert(objc_class_name_with_category, + ref); if (objc_class_name_no_category && objc_class_name_no_category != objc_class_name_with_category) - set.objc_class_selectors.Insert( - objc_class_name_no_category, - DIERef(cu_offset, die.GetOffset())); + set.objc_class_selectors.Insert(objc_class_name_no_category, ref); if (objc_selector_name) - set.function_selectors.Insert(objc_selector_name, - DIERef(cu_offset, die.GetOffset())); + set.function_selectors.Insert(objc_selector_name, ref); if (objc_fullname_no_category_name) set.function_fullnames.Insert(objc_fullname_no_category_name, - DIERef(cu_offset, die.GetOffset())); + ref); } // If we have a mangled name, then the DW_AT_name attribute is // usually the method name without the class or any parameters bool is_method = DWARFDIE(&unit, &die).IsMethod(); if (is_method) - set.function_methods.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.function_methods.Insert(ConstString(name), ref); else - set.function_basenames.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.function_basenames.Insert(ConstString(name), ref); if (!is_method && !mangled_cstr && !objc_method.IsValid(true)) - set.function_fullnames.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.function_fullnames.Insert(ConstString(name), ref); } if (mangled_cstr) { // Make sure our mangled name isn't the same string table entry as @@ -299,8 +292,7 @@ void ManualDWARFIndex::IndexUnitImpl( if (name && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) { - set.function_fullnames.Insert(ConstString(mangled_cstr), - DIERef(cu_offset, die.GetOffset())); + set.function_fullnames.Insert(ConstString(mangled_cstr), ref); } } } @@ -318,22 +310,19 @@ void ManualDWARFIndex::IndexUnitImpl( case DW_TAG_union_type: case DW_TAG_unspecified_type: if (name && !is_declaration) - set.types.Insert(ConstString(name), DIERef(cu_offset, die.GetOffset())); + set.types.Insert(ConstString(name), ref); if (mangled_cstr && !is_declaration) - set.types.Insert(ConstString(mangled_cstr), - DIERef(cu_offset, die.GetOffset())); + set.types.Insert(ConstString(mangled_cstr), ref); break; case DW_TAG_namespace: if (name) - set.namespaces.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.namespaces.Insert(ConstString(name), ref); break; case DW_TAG_variable: if (name && has_location_or_const_value && is_global_or_static_variable) { - set.globals.Insert(ConstString(name), - DIERef(cu_offset, die.GetOffset())); + set.globals.Insert(ConstString(name), ref); // Be sure to include variables by their mangled and demangled names if // they have any since a variable can have a basename "i", a mangled // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name @@ -345,8 +334,7 @@ void ManualDWARFIndex::IndexUnitImpl( // entries if (mangled_cstr && name != mangled_cstr && ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) { - set.globals.Insert(ConstString(mangled_cstr), - DIERef(cu_offset, die.GetOffset())); + set.globals.Insert(ConstString(mangled_cstr), ref); } } break;