]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Use C++17's std::make_unique instead of gdb::make_unique
authorLancelot Six <lancelot.six@amd.com>
Thu, 14 Sep 2023 11:13:24 +0000 (11:13 +0000)
committerLancelot Six <lancelot.six@amd.com>
Tue, 21 Nov 2023 11:52:35 +0000 (11:52 +0000)
gdb::make_unique is a wrapper around std::make_unique when compiled with
C++17.  Now that C++17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net
26 files changed:
gdb/addrmap.c
gdb/break-catch-load.c
gdb/compile/compile-c-support.c
gdb/cp-name-parser.y
gdb/cp-support.c
gdb/dwarf2/frame.c
gdb/dwarf2/read-debug-names.c
gdb/dwarf2/read-gdb-index.c
gdb/dwarf2/read.c
gdb/gdb_bfd.c
gdb/gdbtypes.c
gdb/mi/mi-main.c
gdb/mi/mi-out.c
gdb/nat/linux-btrace.c
gdb/python/py-mi.c
gdb/python/py-varobj.c
gdb/solib-aix.c
gdb/solib-darwin.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/solib-rocm.c
gdb/solib-svr4.c
gdb/ui-out.c
gdb/unittests/parallel-for-selftests.c
gdb/varobj.c
gdbsupport/gdb_unique_ptr.h

index d16775d49d489be921c774905fffdedac78b2f07..076062a0206a3e2adc896320dc3ec7e6be8d397a 100644 (file)
@@ -428,7 +428,7 @@ test_addrmap ()
 
   /* Create mutable addrmap.  */
   auto_obstack temp_obstack;
-  auto map = gdb::make_unique<struct addrmap_mutable> ();
+  auto map = std::make_unique<struct addrmap_mutable> ();
   SELF_CHECK (map != nullptr);
 
   /* Check initial state.  */
index 02a98b5d30a37426a43fc92f5148876603d9932d..dbf70d8f20493e30afb8901e6047a8927e460ff5 100644 (file)
@@ -230,7 +230,7 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled)
   if (*arg == '\0')
     arg = nullptr;
 
-  auto c = gdb::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
+  auto c = std::make_unique<solib_catchpoint> (gdbarch, is_temp, nullptr,
                                               is_load, arg);
 
   c->enable_state = enabled ? bp_enabled : bp_disabled;
index 53b7285b36616797e58767894e3b41352f36351d..3a3e4d21136c2c515e0109eee8d632ba95d2fb47 100644 (file)
@@ -118,7 +118,7 @@ get_compile_context (const char *fe_libcc, const char *fe_context,
     error (_("The loaded version of GCC does not support the required version "
             "of the API."));
 
-  return gdb::make_unique<INSTTYPE> (context);
+  return std::make_unique<INSTTYPE> (context);
 }
 
 /* A C-language implementation of get_compile_context.  */
