aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests
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/unittests
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/unittests')
-rw-r--r--gdb/unittests/parallel-for-selftests.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c
index 15a095a..1ad7eaa 100644
--- a/gdb/unittests/parallel-for-selftests.c
+++ b/gdb/unittests/parallel-for-selftests.c
@@ -160,7 +160,7 @@ TEST (int n_threads)
{
if (start == end)
any_empty_tasks = true;
- return std::unique_ptr<int> (new int (end - start));
+ return gdb::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 std::unique_ptr<int> (new int (end - start));
+ return gdb::make_unique<int> (end - start);
},
task_size_one);
SELF_CHECK (!any_empty_tasks);