diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-08-10 17:57:46 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-08-23 09:50:30 +0100 |
commit | 0b72cde372f4ac58d3027e94ac48672a5698d80a (patch) | |
tree | cca170156597d2c810e1af924fdfeb2cd8e81c31 /gdb/compile | |
parent | adc5f8b99a9d1ec96b5bf2492ad5516db580839a (diff) | |
download | binutils-0b72cde372f4ac58d3027e94ac48672a5698d80a.zip binutils-0b72cde372f4ac58d3027e94ac48672a5698d80a.tar.gz binutils-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/compile')
-rw-r--r-- | gdb/compile/compile-c-support.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c index f9b3220..53b7285 100644 --- a/gdb/compile/compile-c-support.c +++ b/gdb/compile/compile-c-support.c @@ -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 std::unique_ptr<compile_instance> (new INSTTYPE (context)); + return gdb::make_unique<INSTTYPE> (context); } /* A C-language implementation of get_compile_context. */ |