index 324166a03ff6d8ef1b925092df1f878e3bf26a8b..e6c8c4c09a9421316159d0e3ae064d7832719246 100644 (file)
@@ -2038,7 +2038,7 @@ cp_demangled_name_to_comp (const char *demangled_name,
 
   state.demangle_info = allocate_info ();
 
-  auto result = gdb::make_unique<demangle_parse_info> ();
+  auto result = std::make_unique<demangle_parse_info> ();
   result->info = state.demangle_info;
 
   if (yyparse (&state))
index e02e859b99abf5ad3a8825e6a8b7a7da4a83d9a3..834c4774755861dda6e9f783549cc9462b7e164f 100644 (file)
@@ -675,7 +675,7 @@ mangled_name_to_comp (const char *mangled_name, int options,
                                              options, memory);
       if (ret)
        {
-         auto info = gdb::make_unique<demangle_parse_info> ();
+         auto info = std::make_unique<demangle_parse_info> ();
          info->tree = ret;
          *demangled_p = NULL;
          return info;
index abc8d6134824cbb06e42cb0b2541d99a78f639dd..d72dd0ad971d1eaad17e7c4c789394057bac731c 100644 (file)
@@ -2126,7 +2126,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
   struct gdbarch *gdbarch = objfile->arch ();
 
   /* Build a minimal decoding of the DWARF2 compilation unit.  */
-  auto unit = gdb::make_unique<comp_unit> (objfile);
+  auto unit = std::make_unique<comp_unit> (objfile);
 
   if (objfile->separate_debug_objfile_backlink == NULL)
     {
index c1b62b38f93ccaed9f9086ae3d454a83e6aaab53..78e0df27314024e9216008b1284619cf5b5db634 100644 (file)
@@ -464,7 +464,7 @@ create_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
 bool
 dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
 {
-  auto map = gdb::make_unique<mapped_debug_names> ();
+  auto map = std::make_unique<mapped_debug_names> ();
   mapped_debug_names dwz_map;
   struct objfile *objfile = per_objfile->objfile;
   dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
index e789e9c26546d6ac2257df23a4e27c57f5d2d41e..064a9f17b0e2d9df6a7b4c0cb50cd92f2922c37f 100644 (file)
@@ -828,7 +828,7 @@ dwarf2_read_gdb_index
   if (main_index_contents.empty ())
     return 0;
 
-  auto map = gdb::make_unique<mapped_gdb_index> ();
+  auto map = std::make_unique<mapped_gdb_index> ();
   if (!read_gdb_index_from_buffer (objfile_name (objfile),
                                   use_deprecated_index_sections,
                                   main_index_contents, map.get (), &cu_list,
index e8ff4d8f29a4cfebe5d53334c1f1336661b26760..2a7fd8f5de5e78d40e7b94cbdc5428fd16071c73 100644 (file)
@@ -4372,7 +4372,7 @@ allocate_type_unit_groups_table ()
 static std::unique_ptr<type_unit_group>
 create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
 {
-  auto tu_group = gdb::make_unique<type_unit_group> ();
+  auto tu_group = std::make_unique<type_unit_group> ();
 
   tu_group->hash.dwo_unit = cu->dwo_unit;
   tu_group->hash.line_sect_off = line_offset_struct;
index 56a4c5ecc914b54a942c55484bd15b4b34f3c8cf..b72821f4c3581c5f167799b220ffec575153bdeb 100644 (file)
@@ -303,7 +303,7 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
                                 const char *target)
 {
   std::unique_ptr<target_buffer> buffer
-    = gdb::make_unique<target_buffer> (addr, size);
+    = std::make_unique<target_buffer> (addr, size);
 
   return gdb_bfd_openr_iovec (buffer->filename (), target,
                              [&] (bfd *nbfd)
index 7011fddd6958ac15a2496e9f1cb397c0b9b3caaf..e424077c1c0f095c8a0890731343a7c297c5be87 100644 (file)
@@ -5833,7 +5833,7 @@ static const struct registry<objfile>::key<fixed_point_type_storage>
 void
 allocate_fixed_point_type_info (struct type *type)
 {
-  auto up = gdb::make_unique<fixed_point_type_info> ();
+  auto up = std::make_unique<fixed_point_type_info> ();
   fixed_point_type_info *info;
 
   if (type->is_objfile_owned ())
index abcd0d392ba11cf3d33c5474d4a4074f82bee287..14ed2a1fae94b835c47f8f0dcedaf1a5bbb1c40e 100644 (file)
@@ -1932,7 +1932,7 @@ mi_execute_command (const char *cmd, int from_tty)
     = gdb::checked_static_cast<mi_interp *> (command_interp ());
   try
     {
-      command = gdb::make_unique<mi_parse> (cmd, &token);
+      command = std::make_unique<mi_parse> (cmd, &token);
     }
   catch (const gdb_exception &exception)
     {
index bbd21287b2878882d91b3d723321f251cef656fa..0bc13f963bc129f1a984c6757a7905a0a8c9e944 100644 (file)
@@ -340,13 +340,13 @@ std::unique_ptr<mi_ui_out>
 mi_out_new (const char *mi_version)
 {
   if (streq (mi_version, INTERP_MI4) ||  streq (mi_version, INTERP_MI))
-    return gdb::make_unique<mi_ui_out> (4);
+    return std::make_unique<mi_ui_out> (4);
 
   if (streq (mi_version, INTERP_MI3))
-    return gdb::make_unique<mi_ui_out> (3);
+    return std::make_unique<mi_ui_out> (3);
 
   if (streq (mi_version, INTERP_MI2))
-    return gdb::make_unique<mi_ui_out> (2);
+    return std::make_unique<mi_ui_out> (2);
 
   return nullptr;
 }
index 3c217daa48869b10a0767d75f0dbdd82f4516835..c0cebbb2f02d15321ba16ed2684311665f2317ae 100644 (file)
@@ -468,7 +468,7 @@ linux_enable_bts (ptid_t ptid, const struct btrace_config_bts *conf)
     error (_("BTS support has been disabled for the target cpu."));
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_BTS;
 
@@ -617,7 +617,7 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
     pid = ptid.pid ();
 
   std::unique_ptr<linux_btrace_target_info> tinfo
-    { gdb::make_unique<linux_btrace_target_info> (ptid) };
+    { std::make_unique<linux_btrace_target_info> (ptid) };
 
   tinfo->conf.format = BTRACE_FORMAT_PT;
 
index a7b4f4fa3cfe7eabfc481c8cd27aa51dfa218684..aaa225da95e4765dae11ffa8d8e7e79713e459a9 100644 (file)
@@ -290,7 +290,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw)
   try
     {
       scoped_restore save_uiout = make_scoped_restore (&current_uiout, &uiout);
-      auto parser = gdb::make_unique<mi_parse> (std::move (mi_command),
+      auto parser = std::make_unique<mi_parse> (std::move (mi_command),
                                                std::move (arg_strings));
       mi_execute_command (parser.get ());
     }
index 98603cec00994bd5315e99fa23dee6d082debeed..3401cf294ace8ce71e72a347a41203dcd443cea3 100644 (file)
@@ -170,5 +170,5 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer,
       error (_("Could not get children iterator"));
     }
 
-  return gdb::make_unique<py_varobj_iter> (var, std::move (iter), opts);
+  return std::make_unique<py_varobj_iter> (var, std::move (iter), opts);
 }
index c8fa865f49df66ce2ccc21029f3c5790fb96f5b9..0fc3a1539739aea04d1d919fd44b79cefb6ad9b0 100644 (file)
@@ -484,7 +484,7 @@ solib_aix_current_sos ()
 
       new_solib->so_original_name = so_name;
       new_solib->so_name = so_name;
-      new_solib->lm_info = gdb::make_unique<lm_info_aix> (info);
+      new_solib->lm_info = std::make_unique<lm_info_aix> (info);
 
       /* Add it to the list.  */
       sos.push_back (*new_solib);
index c18791cd7c2c8a891e9b6f0c196f26a326e4bb41..4819afe88631a233cfa753710d6da9efca688515 100644 (file)
@@ -274,7 +274,7 @@ darwin_current_sos ()
       /* Create and fill the new struct shobj element.  */
       shobj *newobj = new shobj;
 
-      auto li = gdb::make_unique<lm_info_darwin> ();
+      auto li = std::make_unique<lm_info_darwin> ();
 
       newobj->so_name = file_path.get ();
       newobj->so_original_name = newobj->so_name;
index 65bb6251a0e79cff0802086531d21e528a86b9a1..ef561466945dcfb911428eb50566fe20ff1f2aed 100644 (file)
@@ -594,7 +594,7 @@ dsbt_current_sos (void)
            }
 
          shobj *sop = new shobj;
-         auto li = gdb::make_unique<lm_info_dsbt> ();
+         auto li = std::make_unique<lm_info_dsbt> ();
          li->map = loadmap;
          /* Fetch the name.  */
          addr = extract_unsigned_integer (lm_buf.l_name,
index 0897bce2325ad355e69fffc0942278466faf9d63..7ca28982638f872f47b1ea54832acd83045b619c 100644 (file)
@@ -377,7 +377,7 @@ frv_current_sos ()
            }
 
          shobj *sop = new shobj;
-         auto li = gdb::make_unique<lm_info_frv> ();
+         auto li = std::make_unique<lm_info_frv> ();
          li->map = loadmap;
          li->got_value = got_addr;
          li->lm_addr = lm_addr;
index 3a971b3361eb8431e29db39e883c6334c2ae1980..cf56a81a2eef55620d2a3feb4b6d1a2d8ea8929e 100644 (file)
@@ -212,7 +212,7 @@ so_list_from_rocm_sos (const std::vector<rocm_so> &sos)
   for (const rocm_so &so : sos)
     {
       struct shobj *newobj = new struct shobj;
-      newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
+      newobj->lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
 
       newobj->so_name = so.name;
       newobj->so_original_name = so.unique_name;
@@ -725,7 +725,7 @@ rocm_update_solib_list ()
 
       gdb::unique_xmalloc_ptr<char> uri_bytes_holder (uri_bytes);
 
-      lm_info_svr4_up li = gdb::make_unique<lm_info_svr4> ();
+      lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
       li->l_addr = l_addr;
 
       /* Generate a unique name so that code objects with the same URI but
index 8a5ad590f6f9be3614b0442c5174aef0b1d14c09..5882a4e0070fffc853e150f6bb59f41aa4e49140 100644 (file)
@@ -213,7 +213,7 @@ lm_info_read (CORE_ADDR lm_addr)
       type *ptr_type
        = builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
 
-      lm_info = gdb::make_unique<lm_info_svr4> ();
+      lm_info = std::make_unique<lm_info_svr4> ();
       lm_info->lm_addr = lm_addr;
 
       lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset],
@@ -1001,7 +1001,7 @@ so_list_from_svr4_sos (const std::vector<svr4_so> &sos)
 
       newobj->so_name = so.name;
       newobj->so_original_name = so.name;
-      newobj->lm_info = gdb::make_unique<lm_info_svr4> (*so.lm_info);
+      newobj->lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
 
       dst.push_back (*newobj);
     }
@@ -1032,7 +1032,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
   ULONGEST *l_ldp
     = (ULONGEST *) xml_find_attribute (attributes, "l_ld")->value.get ();
 
-  lm_info_svr4_up li = gdb::make_unique<lm_info_svr4> ();
+  lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
   li->lm_addr = *lmp;
   li->l_addr_inferior = *l_addrp;
   li->l_ld = *l_ldp;
@@ -1190,7 +1190,7 @@ svr4_default_sos (svr4_info *info)
     return {};
 
   shobj *newobj = new shobj;
-  auto li = gdb::make_unique<lm_info_svr4> ();
+  auto li = std::make_unique<lm_info_svr4> ();
 
   /* Nothing will ever check the other fields if we set l_addr_p.  */
   li->l_addr = li->l_addr_inferior = info->debug_loader_offset;
index defa8f9dfa4a3bd09536953db50aad4e16b90c19..e8653c6c127880a1402c50250bea233b619148fd 100644 (file)
@@ -236,7 +236,7 @@ void ui_out_table::append_header (int width, ui_align alignment,
     internal_error (_("table header must be specified after table_begin and "
                      "before table_body."));
 
-  auto header = gdb::make_unique<ui_out_hdr> (m_headers.size () + 1,
+  auto header = std::make_unique<ui_out_hdr> (m_headers.size () + 1,
                                              width, alignment,
                                              col_name, col_hdr);
 
@@ -328,7 +328,7 @@ ui_out::current_level () const
 void
 ui_out::push_level (ui_out_type type)
 {
-  auto level = gdb::make_unique<ui_out_level> (type);
+  auto level = std::make_unique<ui_out_level> (type);
 
   m_levels.push_back (std::move (level));
 }
index 1ad7eaa701c6db20f8f0dd741060fadfdddfaeb3..63e9512ea184527ad2ac02961e4fe5375ec8ba45 100644 (file)
@@ -160,7 +160,7 @@ TEST (int n_threads)
              {
                if (start == end)
                  any_empty_tasks = true;
-               return gdb::make_unique<int> (end - start);
+               return std::make_unique<int> (end - start);
              });
   SELF_CHECK (!any_empty_tasks);
   SELF_CHECK (std::all_of (intresults.begin (),
@@ -178,7 +178,7 @@ TEST (int n_threads)
              {
                if (start == end)
                  any_empty_tasks = true;
-               return gdb::make_unique<int> (end - start);
+               return std::make_unique<int> (end - start);
              },
            task_size_one);
   SELF_CHECK (!any_empty_tasks);
index a4fcbffc3116ed246a29e13cab1c98b79e806169..4ea8d0fd9b31a26d7ecd636f873814c75ff3eb11 100644 (file)
@@ -259,7 +259,7 @@ varobj_create (const char *objname,
               const char *expression, CORE_ADDR frame, enum varobj_type type)
 {
   /* Fill out a varobj structure for the (root) variable being constructed.  */
-  auto var = gdb::make_unique<varobj> (new varobj_root);
+  auto var = std::make_unique<varobj> (new varobj_root);
 
   if (expression != NULL)
     {
index 2b6c0ce3d538994d507ca12941d10ea00c4607a4..3bef6ff34d62ecc969c8bc7f53aeb67bb14e3929 100644 (file)
@@ -56,19 +56,6 @@ struct noop_deleter
   void operator() (T *ptr) const { }
 };
 
-/* Create simple std::unique_ptr<T> objects.  */
-
-template<typename T, typename... Arg>
-std::unique_ptr<T>
-make_unique (Arg &&...args)
-{
-#if __cplusplus >= 201402L
-  return std::make_unique<T> (std::forward<Arg> (args)...);
-#else
-  return std::unique_ptr<T> (new T (std::forward<Arg> (args)...));
-#endif /* __cplusplus < 201402L */
-}
-
 } /* namespace gdb */
 
 /* Dup STR and return a unique_xmalloc_ptr for the result.  */