Use scoped_restore in more places

This changes a few more places to use scoped_restore, allowing some
cleanup removals.

gdb/ChangeLog
2017-04-12  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (exec_direction_forward): Remove.
	(exec_reverse_continue, mi_execute_command): Use scoped_restore.
	* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
	scoped_restore.
	* guile/guile.c (guile_repl_command, guile_command)
	(gdbscm_execute_gdb_command): Use scoped_restore.
	* go-exp.y (go_parse): Use scoped_restore.
	* d-exp.y (d_parse): Use scoped_restore.
	* cli/cli-decode.c (cmd_func): Use scoped_restore.
	* c-exp.y (c_parse): Use scoped_restore.
This commit is contained in:
Tom Tromey 2017-04-07 15:37:25 -06:00
parent 4d89769a7b
commit 156d9eab86
8 changed files with 36 additions and 51 deletions

View file

@ -23,6 +23,7 @@
#include "ui-out.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
#include "common/gdb_optional.h"
/* Prototypes for local functions. */
@ -1878,17 +1879,12 @@ cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
{
if (cmd_func_p (cmd))
{
struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
if (cmd->suppress_notification != NULL)
{
make_cleanup_restore_integer (cmd->suppress_notification);
*cmd->suppress_notification = 1;
}
restore_suppress.emplace (cmd->suppress_notification, 1);
(*cmd->func) (cmd, args, from_tty);
do_cleanups (cleanups);
}
else
error (_("Invalid command"));