Skip to content

Commit 43048e4

Browse files
committed
Remove evaluate_expression
evaluate_expression is just a little wrapper for a method on expression. Removing it also removes a lot of ugly (IMO) calls to get().
1 parent b785bb6 commit 43048e4

18 files changed

+34
-52
lines changed

gdb/ada-lang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,7 +4339,7 @@ ada_read_renaming_var_value (struct symbol *renaming_sym,
43394339

43404340
sym_name = renaming_sym->linkage_name ();
43414341
expression_up expr = parse_exp_1 (&sym_name, 0, block, 0);
4342-
return evaluate_expression (expr.get ());
4342+
return expr->evaluate ();
43434343
}
43444344

43454345

@@ -12318,7 +12318,7 @@ should_stop_exception (const struct bp_location *bl)
1231812318
try
1231912319
{
1232012320
scoped_value_mark mark;
12321-
stop = value_true (evaluate_expression (ada_loc->excep_cond_expr.get ()));
12321+
stop = value_true (ada_loc->excep_cond_expr->evaluate ());
1232212322
}
1232312323
catch (const gdb_exception_error &ex)
1232412324
{

gdb/arc-tdep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,7 @@ dump_arc_instruction_command (const char *args, int from_tty)
24342434
{
24352435
struct value *val;
24362436
if (args != NULL && strlen (args) > 0)
2437-
val = evaluate_expression (parse_expression (args).get ());
2437+
val = parse_expression (args)->evaluate ();
24382438
else
24392439
val = access_value_history (0);
24402440
val->record_latest ();

gdb/breakpoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4984,7 +4984,7 @@ static bool
49844984
breakpoint_cond_eval (expression *exp)
49854985
{
49864986
scoped_value_mark mark;
4987-
return value_true (evaluate_expression (exp));
4987+
return value_true (exp->evaluate ());
49884988
}
49894989

49904990
/* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */

gdb/cli/cli-script.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
567567
/* Evaluate the expression. */
568568
{
569569
scoped_value_mark mark;
570-
value *val = evaluate_expression (expr.get ());
570+
value *val = expr->evaluate ();
571571
cond_result = value_true (val);
572572
}
573573

@@ -622,7 +622,7 @@ execute_control_command_1 (struct command_line *cmd, int from_tty)
622622
/* Evaluate the conditional. */
623623
{
624624
scoped_value_mark mark;
625-
value *val = evaluate_expression (expr.get ());
625+
value *val = expr->evaluate ();
626626

627627
/* Choose which arm to take commands from based on the value
628628
of the conditional expression. */

gdb/darwin-nat-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ info_mach_region_command (const char *exp, int from_tty)
723723
struct inferior *inf;
724724

725725
expression_up expr = parse_expression (exp);
726-
val = evaluate_expression (expr.get ());
726+
val = expr->evaluate ();
727727
if (TYPE_IS_REFERENCE (val->type ()))
728728
{
729729
val = value_ind (val);

gdb/dtrace-probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ dtrace_probe::evaluate_argument (unsigned n,
714714
struct dtrace_probe_arg *arg;
715715

716716
arg = this->get_arg_by_number (n, gdbarch);
717-
return evaluate_expression (arg->expr.get (), arg->type);
717+
return arg->expr->evaluate (arg->type);
718718
}
719719

720720
/* Implementation of the compile_to_ax method. */

gdb/eval.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ parse_and_eval_address (const char *exp)
5353
{
5454
expression_up expr = parse_expression (exp);
5555

56-
return value_as_address (evaluate_expression (expr.get ()));
56+
return value_as_address (expr->evaluate ());
5757
}
5858

5959
/* Like parse_and_eval_address, but treats the value of the expression
@@ -63,15 +63,15 @@ parse_and_eval_long (const char *exp)
6363
{
6464
expression_up expr = parse_expression (exp);
6565

66-
return value_as_long (evaluate_expression (expr.get ()));
66+
return value_as_long (expr->evaluate ());
6767
}
6868

6969
struct value *
7070
parse_and_eval (const char *exp)
7171
{
7272
expression_up expr = parse_expression (exp);
7373

74-
return evaluate_expression (expr.get ());
74+
return expr->evaluate ();
7575
}
7676

7777
/* Parse up to a comma (or to a closeparen)
@@ -83,7 +83,7 @@ parse_to_comma_and_eval (const char **expp)
8383
{
8484
expression_up expr = parse_exp_1 (expp, 0, nullptr, 1);
8585

86-
return evaluate_expression (expr.get ());
86+
return expr->evaluate ();
8787
}
8888

8989

@@ -116,14 +116,6 @@ expression::evaluate (struct type *expect_type, enum noside noside)
116116
return retval;
117117
}
118118

119-
/* See value.h. */
120-
121-
struct value *
122-
evaluate_expression (struct expression *exp, struct type *expect_type)
123-
{
124-
return exp->evaluate (expect_type, EVAL_NORMAL);
125-
}
126-
127119
/* Evaluate an expression, avoiding all memory references
128120
and getting a value whose type alone is correct. */
129121

gdb/expression.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ struct expression
222222
/* Evaluate the expression. EXPECT_TYPE is the context type of the
223223
expression; normally this should be nullptr. NOSIDE controls how
224224
evaluation is performed. */
225-
struct value *evaluate (struct type *expect_type, enum noside noside);
225+
struct value *evaluate (struct type *expect_type = nullptr,
226+
enum noside noside = EVAL_NORMAL);
226227

227228
/* Language it was entered in. */
228229
const struct language_defn *language_defn;

gdb/linux-thread-db.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ check_thread_db_callback (const td_thrhandle_t *th, void *arg)
694694
switch_to_thread (thread_info);
695695

696696
expression_up expr = parse_expression ("(int) errno");
697-
struct value *val = evaluate_expression (expr.get ());
697+
struct value *val = expr->evaluate ();
698698

699699
if (tdb_testinfo->log_progress)
700700
{

gdb/mi/mi-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ mi_cmd_data_evaluate_expression (const char *command, char **argv, int argc)
11891189

11901190
expression_up expr = parse_expression (argv[0]);
11911191

1192-
val = evaluate_expression (expr.get ());
1192+
val = expr->evaluate ();
11931193

11941194
string_file stb;
11951195

@@ -2468,7 +2468,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
24682468
if (values == PRINT_SIMPLE_VALUES)
24692469
val = evaluate_type (expr.get ());
24702470
else
2471-
val = evaluate_expression (expr.get ());
2471+
val = expr->evaluate ();
24722472

24732473
gdb::optional<ui_out_emit_tuple> tuple_emitter;
24742474
if (values != PRINT_NO_VALUES)

0 commit comments

Comments
 (0)