From e947a8482ac8ea529869c15b6949e4f19272c747 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 23 Sep 2020 09:32:54 -0600 Subject: Introduce and use compile_module_up This introduces compile_module_up, a unique pointer for compile_module, and changes a few spots to use it. gdb/ChangeLog 2020-09-23 Tom Tromey * compile/compile.c (eval_compile_command): Update. * compile/compile-object-run.h (compile_object_run): Take a compile_module_up. * compile/compile-object-run.c (compile_object_run): Take a compile_module_up. * compile/compile-object-load.h (struct compile_module): Add constructor, destructor. (compile_module_up): New typedef. (compile_object_load): Return compile_object_up. * compile/compile-object-load.c (compile_object_load): Return compile_module_up. --- gdb/compile/compile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gdb/compile/compile.c') diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 8d8c2b1..6e8ec40 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -820,14 +820,13 @@ void eval_compile_command (struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, void *scope_data) { - struct compile_module *compile_module; - compile_file_names fnames = compile_to_object (cmd, cmd_string, scope); gdb::unlinker object_remover (fnames.object_file ()); gdb::unlinker source_remover (fnames.source_file ()); - compile_module = compile_object_load (fnames, scope, scope_data); + compile_module_up compile_module = compile_object_load (fnames, scope, + scope_data); if (compile_module == NULL) { gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE); @@ -840,7 +839,7 @@ eval_compile_command (struct command_line *cmd, const char *cmd_string, source_remover.keep (); object_remover.keep (); - compile_object_run (compile_module); + compile_object_run (std::move (compile_module)); } /* See compile/compile-internal.h. */ -- cgit v1.1