aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-04-15 10:05:00 -0600
committerTom Tromey <tromey@adacore.com>2021-04-15 10:05:00 -0600
commit9e5e03df52968b416e09a59482409abfed9727c0 (patch)
treef7b84a83f5c0aa2f636927ef25efed33604c3f13 /gdb/expop.h
parent4c79248a46100016e902f1489ce1c38a42608460 (diff)
downloadbinutils-9e5e03df52968b416e09a59482409abfed9727c0.zip
binutils-9e5e03df52968b416e09a59482409abfed9727c0.tar.gz
binutils-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/expop.h')
-rw-r--r--gdb/expop.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index cc8d9ca..b8e28b5 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -221,7 +221,7 @@ check_objfile (struct objfile *exp_objfile, struct objfile *objfile)
return exp_objfile == objfile;
}
-static inline bool
+static inline bool
check_objfile (struct type *type, struct objfile *objfile)
{
struct objfile *ty_objfile = type->objfile_owner ();
@@ -230,19 +230,26 @@ check_objfile (struct type *type, struct objfile *objfile)
return false;
}
-static inline bool
+static inline bool
check_objfile (struct symbol *sym, struct objfile *objfile)
{
return check_objfile (symbol_objfile (sym), objfile);
}
-static inline bool
+static inline bool
check_objfile (const struct block *block, struct objfile *objfile)
{
return check_objfile (block_objfile (block), objfile);
}
static inline bool
+check_objfile (const block_symbol &sym, struct objfile *objfile)
+{
+ return (check_objfile (sym.symbol, objfile)
+ || check_objfile (sym.block, objfile));
+}
+
+static inline bool
check_objfile (bound_minimal_symbol minsym, struct objfile *objfile)
{
return check_objfile (minsym.objfile, objfile);
@@ -260,7 +267,7 @@ check_objfile (const std::string &str, struct objfile *objfile)
return false;
}
-static inline bool
+static inline bool
check_objfile (const operation_up &op, struct objfile *objfile)
{
return op->uses_objfile (objfile);
@@ -286,7 +293,7 @@ check_objfile (enum_flags<T> val, struct objfile *objfile)
}
template<typename T>
-static inline bool
+static inline bool
check_objfile (const std::vector<T> &collection, struct objfile *objfile)
{
for (const auto &item : collection)
@@ -298,7 +305,7 @@ check_objfile (const std::vector<T> &collection, struct objfile *objfile)
}
template<typename S, typename T>
-static inline bool
+static inline bool
check_objfile (const std::pair<S, T> &item, struct objfile *objfile)
{
return (check_objfile (item.first, objfile)
@@ -328,6 +335,8 @@ extern void dump_for_expression (struct ui_file *stream, int depth,
extern void dump_for_expression (struct ui_file *stream, int depth,
symbol *sym);
extern void dump_for_expression (struct ui_file *stream, int depth,
+ const block_symbol &sym);
+extern void dump_for_expression (struct ui_file *stream, int depth,
bound_minimal_symbol msym);
extern void dump_for_expression (struct ui_file *stream, int depth,
const block *bl);
@@ -480,6 +489,14 @@ check_constant (struct symbol *sym)
|| sc == LOC_LABEL);
}
+static inline bool
+check_constant (const block_symbol &sym)
+{
+ /* We know the block is constant, so we only need to check the
+ symbol. */
+ return check_constant (sym.symbol);
+}
+
template<typename T>
static inline bool
check_constant (const std::vector<T> &collection)
@@ -612,7 +629,7 @@ protected:
/* Compute the value of a variable. */
class var_value_operation
- : public maybe_constant_operation<symbol *, const block *>
+ : public maybe_constant_operation<block_symbol>
{
public:
@@ -646,7 +663,7 @@ public:
/* Return the symbol referenced by this object. */
symbol *get_symbol () const
{
- return std::get<0> (m_storage);
+ return std::get<0> (m_storage).symbol;
}
protected: