]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Use c++17 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>
Fri, 13 Oct 2023 13:51:13 +0000 (13:51 +0000)
gdb::make_unique is a wrapper around std::make_unique when compiled with
c++17.  Now that 17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab

20 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/ui-out.c
gdb/unittests/parallel-for-selftests.c
gdb/varobj.c
gdbsupport/gdb_unique_ptr.h

index d16775d49d489be921c774905fffdedac78b2f07..757947abaf4f69c6e91800221f952df51f5fe155 100644 (file)
@@ -21,6 +21,7 @@
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
 #include "gdbsupport/selftest.h"
+#include <memory>
 
 /* Make sure splay trees can actually hold the values we want to
    store in them.  */
@@ -428,7 +429,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 94d8b420d32725cefe28e7aa3c11680a36ad8832..cac914d3face8e4a0d4f7dc8985553dd47925b14 100644 (file)
@@ -28,6 +28,7 @@
 #include "solist.h"
 #include "target.h"
 #include "valprint.h"
+#include <memory>
 
 /* An instance of this type is used to represent an solib catchpoint.
    A breakpoint is really of this type iff its ops pointer points to
@@ -230,7 +231,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..20a7bb4e0d46de16ae7a8a523b4bd968b9bdb899 100644 (file)
@@ -30,6 +30,7 @@
 #include "gdbsupport/gdb-dlfcn.h"
 #include "gdbsupport/preprocessor.h"
 #include "gdbarch.h"
+#include <memory>
 
 /* See compile-internal.h.  */
 
@@ -118,7 +119,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..061882363be509e076ad60b56db42d291425213e 100644 (file)
@@ -45,6 +45,7 @@
 #include "cp-support.h"
 #include "c-support.h"
 #include "parser-defs.h"
+#include <memory>
 
 #define GDB_YY_REMAP_PREFIX cpname
 #include "yy-remap.h"
@@ -2038,7 +2039,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..579f09303c8713ff081ee89e30b1ea5a32e38d09 100644 (file)
@@ -44,6 +44,7 @@
 #include "run-on-main-thread.h"
 #include "typeprint.h"
 #include "inferior.h"
+#include <memory>
 
 #define d_left(dc) (dc)->u.s_binary.left
 #define d_right(dc) (dc)->u.s_binary.right
@@ -675,7 +676,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..6f52a1abe0e2cc49954aba2960491cfe8fabf254 100644 (file)
@@ -49,6 +49,7 @@
 #include <unordered_map>
 
 #include <algorithm>
+#include <memory>
 
 struct comp_unit;
 
@@ -2126,7 +2127,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 2e5067efb3d73ba16997d664b1fb0ebbdf4be36c..535028b1597ce5162d60cdbd31517ff67c92b642 100644 (file)
@@ -26,6 +26,7 @@
 #include "mapped-index.h"
 #include "read.h"
 #include "stringify.h"
+#include <memory>
 
 /* A description of the mapped .debug_names.
    Uninitialized map has CU_COUNT 0.  */
@@ -462,7 +463,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 b96eaa96e23d7fcfc54dff0fb989410f6c7c8052..da3bf0633fcda348897d5b1092876e806bd63e1e 100644 (file)
@@ -27,6 +27,7 @@
 #include "gdbsupport/gdb-checked-static-cast.h"
 #include "mapped-index.h"
 #include "read.h"
+#include <memory>
 
 /* When true, do not reject deprecated .gdb_index sections.  */
 static bool use_deprecated_index_sections = false;
@@ -828,7 +829,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 d4aec19d31db9fd2f1249634800ec40fdfa499b2..5bbf208ed5adc81fb810d4c511be2d0944ef3a72 100644 (file)
@@ -95,6 +95,7 @@
 #include "split-name.h"
 #include "gdbsupport/parallel-for.h"
 #include "gdbsupport/thread-pool.h"
+#include <memory>
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -4535,7 +4536,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 217753cf914ba0f1375e1519ffc54d27ec179768..fc0c5bab6ed168a3a14ffbb4cd2ae24c0acdc51e 100644 (file)
@@ -302,7 +302,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..534b7a2bfa2d5ae279007befb57c0ee7f37f0d50 100644 (file)
@@ -45,6 +45,7 @@
 #include "gmp-utils.h"
 #include "rust-lang.h"
 #include "ada-lang.h"
+#include <memory>
 
 /* The value of an invalid conversion badness.  */
 #define INVALID_CONVERSION 100
@@ -5833,7 +5834,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 944c9116731fc5e24c4ecbe266c0f0eec4643eaa..d750371f91752873d4983cb21b44919335be6f12 100644 (file)
@@ -63,6 +63,7 @@
 #include <algorithm>
 #include <set>
 #include <map>
+#include <memory>
 
 enum
   {
@@ -1933,7 +1934,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..95f8069674c5aaa96492398466f17fed5b98ebda 100644 (file)
@@ -23,6 +23,7 @@
 #include "mi-out.h"
 
 #include <vector>
+#include <memory>
 
 #include "interps.h"
 #include "ui-out.h"
@@ -340,13 +341,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..aa02f193399e7dc15b73a00464ddc28f5157f6b5 100644 (file)
@@ -27,6 +27,7 @@
 #include "gdbsupport/filestuff.h"
 #include "gdbsupport/scoped_fd.h"
 #include "gdbsupport/scoped_mmap.h"
+#include <memory>
 
 #include <inttypes.h>
 
@@ -468,7 +469,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 +618,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..a43fac98c43d5b67a60baddc288b3258e7b5ecd4 100644 (file)
@@ -27,6 +27,7 @@
 #include "mi/mi-parse.h"
 #include "mi/mi-console.h"
 #include "mi/mi-interp.h"
+#include <memory>
 
 /* A ui_out subclass that creates a Python object based on the data
    that is passed in.  */
@@ -290,7 +291,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..f72f1400d1d42d5ea30f121a753d630de1bd3f4f 100644 (file)
@@ -18,6 +18,7 @@
 #include "varobj.h"
 #include "varobj-iter.h"
 #include "valprint.h"
+#include <memory>
 
 /* A dynamic varobj iterator "class" for python pretty-printed
    varobjs.  This inherits struct varobj_iter.  */
@@ -170,5 +171,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 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..5e2f8b5f73541a537369378a999994a8b1099ca5 100644 (file)
@@ -27,6 +27,7 @@
 #include "defs.h"
 #include "gdbsupport/selftest.h"
 #include "gdbsupport/parallel-for.h"
+#include <memory>
 
 #if CXX_STD_THREAD
 
@@ -160,7 +161,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 +179,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..5d1ae343fcabdac51c25df85adeafd38d6fe8e74 100644 (file)
@@ -33,6 +33,7 @@
 #include "gdbarch.h"
 #include <algorithm>
 #include "observable.h"
+#include <memory>
 
 #if HAVE_PYTHON
 #include "python/python.h"
@@ -259,7 +260,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.  */