aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2023-08-10 17:57:46 +0100
committerAndrew Burgess <aburgess@redhat.com>2023-08-23 09:50:30 +0100
commit0b72cde372f4ac58d3027e94ac48672a5698d80a (patch)
treecca170156597d2c810e1af924fdfeb2cd8e81c31 /gdb/dwarf2
parentadc5f8b99a9d1ec96b5bf2492ad5516db580839a (diff)
downloadgdb-0b72cde372f4ac58d3027e94ac48672a5698d80a.zip
gdb-0b72cde372f4ac58d3027e94ac48672a5698d80a.tar.gz
gdb-0b72cde372f4ac58d3027e94ac48672a5698d80a.tar.bz2
gdb: add gdb::make_unique function
While GDB is still C++11, lets add a gdb::make_unique template function that can be used to create std::unique_ptr objects, just like the C++14 std::make_unique. If GDB is being compiled with a C++14 compiler then the new gdb::make_unique function will delegate to the std::make_unique. I checked with gcc, and at -O1 and above gdb::make_unique will be optimised away completely in this case. If C++14 (or later) becomes our minimum, then it will be easy enough to go through the code and replace gdb::make_unique with std::make_unique later on. I've make use of this function in all the places I think this can easily be used, though I'm sure I've probably missed some. Should be no user visible changes after this commit. Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/frame.c2
-rw-r--r--gdb/dwarf2/read-debug-names.c2
-rw-r--r--gdb/dwarf2/read-gdb-index.c2
-rw-r--r--gdb/dwarf2/read.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 940a01e..abc8d61 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -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. */
- std::unique_ptr<comp_unit> unit (new comp_unit (objfile));
+ auto unit = gdb::make_unique<comp_unit> (objfile);
if (objfile->separate_debug_objfile_backlink == NULL)
{
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 3d96bf4..2e5067e 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -462,7 +462,7 @@ create_cus_from_debug_names (dwarf2_per_bfd *per_bfd,
bool
dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
{
- std::unique_ptr<mapped_debug_names> map (new mapped_debug_names);
+ auto map = gdb::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;
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 1127643..9bfc530 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -778,7 +778,7 @@ dwarf2_read_gdb_index
if (main_index_contents.empty ())
return 0;
- std::unique_ptr<mapped_gdb_index> map (new mapped_gdb_index);
+ auto map = gdb::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,
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f1d7bfd..eb4cb9b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4535,7 +4535,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)
{
- std::unique_ptr<type_unit_group> tu_group (new type_unit_group);
+ auto tu_group = gdb::make_unique<type_unit_group> ();
tu_group->hash.dwo_unit = cu->dwo_unit;
tu_group->hash.line_sect_off = line_offset_struct;