Add another constructor to scoped_restore_current_language

While working on something else, I noticed that this is relatively
common:

  scoped_restore_current_language save;
  set_language (something);

This patch adds a second constructor to
scoped_restore_current_language to simplify this idiom.

Reviewed-By: Tom de Vries <tdevries@suse.de>
This commit is contained in:
Tom Tromey
2024-08-14 11:22:58 -06:00
parent 5c8f918639
commit d47600c85d
6 changed files with 16 additions and 14 deletions

View File

@@ -3734,8 +3734,7 @@ create_std_terminate_master_breakpoint (void)
const char *const func_name = "std::terminate()";
scoped_restore_current_program_space restore_pspace;
scoped_restore_current_language save_language;
set_language (language_cplus);
scoped_restore_current_language save_language (language_cplus);
for (struct program_space *pspace : program_spaces)
{