From: Tom Tromey Date: Sat, 23 Mar 2019 15:43:49 +0000 (-0600) Subject: Use scoped_restore_current_language in two places X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9bb9b2f9d6d5aa90f579494d8407375a87a9ad0b;p=binutils-gdb.git Use scoped_restore_current_language in two places I found a couple of spots that manually saved and restored the current language. This patch changes them to use scoped_restore_current_language. Tested by the buildbot. gdb/ChangeLog 2019-03-23 Tom Tromey * linespec.c (get_current_search_block): Use scoped_restore_current_language. * symmisc.c (dump_symtab): Use scoped_restore_current_language. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 798bcc41424..8088b75758a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-03-23 Tom Tromey + + * linespec.c (get_current_search_block): Use + scoped_restore_current_language. + * symmisc.c (dump_symtab): Use scoped_restore_current_language. + 2019-03-22 Alan Hayward Jiong Wang diff --git a/gdb/linespec.c b/gdb/linespec.c index e902b11c8e8..8e2ade07c73 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1190,16 +1190,10 @@ iterate_over_all_matching_symtabs static const struct block * get_current_search_block (void) { - const struct block *block; - enum language save_language; - /* get_selected_block can change the current language when there is no selected frame yet. */ - save_language = current_language->la_language; - block = get_selected_block (0); - set_language (save_language); - - return block; + scoped_restore_current_language save_language; + return get_selected_block (0); } /* Iterate over static and global blocks. */ diff --git a/gdb/symmisc.c b/gdb/symmisc.c index cb0b5a52e47..3089c99e232 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -384,13 +384,9 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile) if (symtab->language != language_unknown && symtab->language != language_auto) { - enum language saved_lang; - - saved_lang = set_language (symtab->language); - + scoped_restore_current_language save_lang; + set_language (symtab->language); dump_symtab_1 (symtab, outfile); - - set_language (saved_lang); } else dump_symtab_1 (symtab, outfile);