diff options
author | Tom Tromey <tromey@adacore.com> | 2021-04-15 10:05:00 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-04-15 10:05:00 -0600 |
commit | 9e5e03df52968b416e09a59482409abfed9727c0 (patch) | |
tree | f7b84a83f5c0aa2f636927ef25efed33604c3f13 /gdb/eval.c | |
parent | 4c79248a46100016e902f1489ce1c38a42608460 (diff) | |
download | gdb-9e5e03df52968b416e09a59482409abfed9727c0.zip gdb-9e5e03df52968b416e09a59482409abfed9727c0.tar.gz gdb-9e5e03df52968b416e09a59482409abfed9727c0.tar.bz2 |
Use block_symbol in var_value_operation
I noticed that var_value_operation takes a block and a symbol, and
most callers destructure a block_symbol to pass in. It seems better
for this class to simply hold a block_symbol instead.
Tested on x86-64 Fedora 32.
gdb/ChangeLog
2021-04-15 Tom Tromey <tromey@adacore.com>
* rust-exp.y (rust_parser::convert_ast_to_expression): Update.
* parse.c (parser_state::push_symbol, parser_state::push_dollar):
Update.
* p-exp.y (variable): Update.
* m2-exp.y (variable): Update.
* go-exp.y (variable): Update.
* expprint.c (dump_for_expression): New overload.
* expop.h (check_objfile): New overload.
(check_constant): New overload.
(class var_value_operation): Use block_symbol.
<get_symbol>: Rewrite.
* eval.c (var_value_operation::evaluate)
(var_value_operation::evaluate_funcall)
(var_value_operation::evaluate_for_address)
(var_value_operation::evaluate_for_address)
(var_value_operation::evaluate_with_coercion)
(var_value_operation::evaluate_for_sizeof)
(var_value_operation::evaluate_for_cast): Update.
* d-exp.y (PrimaryExpression): Update.
* c-exp.y (variable): Update.
* ax-gdb.c (var_value_operation::do_generate_ax): Update.
* ada-lang.c (ada_var_value_operation::evaluate_for_cast)
(ada_var_value_operation::evaluate)
(ada_var_value_operation::resolve)
(ada_funcall_operation::resolve): Update.
* ada-exp.y (write_var_from_sym, write_object_renaming)
(write_ambiguous_var, write_var_or_type, write_name_assoc)
(maybe_overload): Update.
* ada-exp.h (class ada_var_value_operation) <get_block>: Rewrite.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r-- | gdb/eval.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -579,10 +579,10 @@ var_value_operation::evaluate (struct type *expect_type, struct expression *exp, enum noside noside) { - symbol *var = std::get<0> (m_storage); + symbol *var = std::get<0> (m_storage).symbol; if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR) error_unknown_type (var->print_name ()); - return evaluate_var_value (noside, std::get<1> (m_storage), var); + return evaluate_var_value (noside, std::get<0> (m_storage).block, var); } } /* namespace expr */ @@ -719,12 +719,13 @@ var_value_operation::evaluate_funcall (struct type *expect_type, struct symbol *symp; find_overload_match (argvec, NULL, NON_METHOD, - NULL, std::get<0> (m_storage), + NULL, std::get<0> (m_storage).symbol, NULL, &symp, NULL, 0, noside); if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR) error_unknown_type (symp->print_name ()); - value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp); + value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block, + symp); return evaluate_subexp_do_call (exp, noside, callee, argvec, nullptr, expect_type); @@ -2573,7 +2574,7 @@ value * var_value_operation::evaluate_for_address (struct expression *exp, enum noside noside) { - symbol *var = std::get<0> (m_storage); + symbol *var = std::get<0> (m_storage).symbol; /* C++: The "address" of a reference should yield the address * of the object pointed to. Let value_addr() deal with it. */ @@ -2593,20 +2594,21 @@ var_value_operation::evaluate_for_address (struct expression *exp, return value_zero (type, not_lval); } else - return address_of_variable (var, std::get<1> (m_storage)); + return address_of_variable (var, std::get<0> (m_storage).block); } value * var_value_operation::evaluate_with_coercion (struct expression *exp, enum noside noside) { - struct symbol *var = std::get<0> (m_storage); + struct symbol *var = std::get<0> (m_storage).symbol; struct type *type = check_typedef (SYMBOL_TYPE (var)); if (type->code () == TYPE_CODE_ARRAY && !type->is_vector () && CAST_IS_CONVERSION (exp->language_defn)) { - struct value *val = address_of_variable (var, std::get<1> (m_storage)); + struct value *val = address_of_variable (var, + std::get<0> (m_storage).block); return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val); } return evaluate (nullptr, exp, noside); @@ -2730,7 +2732,7 @@ value * var_value_operation::evaluate_for_sizeof (struct expression *exp, enum noside noside) { - struct type *type = SYMBOL_TYPE (std::get<0> (m_storage)); + struct type *type = SYMBOL_TYPE (std::get<0> (m_storage).symbol); if (is_dynamic_type (type)) { value *val = evaluate (nullptr, exp, EVAL_NORMAL); @@ -2778,8 +2780,8 @@ var_value_operation::evaluate_for_cast (struct type *to_type, enum noside noside) { value *val = evaluate_var_value (noside, - std::get<1> (m_storage), - std::get<0> (m_storage)); + std::get<0> (m_storage).block, + std::get<0> (m_storage).symbol); val = value_cast (to_type, val); |