diff options
author | Tom Tromey <tom@tromey.com> | 2025-02-23 16:46:30 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2025-03-07 08:09:29 -0700 |
commit | 8f6ddbfc7dfd24b18d0b2ae2c47212ef85b45068 (patch) | |
tree | 10e4f6c3ee0111cb4d81d59537388845b6af3db6 /gdb | |
parent | 34177f19831dc1740fcf3741f9971254b1d3eb4f (diff) | |
download | binutils-8f6ddbfc7dfd24b18d0b2ae2c47212ef85b45068.zip binutils-8f6ddbfc7dfd24b18d0b2ae2c47212ef85b45068.tar.gz binutils-8f6ddbfc7dfd24b18d0b2ae2c47212ef85b45068.tar.bz2 |
Minor cleanups to cpname_state
This changes cpname_state to have a constructor and some inline
initializers.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/cp-name-parser.y | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 9d0085d..14ee6cf 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -75,19 +75,27 @@ struct cpname_state { + cpname_state (const char *input, demangle_parse_info *info) + : lexptr (input), + prev_lexptr (input), + demangle_info (info) + { } + /* LEXPTR is the current pointer into our lex buffer. PREV_LEXPTR is the start of the last token lexed, only used for diagnostics. ERROR_LEXPTR is the first place an error occurred. GLOBAL_ERRMSG is the first error message encountered. */ - const char *lexptr, *prev_lexptr, *error_lexptr, *global_errmsg; + const char *lexptr, *prev_lexptr; + const char *error_lexptr = nullptr; + const char *global_errmsg = nullptr; demangle_parse_info *demangle_info; /* The parse tree created by the parser is stored here after a successful parse. */ - struct demangle_component *global_result; + struct demangle_component *global_result = nullptr; struct demangle_component *d_grab (); @@ -2018,14 +2026,8 @@ struct std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp (const char *demangled_name, std::string *errmsg) { - cpname_state state; - - state.prev_lexptr = state.lexptr = demangled_name; - state.error_lexptr = NULL; - state.global_errmsg = NULL; - auto result = std::make_unique<demangle_parse_info> (); - state.demangle_info = result.get (); + cpname_state state (demangled_name, result.get ()); if (yyparse (&state)) { |