diff options
author | Tom Tromey <tom@tromey.com> | 2024-10-08 19:31:51 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-10-20 10:13:05 -0600 |
commit | 40ae603e6e0fe21fd0c1677dcf4e137cf99c2ebe (patch) | |
tree | 37b815b09eb8c8da38cd0846cdc7cd9136149167 /gdb/dwarf2 | |
parent | 32dc367249e85ecb2449d4be8cafc8e3fc2f359f (diff) | |
download | gdb-40ae603e6e0fe21fd0c1677dcf4e137cf99c2ebe.zip gdb-40ae603e6e0fe21fd0c1677dcf4e137cf99c2ebe.tar.gz gdb-40ae603e6e0fe21fd0c1677dcf4e137cf99c2ebe.tar.bz2 |
Use std::make_unique in more places
I searched for spots using ".reset (new ...)" and replaced most of
these with std::make_unique. I think this is a bit cleaner and more
idiomatic.
Regression tested on x86-64 Fedora 40.
Reviewed-By: Klaus Gerlicher<klaus.gerlicher@intel.com>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/cu.c | 9 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 16 |
2 files changed, 14 insertions, 11 deletions
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 5cb2291..76cdd6f 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -77,9 +77,12 @@ dwarf2_cu::start_compunit_symtab (const char *name, const char *comp_dir, name_for_id = name_for_id_holder.c_str (); } - m_builder.reset (new struct buildsym_compunit - (this->per_objfile->objfile, - name, comp_dir, name_for_id, lang (), low_pc)); + m_builder = std::make_unique<buildsym_compunit> (this->per_objfile->objfile, + name, + comp_dir, + name_for_id, + lang (), + low_pc); list_in_scope = get_builder ()->get_file_symbols (); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bd2de02..cc49c47 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -3970,7 +3970,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu, /* If an existing_cu is provided, a dwarf2_cu must not exist for this_cu in per_objfile yet. */ gdb_assert (per_objfile->get_cu (this_cu) == nullptr); - m_new_cu.reset (new dwarf2_cu (this_cu, per_objfile)); + m_new_cu = std::make_unique<dwarf2_cu> (this_cu, per_objfile); cu = m_new_cu.get (); } @@ -4067,7 +4067,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, thread-safe. */ gdb_assert (cache != nullptr || per_objfile->get_cu (this_cu) == nullptr); - m_new_cu.reset (new dwarf2_cu (this_cu, per_objfile)); + m_new_cu = std::make_unique<dwarf2_cu> (this_cu, per_objfile); cu = m_new_cu.get (); } @@ -4257,7 +4257,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu, /* This is cheap if the section is already read in. */ section->read (objfile); - m_new_cu.reset (new dwarf2_cu (this_cu, per_objfile)); + m_new_cu = std::make_unique<dwarf2_cu> (this_cu, per_objfile); begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off); info_ptr = read_and_check_comp_unit_head (per_objfile, &m_new_cu->header, @@ -7366,7 +7366,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) res.set_name (make_unique_xstrdup (lbasename (res.get_name ()))); } - cu->per_cu->fnd.reset (new file_and_directory (std::move (res))); + cu->per_cu->fnd = std::make_unique<file_and_directory> (std::move (res)); return *cu->per_cu->fnd; } @@ -7612,11 +7612,11 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) gdb_assert (tug_unshare->symtabs == NULL); gdb_assert (m_builder == nullptr); struct compunit_symtab *cust = tug_unshare->compunit_symtab; - m_builder.reset (new struct buildsym_compunit + m_builder = std::make_unique<buildsym_compunit> (cust->objfile (), "", cust->dirname (), cust->language (), - 0, cust)); + 0, cust); list_in_scope = get_builder ()->get_file_symbols (); } return; @@ -7666,11 +7666,11 @@ dwarf2_cu::setup_type_unit_groups (struct die_info *die) { gdb_assert (m_builder == nullptr); struct compunit_symtab *cust = tug_unshare->compunit_symtab; - m_builder.reset (new struct buildsym_compunit + m_builder = std::make_unique<buildsym_compunit> (cust->objfile (), "", cust->dirname (), cust->language (), - 0, cust)); + 0, cust); list_in_scope = get_builder ()->get_file_symbols (); auto &file_names = line_header->file_names (); |