Remove make_cleanup_clear_parser_state

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.
This commit is contained in:
Tom Tromey 2017-08-13 10:37:13 -06:00
parent 73b9be8b53
commit eae49211e1
10 changed files with 23 additions and 50 deletions

View 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.

View 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

View 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;

View 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;

View 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

View 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;

View 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

View 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

View 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

View 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);