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:
Tom Tromey
2021-02-05 07:17:11 -07:00
parent 1b30f42106
commit bdfea17ea9
7 changed files with 47 additions and 31 deletions

View File

@ -374,18 +374,14 @@ struct language_defn
symbol_name_matcher_ftype *get_symbol_name_matcher
(const lookup_name_info &lookup_name) const;
/* If this language allows compilation from the gdb command line, then
this method will return an instance of struct gcc_context appropriate
to the language. If compilation for this language is generally
supported, but something goes wrong then an exception is thrown. The
returned compiler instance is owned by its caller and must be
deallocated by the caller. If compilation is not supported for this
language then this method returns NULL. */
/* If this language allows compilation from the gdb command line,
then this method will return an instance of struct gcc_context
appropriate to the language. If compilation for this language is
generally supported, but something goes wrong then an exception
is thrown. If compilation is not supported for this language
then this method returns NULL. */
virtual compile_instance *get_compile_instance () const
{
return nullptr;
}
virtual std::unique_ptr<compile_instance> get_compile_instance () const;
/* This method must be overridden if 'get_compile_instance' is
overridden.