aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-04-24 13:03:03 -0600
committerTom Tromey <tromey@adacore.com>2023-04-25 11:54:28 -0600
commitfc53c8e02183b61a9df0224de1d7016fb52960ba (patch)
tree9544283bd5820c8acd59a7108ed1051c800299ae
parent8f5cd47bee6c07c33aeda758d8d8db5f81ae03e7 (diff)
downloadgdb-fc53c8e02183b61a9df0224de1d7016fb52960ba.zip
gdb-fc53c8e02183b61a9df0224de1d7016fb52960ba.tar.gz
gdb-fc53c8e02183b61a9df0224de1d7016fb52960ba.tar.bz2
Remove some "goto"s from parse.c
parser_state::push_dollar has some unnecessary "goto"s. Replacing them cleans up the code. Regression tested on x86-64 Fedora 36. Approved-By: Simon Marchi <simon.marchi@efficios.com>
-rw-r--r--gdb/parse.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 0588c06..85a6caf 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;
}