diff options
author | Tom Tromey <tromey@adacore.com> | 2024-09-03 12:04:18 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-09-09 11:37:35 -0600 |
commit | 052736020af3aae80f8eddbfc8a695916cdcbb9a (patch) | |
tree | 0308dc87f2954872863c5cfef4e2a3981d57f515 | |
parent | 86d6495bd44a5f228a65b84d1630fc318d3732ef (diff) | |
download | binutils-052736020af3aae80f8eddbfc8a695916cdcbb9a.zip binutils-052736020af3aae80f8eddbfc8a695916cdcbb9a.tar.gz binutils-052736020af3aae80f8eddbfc8a695916cdcbb9a.tar.bz2 |
Refactor cooked_index_shard::handle_gnat_encoded_entry
This changes cooked_index_shard::handle_gnat_encoded_entry to modify
the incoming entry itself, and to return void rather than a new name.
this simplifies the caller a little, which is convenient for a
different series I am working on.
Approved-By: Tom de Vries <tdevries@suse.de>
-rw-r--r-- | gdb/dwarf2/cooked-index.c | 23 | ||||
-rw-r--r-- | gdb/dwarf2/cooked-index.h | 5 |
2 files changed, 11 insertions, 17 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 41aa9d0..4073c92 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -288,7 +288,7 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag, /* See cooked-index.h. */ -gdb::unique_xmalloc_ptr<char> +void cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, htab_t gnat_entries) { @@ -298,7 +298,10 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, source charset does not affect the indexer directly. */ std::string canonical = ada_decode (entry->name, false, false, false); if (canonical.empty ()) - return {}; + { + entry->canonical = entry->name; + return; + } std::vector<std::string_view> names = split_name (canonical.c_str (), split_style::DOT_STYLE); std::string_view tail = names.back (); @@ -329,7 +332,9 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, } entry->set_parent (parent); - return make_unique_xstrndup (tail.data (), tail.length ()); + auto new_canon = make_unique_xstrndup (tail.data (), tail.length ()); + entry->canonical = new_canon.get (); + m_names.push_back (std::move (new_canon)); } /* See cooked-index.h. */ @@ -389,17 +394,7 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps) if ((entry->flags & IS_LINKAGE) != 0) entry->canonical = entry->name; else if (entry->lang == language_ada) - { - gdb::unique_xmalloc_ptr<char> canon_name - = handle_gnat_encoded_entry (entry, gnat_entries.get ()); - if (canon_name == nullptr) - entry->canonical = entry->name; - else - { - entry->canonical = canon_name.get (); - m_names.push_back (std::move (canon_name)); - } - } + handle_gnat_encoded_entry (entry, gnat_entries.get ()); else if (entry->lang == language_cplus || entry->lang == language_c) { void **slot = htab_find_slot (seen_names.get (), entry, diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index e9f13c9..5b48b81 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -338,9 +338,8 @@ private: /* GNAT only emits mangled ("encoded") names in the DWARF, and does not emit the module structure. However, we need this structure to do lookups. This function recreates that structure for an - existing entry. It returns the base name (last element) of the - full decoded name. */ - gdb::unique_xmalloc_ptr<char> handle_gnat_encoded_entry + existing entry, modifying ENTRY as appropriate. */ + void handle_gnat_encoded_entry (cooked_index_entry *entry, htab_t gnat_entries); /* Finalize the index. This should be called a single time, when |