diff options
author | Tom Tromey <tom@tromey.com> | 2018-02-06 01:02:00 +0100 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-02-08 11:46:55 -0700 |
commit | f6c2623eb8ac7296b6d7a76657394272a71f5aee (patch) | |
tree | 7a83749c7e88dc681929f784c2896dc369aa2d1a /gdb/c-exp.y | |
parent | 8ce47547b34fddec16d1ccd801f025a56976af95 (diff) | |
download | gdb-f6c2623eb8ac7296b6d7a76657394272a71f5aee.zip gdb-f6c2623eb8ac7296b6d7a76657394272a71f5aee.tar.gz gdb-f6c2623eb8ac7296b6d7a76657394272a71f5aee.tar.bz2 |
Return unique_xmalloc_ptr from macro scope functions
This changes the macro scope functions (sal_macro_scope,
user_macro_scope, and default_macro_scope) to return a
unique_xmalloc_ptr, then fixes up the users. This allowed for the
removal of several cleanups.
2018-02-08 Tom Tromey <tom@tromey.com>
* symtab.c (default_collect_symbol_completion_matches_break_on):
Use unique_xmalloc_ptr.
* macroscope.h: (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroscope.c (sal_macro_scope, user_macro_scope)
(default_macro_scope): Return unique_xmalloc_ptr.
* macroexp.h (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macroexp.c (macro_expand, macro_expand_once): Return
unique_xmalloc_ptr.
* macrocmd.c (macro_expand_command, macro_expand_once_command)
(info_macro_command, info_macros_command): Use
unique_xmalloc_ptr.
* compile/compile-c-support.c (write_macro_definitions): Use
unique_xmalloc_ptr.
* c-exp.y (c_parse): Use unique_xmalloc_ptr.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r-- | gdb/c-exp.y | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8f0aa00..8dc3c06 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -3220,26 +3220,24 @@ c_parse (struct parser_state *par_state) gdb_assert (par_state != NULL); pstate = par_state; - /* Note that parsing (within yyparse) freely installs cleanups - assuming they'll be run here (below). */ - - back_to = make_cleanup (free_current_contents, &expression_macro_scope); - - /* Set up the scope for macro expansion. */ - expression_macro_scope = NULL; + gdb::unique_xmalloc_ptr<struct macro_scope> macro_scope; if (expression_context_block) - expression_macro_scope - = sal_macro_scope (find_pc_line (expression_context_pc, 0)); + macro_scope = sal_macro_scope (find_pc_line (expression_context_pc, 0)); else - expression_macro_scope = default_macro_scope (); - if (! expression_macro_scope) - expression_macro_scope = user_macro_scope (); + macro_scope = default_macro_scope (); + if (! macro_scope) + macro_scope = user_macro_scope (); + + scoped_restore restore_macro_scope + = make_scoped_restore (&expression_macro_scope, macro_scope.get ()); /* Initialize macro expansion code. */ obstack_init (&expansion_obstack); gdb_assert (! macro_original_text); - make_cleanup (scan_macro_cleanup, 0); + /* Note that parsing (within yyparse) freely installs cleanups + assuming they'll be run here (below). */ + back_to = make_cleanup (scan_macro_cleanup, 0); scoped_restore restore_yydebug = make_scoped_restore (&yydebug, parser_debug); |