mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
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>
This commit is contained in:
@@ -10494,9 +10494,9 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
|
||||
|
||||
std::unique_ptr<watchpoint> w;
|
||||
if (use_mask)
|
||||
w.reset (new masked_watchpoint (nullptr, bp_type));
|
||||
w = std::make_unique<masked_watchpoint> (nullptr, bp_type);
|
||||
else
|
||||
w.reset (new watchpoint (nullptr, bp_type));
|
||||
w = std::make_unique<watchpoint> (nullptr, bp_type);
|
||||
|
||||
/* At most one of thread or task can be set on a watchpoint. */
|
||||
gdb_assert (thread == -1 || task == -1);
|
||||
|
||||
@@ -269,7 +269,7 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect,
|
||||
if (logfile != nullptr)
|
||||
{
|
||||
gdb_assert (m_saved_output == nullptr);
|
||||
m_saved_output.reset (new saved_output_files);
|
||||
m_saved_output = std::make_unique<saved_output_files> ();
|
||||
m_saved_output->out = gdb_stdout;
|
||||
m_saved_output->err = gdb_stderr;
|
||||
m_saved_output->log = gdb_stdlog;
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
@@ -222,7 +222,7 @@ static jiter_objfile_data *
|
||||
get_jiter_objfile_data (objfile *objf)
|
||||
{
|
||||
if (objf->jiter_data == nullptr)
|
||||
objf->jiter_data.reset (new jiter_objfile_data ());
|
||||
objf->jiter_data = std::make_unique<jiter_objfile_data> ();
|
||||
|
||||
return objf->jiter_data.get ();
|
||||
}
|
||||
@@ -236,8 +236,9 @@ add_objfile_entry (struct objfile *objfile, CORE_ADDR entry,
|
||||
{
|
||||
gdb_assert (objfile->jited_data == nullptr);
|
||||
|
||||
objfile->jited_data.reset (new jited_objfile_data (entry, symfile_addr,
|
||||
symfile_size));
|
||||
objfile->jited_data = std::make_unique<jited_objfile_data> (entry,
|
||||
symfile_addr,
|
||||
symfile_size);
|
||||
}
|
||||
|
||||
/* Helper function for reading the global JIT descriptor from remote
|
||||
|
||||
@@ -63,7 +63,7 @@ osdata_start_osdata (struct gdb_xml_parser *parser,
|
||||
gdb_xml_error (parser, _("Seen more than on osdata element"));
|
||||
|
||||
char *type = (char *) xml_find_attribute (attributes, "type")->value.get ();
|
||||
data->osdata.reset (new struct osdata (std::string (type)));
|
||||
data->osdata = std::make_unique<osdata> (std::string (type));
|
||||
}
|
||||
|
||||
/* Handle the start of a <item> element. */
|
||||
|
||||
@@ -100,7 +100,7 @@ void
|
||||
parser_state::mark_struct_expression (expr::structop_base_operation *op)
|
||||
{
|
||||
gdb_assert (parse_completion && m_completion_state == nullptr);
|
||||
m_completion_state.reset (new expr_complete_structop (op));
|
||||
m_completion_state = std::make_unique<expr_complete_structop> (op);
|
||||
}
|
||||
|
||||
/* Indicate that the current parser invocation is completing a tag.
|
||||
|
||||
@@ -244,13 +244,13 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
|
||||
switch (what_to_dump)
|
||||
{
|
||||
case regcache_dump_none:
|
||||
dump.reset (new register_dump_none (gdbarch));
|
||||
dump = std::make_unique<register_dump_none> (gdbarch);
|
||||
break;
|
||||
case regcache_dump_remote:
|
||||
dump.reset (new register_dump_remote (gdbarch));
|
||||
dump = std::make_unique<register_dump_remote> (gdbarch);
|
||||
break;
|
||||
case regcache_dump_groups:
|
||||
dump.reset (new register_dump_groups (gdbarch));
|
||||
dump = std::make_unique<register_dump_groups> (gdbarch);
|
||||
break;
|
||||
case regcache_dump_raw:
|
||||
case regcache_dump_cooked:
|
||||
@@ -258,15 +258,15 @@ regcache_print (const char *args, enum regcache_dump_what what_to_dump)
|
||||
auto dump_pseudo = (what_to_dump == regcache_dump_cooked);
|
||||
|
||||
if (target_has_registers ())
|
||||
dump.reset (new register_dump_regcache (get_thread_regcache
|
||||
(inferior_thread ()),
|
||||
dump_pseudo));
|
||||
dump = (std::make_unique<register_dump_regcache>
|
||||
(get_thread_regcache (inferior_thread ()), dump_pseudo));
|
||||
else
|
||||
{
|
||||
/* For the benefit of "maint print registers" & co when
|
||||
debugging an executable, allow dumping a regcache even when
|
||||
there is no thread selected / no registers. */
|
||||
dump.reset (new register_dump_reg_buffer (gdbarch, dump_pseudo));
|
||||
dump = std::make_unique<register_dump_reg_buffer> (gdbarch,
|
||||
dump_pseudo);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3049,7 +3049,7 @@ get_remote_thread_info (thread_info *thread)
|
||||
gdb_assert (thread != NULL);
|
||||
|
||||
if (thread->priv == NULL)
|
||||
thread->priv.reset (new remote_thread_info);
|
||||
thread->priv = std::make_unique<remote_thread_info> ();
|
||||
|
||||
return gdb::checked_static_cast<remote_thread_info *> (thread->priv.get ());
|
||||
}
|
||||
@@ -7099,7 +7099,7 @@ static remote_inferior *
|
||||
get_remote_inferior (inferior *inf)
|
||||
{
|
||||
if (inf->priv == NULL)
|
||||
inf->priv.reset (new remote_inferior);
|
||||
inf->priv = std::make_unique<remote_inferior> ();
|
||||
|
||||
return gdb::checked_static_cast<remote_inferior *> (inf->priv.get ());
|
||||
}
|
||||
|
||||
@@ -562,10 +562,10 @@ whatis_exp (const char *exp, int show)
|
||||
std::unique_ptr<ext_lang_type_printers> printer_holder;
|
||||
if (!flags.raw)
|
||||
{
|
||||
table_holder.reset (new typedef_hash_table);
|
||||
table_holder = std::make_unique<typedef_hash_table> ();
|
||||
flags.global_typedefs = table_holder.get ();
|
||||
|
||||
printer_holder.reset (new ext_lang_type_printers);
|
||||
printer_holder = std::make_unique<ext_lang_type_printers> ();
|
||||
flags.global_printers = printer_holder.get ();
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ ui_out::table_begin (int nr_cols, int nr_rows, const std::string &tblid)
|
||||
internal_error (_("tables cannot be nested; table_begin found before \
|
||||
previous table_end."));
|
||||
|
||||
m_table_up.reset (new ui_out_table (level () + 1, nr_cols, tblid));
|
||||
m_table_up = std::make_unique<ui_out_table> (level () + 1, nr_cols, tblid);
|
||||
|
||||
do_table_begin (nr_cols, nr_rows, tblid.c_str ());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user