Use scoped_restore_current_language in two places
authorTom Tromey <tom@tromey.com>
Sat, 23 Mar 2019 15:43:49 +0000 (09:43 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 23 Mar 2019 16:18:15 +0000 (10:18 -0600)
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  <tom@tromey.com>

* linespec.c (get_current_search_block): Use
scoped_restore_current_language.
* symmisc.c (dump_symtab): Use scoped_restore_current_language.

gdb/ChangeLog
gdb/linespec.c
gdb/symmisc.c

index 798bcc4142445f6a62449546a726850b9e46d982..8088b75758a2eadd489b175c1bca2b50fe997787 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-23  Tom Tromey  <tom@tromey.com>
+
+       * 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  <alan.hayward@arm.com>
            Jiong Wang  <jiong.wang@arm.com>
 
index e902b11c8e81bd9c48b639d5a381e112b11fa948..8e2ade07c73adcb7dbe063f65cf6355efe8d0f40 100644 (file)
@@ -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.  */
index cb0b5a52e47ef123357384402287cc7c3d8b644c..3089c99e2321c6db46f5add3bab80f80163fe6fe 100644 (file)
@@ -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);