]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove make_cleanup_clear_parser_state
authorTom Tromey <tom@tromey.com>
Sun, 13 Aug 2017 16:37:13 +0000 (10:37 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 6 Sep 2017 21:49:30 +0000 (15:49 -0600)
This removes make_cleanup_clear_parser_state in favor of
scoped_restore.

2017-09-05  Tom Tromey  <tom@tromey.com>

* utils.c (do_clear_parser_state): Remove.
(make_cleanup_clear_parser_state): Remove.
* p-exp.y (pascal_parse): Use scoped_restore.
* m2-exp.y (m2_parse): Use scoped_restore.
* f-exp.y (f_parse): Use scoped_restore.
* d-exp.y (d_parse): Use scoped_restore.
* c-exp.y (c_parse): Use scoped_restore.
* ada-exp.y (ada_parse): Use scoped_restore.
* utils.h (make_cleanup_clear_parser_state): Remove.

gdb/ChangeLog
gdb/ada-exp.y
gdb/c-exp.y
gdb/d-exp.y
gdb/f-exp.y
gdb/go-exp.y
gdb/m2-exp.y
gdb/p-exp.y
gdb/utils.c
gdb/utils.h

index 8080a55078e50d6b498a3a8cee3e41895228e9b6..f3610239b2740454c7a9a05819e3ae9cf44d6010 100644 (file)
@@ -1,3 +1,15 @@
+2017-09-05  Tom Tromey  <tom@tromey.com>
+
+       * utils.c (do_clear_parser_state): Remove.
+       (make_cleanup_clear_parser_state): Remove.
+       * p-exp.y (pascal_parse): Use scoped_restore.
+       * m2-exp.y (m2_parse): Use scoped_restore.
+       * f-exp.y (f_parse): Use scoped_restore.
+       * d-exp.y (d_parse): Use scoped_restore.
+       * c-exp.y (c_parse): Use scoped_restore.
+       * ada-exp.y (ada_parse): Use scoped_restore.
+       * utils.h (make_cleanup_clear_parser_state): Remove.
+
 2017-09-06  Keith Seitz  <keiths@redhat.com>
 
        * dwarf2read.c (dw2_linkage_name_attr): New function.
index 1eea4546706a7e90535c42c6619063f7dea06b54..618c9d540e925a1b2aecc0fc84f9efca1562a8db 100644 (file)
@@ -733,10 +733,8 @@ static struct obstack temp_parse_space;
 int
 ada_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -745,9 +743,7 @@ ada_parse (struct parser_state *par_state)
   obstack_free (&temp_parse_space, NULL);
   obstack_init (&temp_parse_space);
 
-  result = yyparse ();
-  do_cleanups (c);
-  return result;
+  return yyparse ();
 }
 
 void
index bcc3e12dfc559679188be091055528c58f5db524..43af80cb19f33188ef3163e10be7ee647888ef86 100644 (file)
@@ -3232,6 +3232,7 @@ c_parse (struct parser_state *par_state)
   struct cleanup *back_to;
 
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -3239,7 +3240,6 @@ c_parse (struct parser_state *par_state)
      assuming they'll be run here (below).  */
 
   back_to = make_cleanup (free_current_contents, &expression_macro_scope);
-  make_cleanup_clear_parser_state (&pstate);
 
   /* Set up the scope for macro expansion.  */
   expression_macro_scope = NULL;
index d392a5cb2ef510bec4f81b244187309718e198ff..9b773c65441b710bd3ad1bc72c5923206ed3e14b 100644 (file)
@@ -1624,6 +1624,7 @@ d_parse (struct parser_state *par_state)
   struct cleanup *back_to;
 
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -1633,7 +1634,6 @@ d_parse (struct parser_state *par_state)
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
                                                        parser_debug);
-  make_cleanup_clear_parser_state (&pstate);
 
   /* Initialize some state used by the lexer.  */
   last_was_structop = 0;
index 7e9e234bf68fc309f85726dfcbe83fd12f69d52c..8dcc811b6816f8af5a318d9047a9a52559f3d942 100644 (file)
@@ -1206,16 +1206,12 @@ yylex (void)
 int
 f_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
-  result = yyparse ();
-  do_cleanups (c);
-  return result;
+  return yyparse ();
 }
 
 void
index f2f359609cd783b40f73f329619d674c585dbe3e..098e7340fcd9b41f5c83151ecd7ccb7aec83a2ef 100644 (file)
@@ -1564,6 +1564,7 @@ go_parse (struct parser_state *par_state)
   struct cleanup *back_to;
 
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
@@ -1573,7 +1574,6 @@ go_parse (struct parser_state *par_state)
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
                                                        parser_debug);
-  make_cleanup_clear_parser_state (&pstate);
 
   /* Initialize some state used by the lexer.  */
   last_was_structop = 0;
index 9179187aa20e2125d774e04480835896bf38a56f..02dc36f48036e882fbfdb4e3f223abf3864934b0 100644 (file)
@@ -1036,17 +1036,12 @@ yylex (void)
 int
 m2_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
-  result = yyparse ();
-  do_cleanups (c);
-
-  return result;
+  return yyparse ();
 }
 
 void
index 81eb2162589678c2205fbec94881610a38eeb756..eee4fa94b3acd02500296d385d746fc903d17ad0 100644 (file)
@@ -1701,16 +1701,12 @@ yylex (void)
 int
 pascal_parse (struct parser_state *par_state)
 {
-  int result;
-  struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
-
   /* Setting up the parser state.  */
+  scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
 
-  result = yyparse ();
-  do_cleanups (c);
-  return result;
+  return yyparse ();
 }
 
 void
index af50cf09d6a07f3b415f7dbbb556a1d141623642..f2da2df60f56c8f533e120f133408204350299df 100644 (file)
@@ -257,24 +257,6 @@ make_cleanup_value_free (struct value *value)
   return make_cleanup (do_value_free, value);
 }
 
-/* Helper function for make_cleanup_clear_parser_state.  */
-
-static void
-do_clear_parser_state (void *ptr)
-{
-  struct parser_state **p = (struct parser_state **) ptr;
-
-  *p = NULL;
-}
-
-/* Clean (i.e., set to NULL) the parser state variable P.  */
-
-struct cleanup *
-make_cleanup_clear_parser_state (struct parser_state **p)
-{
-  return make_cleanup (do_clear_parser_state, (void *) p);
-}
-
 /* This function is useful for cleanups.
    Do
 
index 3ceefc1dc6c4c6011ee7511b741d48260c2c455a..1c8b95cd2ebe3dcd8623d6db2c6ae08a0f297a67 100644 (file)
@@ -236,10 +236,6 @@ struct htab_deleter
 /* A unique_ptr wrapper for htab_t.  */
 typedef std::unique_ptr<htab, htab_deleter> htab_up;
 
-struct parser_state;
-extern struct cleanup *make_cleanup_clear_parser_state
-  (struct parser_state **p);
-
 extern void free_current_contents (void *);
 
 extern void init_page_info (void);