Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -110,6 +110,21 @@ } } +static inline bool AddMangled(ConstString name, ConstString mangled) { + return mangled && name != mangled; +} + +// +//static inline bool AddMangled(const char *name, const char *mangled) { +// if (mangled == nullptr || name == mangled) +// return false; +// if (name == nullptr) +// return true; +// if (mangled[0] != name[0]) +// return true; +// return ::strcmp(name, mangled) != 0; +//} + void ManualDWARFIndex::IndexUnitImpl( DWARFUnit &unit, const LanguageType cu_language, const dw_offset_t cu_offset, IndexSet &set) { @@ -139,7 +154,7 @@ } DWARFAttributes attributes; - const char *name = nullptr; + const char *name_cstr = nullptr; const char *mangled_cstr = nullptr; bool is_declaration = false; // bool is_artificial = false; @@ -156,7 +171,7 @@ switch (attr) { case DW_AT_name: if (attributes.ExtractFormValueAtIndex(i, form_value)) - name = form_value.AsCString(); + name_cstr = form_value.AsCString(); break; case DW_AT_declaration: @@ -247,8 +262,9 @@ case DW_TAG_inlined_subroutine: case DW_TAG_subprogram: if (has_address) { + ConstString name(name_cstr); if (name) { - ObjCLanguage::MethodName objc_method(name, true); + ObjCLanguage::MethodName objc_method(name.GetStringRef(), true); if (objc_method.IsValid(true)) { ConstString objc_class_name_with_category( objc_method.GetClassNameWithCategory()); @@ -256,7 +272,7 @@ 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), ref); + set.function_fullnames.Insert(name, ref); if (objc_class_name_with_category) set.objc_class_selectors.Insert(objc_class_name_with_category, ref); @@ -274,24 +290,17 @@ bool is_method = DWARFDIE(&unit, &die).IsMethod(); if (is_method) - set.function_methods.Insert(ConstString(name), ref); + set.function_methods.Insert(name, ref); else - set.function_basenames.Insert(ConstString(name), ref); + set.function_basenames.Insert(name, ref); if (!is_method && !mangled_cstr && !objc_method.IsValid(true)) - set.function_fullnames.Insert(ConstString(name), ref); + set.function_fullnames.Insert(name, ref); } - if (mangled_cstr) { - // Make sure our mangled name isn't the same string table entry as - // our name. If it starts with '_', then it is ok, else compare the - // string to make sure it isn't the same and we don't end up with - // duplicate entries - if (name && name != mangled_cstr && - ((mangled_cstr[0] == '_') || - (::strcmp(name, mangled_cstr) != 0))) { - set.function_fullnames.Insert(ConstString(mangled_cstr), ref); - } - } + // Make sure our mangled name isn't the same as our name. + ConstString mangled(mangled_cstr); + if (AddMangled(name, mangled)) + set.function_fullnames.Insert(mangled, ref); } break; @@ -306,33 +315,36 @@ case DW_TAG_typedef: case DW_TAG_union_type: case DW_TAG_unspecified_type: - if (name && !is_declaration) - set.types.Insert(ConstString(name), ref); - if (mangled_cstr && !is_declaration) - set.types.Insert(ConstString(mangled_cstr), ref); + if (!is_declaration) { + ConstString name(name_cstr); + if (name) + set.types.Insert(name, ref); + // Make sure our mangled name isn't the same as our name. + ConstString mangled(mangled_cstr); + if (AddMangled(name, mangled)) + set.types.Insert(mangled, ref); + } break; case DW_TAG_namespace: - if (name) - set.namespaces.Insert(ConstString(name), ref); + if (name_cstr) + set.namespaces.Insert(ConstString(name_cstr), ref); break; case DW_TAG_variable: - if (name && has_location_or_const_value && is_global_or_static_variable) { - set.globals.Insert(ConstString(name), ref); + if (has_location_or_const_value && is_global_or_static_variable) { + ConstString name(name_cstr); + if (name) + set.globals.Insert(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 // "(anonymous namespace)::i"... - // Make sure our mangled name isn't the same string table entry as our - // name. If it starts with '_', then it is ok, else compare the string - // to make sure it isn't the same and we don't end up with duplicate - // entries - if (mangled_cstr && name != mangled_cstr && - ((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) { - set.globals.Insert(ConstString(mangled_cstr), ref); - } + // Make sure our mangled name isn't the same as our name. + ConstString mangled(mangled_cstr); + if (AddMangled(name, mangled)) + set.globals.Insert(mangled, ref); } break;