Return unique_ptr from language_defn::get_compile_context
This changes language_defn::get_compile_context to return a unique_ptr. This makes the ownership transfer clear. gdb/ChangeLog 2021-02-05 Tom Tromey <tom@tromey.com> * compile/compile-c-support.c (get_compile_context) (c_get_compile_context, cplus_get_compile_context): Change return type. * language.c (language_defn::get_compile_instance): New method. * language.h (language_defn::get_compile_instance): Change return type. No longer inline. * c-lang.c (c_language::get_compile_instance): Change return type. (cplus_language::get_compile_instance): Change return type. * c-lang.h (c_get_compile_context, cplus_get_compile_context): Change return type. * compile/compile.c (compile_to_object): Update.
This commit is contained in:
parent
1b30f42106
commit
bdfea17ea9
7 changed files with 47 additions and 31 deletions
|
@ -99,7 +99,7 @@ load_libcompile (const char *fe_libcc, const char *fe_context)
|
|||
|
||||
template <typename INSTTYPE, typename FUNCTYPE, typename CTXTYPE,
|
||||
typename BASE_VERSION_TYPE, typename API_VERSION_TYPE>
|
||||
compile_instance *
|
||||
std::unique_ptr<compile_instance>
|
||||
get_compile_context (const char *fe_libcc, const char *fe_context,
|
||||
BASE_VERSION_TYPE base_version,
|
||||
API_VERSION_TYPE api_version)
|
||||
|
@ -118,12 +118,12 @@ 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 new INSTTYPE (context);
|
||||
return std::unique_ptr<compile_instance> (new INSTTYPE (context));
|
||||
}
|
||||
|
||||
/* A C-language implementation of get_compile_context. */
|
||||
|
||||
compile_instance *
|
||||
std::unique_ptr<compile_instance>
|
||||
c_get_compile_context ()
|
||||
{
|
||||
return get_compile_context
|
||||
|
@ -135,7 +135,7 @@ c_get_compile_context ()
|
|||
|
||||
/* A C++-language implementation of get_compile_context. */
|
||||
|
||||
compile_instance *
|
||||
std::unique_ptr<compile_instance>
|
||||
cplus_get_compile_context ()
|
||||
{
|
||||
return get_compile_context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue