From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Remove some "goto"s from parse.c
Date: Mon, 24 Apr 2023 13:04:03 -0600 [thread overview]
Message-ID: <20230424190403.1550146-1-tromey@adacore.com> (raw)
parser_state::push_dollar has some unnecessary "goto"s. Replacing
them cleans up the code. Regression tested on x86-64 Fedora 36.
---
gdb/parse.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/gdb/parse.c b/gdb/parse.c
index 0588c0618c6..85a6caf14ba 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -268,7 +268,8 @@ parser_state::push_dollar (struct stoken str)
{
/* Just dollars (one or two). */
i = -negate;
- goto handle_last;
+ push_new<expr::last_operation> (i);
+ return;
}
/* Is the rest of the token digits? */
for (; i < str.length; i++)
@@ -279,7 +280,8 @@ parser_state::push_dollar (struct stoken str)
i = atoi (str.ptr + 1 + negate);
if (negate)
i = -i;
- goto handle_last;
+ push_new<expr::last_operation> (i);
+ return;
}
/* Handle tokens that refer to machine registers:
@@ -287,7 +289,14 @@ parser_state::push_dollar (struct stoken str)
i = user_reg_map_name_to_regnum (gdbarch (),
str.ptr + 1, str.length - 1);
if (i >= 0)
- goto handle_register;
+ {
+ str.length--;
+ str.ptr++;
+ push_new<expr::register_operation> (copy_name (str));
+ block_tracker->update (expression_context_block,
+ INNERMOST_BLOCK_FOR_REGISTERS);
+ return;
+ }
/* Any names starting with $ are probably debugger internal variables. */
@@ -319,17 +328,6 @@ parser_state::push_dollar (struct stoken str)
push_new<expr::internalvar_operation>
(create_internalvar (copy.c_str () + 1));
- return;
-handle_last:
- push_new<expr::last_operation> (i);
- return;
-handle_register:
- str.length--;
- str.ptr++;
- push_new<expr::register_operation> (copy_name (str));
- block_tracker->update (expression_context_block,
- INNERMOST_BLOCK_FOR_REGISTERS);
- return;
}
\f
--
2.39.1
next reply other threads:[~2023-04-24 19:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-24 19:04 Tom Tromey [this message]
2023-04-24 19:33 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230424190403.1550146-1-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).