From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 25/47] Turn value_zero into static "constructor"
Date: Thu, 09 Feb 2023 14:38:46 -0700 [thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v1-25-55dc2794dbb9@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v1-0-55dc2794dbb9@tromey.com>
This turns value_zero into a static "constructor" of value.
---
gdb/ada-lang.c | 42 +++++++++++++++++++++---------------------
gdb/dummy-frame.c | 2 +-
gdb/dwarf2/expr.c | 2 +-
gdb/eval.c | 44 ++++++++++++++++++++++----------------------
gdb/f-lang.c | 4 ++--
gdb/frame-unwind.c | 6 +++---
gdb/guile/scm-math.c | 2 +-
gdb/m2-lang.c | 2 +-
gdb/opencl-lang.c | 4 ++--
gdb/python/py-value.c | 2 +-
gdb/rust-lang.c | 8 ++++----
gdb/valarith.c | 14 +++++++-------
gdb/valops.c | 10 +++++-----
gdb/value.c | 5 ++---
gdb/value.h | 7 ++++---
15 files changed, 77 insertions(+), 77 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 727f816b519..53265ca1a9c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -8922,7 +8922,7 @@ ada_pos_atr (struct type *expect_type,
{
struct type *type = builtin_type (exp->gdbarch)->builtin_int;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
return value_from_longest (type, pos_atr (arg));
}
@@ -8947,7 +8947,7 @@ struct value *
ada_val_atr (enum noside noside, struct type *type, struct value *arg)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
if (!discrete_type_p (type))
error (_("'VAL only defined on discrete types"));
@@ -10164,7 +10164,7 @@ ada_atr_tag (struct type *expect_type,
struct value *arg1)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (ada_tag_type (arg1), not_lval);
+ return value::zero (ada_tag_type (arg1), not_lval);
return ada_value_tag (arg1);
}
@@ -10186,7 +10186,7 @@ ada_atr_size (struct type *expect_type,
type = type->target_type ();
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval);
+ return value::zero (builtin_type (exp->gdbarch)->builtin_int, not_lval);
else
return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
TARGET_CHAR_BIT * type->length ());
@@ -10201,7 +10201,7 @@ ada_abs (struct type *expect_type,
struct value *arg1)
{
unop_promote (exp->language_defn, exp->gdbarch, &arg1);
- if (value_less (arg1, value_zero (arg1->type (), not_lval)))
+ if (value_less (arg1, value::zero (arg1->type (), not_lval)))
return value_neg (arg1);
else
return arg1;
@@ -10218,7 +10218,7 @@ ada_mult_binop (struct type *expect_type,
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
- return value_zero (arg1->type (), not_lval);
+ return value::zero (arg1->type (), not_lval);
}
else
{
@@ -10340,7 +10340,7 @@ ada_binop_in_bounds (struct expression *exp, enum noside noside,
{
struct type *type = language_bool_type (exp->language_defn,
exp->gdbarch);
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
}
struct type *type = ada_index_type (arg2->type (), n, "range");
@@ -10391,7 +10391,7 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op,
}
}
- return value_zero (type_arg, not_lval);
+ return value::zero (type_arg, not_lval);
}
else if (type_arg == NULL)
{
@@ -10496,7 +10496,7 @@ ada_binop_minmax (struct type *expect_type,
struct value *arg1, struct value *arg2)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (arg1->type (), not_lval);
+ return value::zero (arg1->type (), not_lval);
else
{
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
@@ -10513,7 +10513,7 @@ ada_binop_exp (struct type *expect_type,
struct value *arg1, struct value *arg2)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (arg1->type (), not_lval);
+ return value::zero (arg1->type (), not_lval);
else
{
/* For integer exponentiation operations,
@@ -10841,7 +10841,7 @@ ada_var_msym_value_operation::evaluate_for_cast (struct type *expect_type,
enum noside noside)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (expect_type, not_lval);
+ return value::zero (expect_type, not_lval);
const bound_minimal_symbol &b = std::get<0> (m_storage);
value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym);
@@ -10938,7 +10938,7 @@ ada_var_value_operation::evaluate (struct type *expect_type,
This can happen if the debugging information is
incomplete, for instance. */
actual_type = type;
- return value_zero (actual_type, not_lval);
+ return value::zero (actual_type, not_lval);
}
else
{
@@ -10963,7 +10963,7 @@ ada_var_value_operation::evaluate (struct type *expect_type,
&& dynamic_template_type (type) != NULL)
|| (type->code () == TYPE_CODE_UNION
&& ada_find_parallel_type (type, "___XVU") != NULL))
- return value_zero (to_static_fixed_type (type), not_lval);
+ return value::zero (to_static_fixed_type (type), not_lval);
}
value *arg1 = var_value_operation::evaluate (expect_type, exp, noside);
@@ -11047,19 +11047,19 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
(ada_aligned_type
(ada_check_typedef (type->target_type ())));
}
- return value_zero (type, lval_memory);
+ return value::zero (type, lval_memory);
}
else if (type->code () == TYPE_CODE_INT)
{
/* GDB allows dereferencing an int. */
if (expect_type == NULL)
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ return value::zero (builtin_type (exp->gdbarch)->builtin_int,
lval_memory);
else
{
expect_type =
to_static_fixed_type (ada_aligned_type (expect_type));
- return value_zero (expect_type, lval_memory);
+ return value::zero (expect_type, lval_memory);
}
}
else
@@ -11120,7 +11120,7 @@ ada_structop_operation::evaluate (struct type *expect_type,
else
type = ada_lookup_struct_elt_type (type1, str, 1, 0);
- return value_zero (ada_aligned_type (type), lval_memory);
+ return value::zero (ada_aligned_type (type), lval_memory);
}
else
{
@@ -11216,7 +11216,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
/* We don't know anything about what the internal
function might return, but we have to return
something. */
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ return value::zero (builtin_type (exp->gdbarch)->builtin_int,
not_lval);
else
return call_internal_function (exp->gdbarch, exp->language_defn,
@@ -11234,7 +11234,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
if (arity != nargs)
error (_("wrong number of subscripts; expecting %d"), arity);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (ada_aligned_type (type), lval_memory);
+ return value::zero (ada_aligned_type (type), lval_memory);
return
unwrap_value (ada_value_subscript
(callee, nargs, argvec.data ()));
@@ -11246,7 +11246,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
if (type == NULL)
error (_("element type of array unknown"));
else
- return value_zero (ada_aligned_type (type), lval_memory);
+ return value::zero (ada_aligned_type (type), lval_memory);
}
return
unwrap_value (ada_value_subscript
@@ -11260,7 +11260,7 @@ ada_funcall_operation::evaluate (struct type *expect_type,
if (type == NULL)
error (_("element type of array unknown"));
else
- return value_zero (ada_aligned_type (type), lval_memory);
+ return value::zero (ada_aligned_type (type), lval_memory);
}
return
unwrap_value (ada_value_ptr_subscript (callee, nargs,
diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c
index 784ac103eec..6c3dfb1b24d 100644
--- a/gdb/dummy-frame.c
+++ b/gdb/dummy-frame.c
@@ -348,7 +348,7 @@ dummy_frame_prev_register (frame_info_ptr this_frame,
/* Describe the register's location. Generic dummy frames always
have the register value in an ``expression''. */
- reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
+ reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
/* Use the regcache_cooked_read() method so that it, on the fly,
constructs either a raw or pseudo register from the raw
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index db88dc368fd..bb77a969784 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1929,7 +1929,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
{
case DW_OP_abs:
if (value_less (result_val,
- value_zero (result_val->type (), not_lval)))
+ value::zero (result_val->type (), not_lval)))
result_val = value_neg (result_val);
break;
case DW_OP_neg:
diff --git a/gdb/eval.c b/gdb/eval.c
index bb72043a28a..7dcad5b5d99 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -552,7 +552,7 @@ type_instance_operation::evaluate (struct type *expect_type,
value *
evaluate_var_value (enum noside noside, const block *blk, symbol *var)
{
- /* JYG: We used to just return value_zero of the symbol type if
+ /* JYG: We used to just return value::zero of the symbol type if
we're asked to avoid side effects. Otherwise we return
value_of_variable (...). However I'm not sure if
value_of_variable () has any side effect. We need a full value
@@ -573,7 +573,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var)
if (noside != EVAL_AVOID_SIDE_EFFECTS)
throw;
- ret = value_zero (var->type (), not_lval);
+ ret = value::zero (var->type (), not_lval);
}
return ret;
@@ -606,7 +606,7 @@ evaluate_var_msym_value (enum noside noside,
type *the_type = find_minsym_type_and_address (msymbol, objfile, &address);
if (noside == EVAL_AVOID_SIDE_EFFECTS && !the_type->is_gnu_ifunc ())
- return value_zero (the_type, not_lval);
+ return value::zero (the_type, not_lval);
else
return value_at_lazy (the_type, address);
}
@@ -635,7 +635,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
/* We don't know anything about what the internal
function might return, but we have to return
something. */
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ return value::zero (builtin_type (exp->gdbarch)->builtin_int,
not_lval);
}
else if (ftype->code () == TYPE_CODE_XMETHOD)
@@ -644,7 +644,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
if (return_type == NULL)
error (_("Xmethod is missing return type."));
- return value_zero (return_type, not_lval);
+ return value::zero (return_type, not_lval);
}
else if (ftype->code () == TYPE_CODE_FUNC
|| ftype->code () == TYPE_CODE_METHOD)
@@ -775,7 +775,7 @@ scope_operation::evaluate_funcall (struct type *expect_type,
function_name = name.c_str ();
/* We need a properly typed value for method lookup. */
- argvec[0] = value_zero (type, lval_memory);
+ argvec[0] = value::zero (type, lval_memory);
}
for (int i = 0; i < args.size (); ++i)
@@ -840,7 +840,7 @@ structop_member_base::evaluate_funcall (struct type *expect_type,
if (a1_type->code () == TYPE_CODE_METHODPTR)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- callee = value_zero (a1_type->target_type (), not_lval);
+ callee = value::zero (a1_type->target_type (), not_lval);
else
callee = cplus_method_ptr_to_value (&lhs, rhs);
@@ -1101,7 +1101,7 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
enum noside noside, symbol *sym)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (sym->type (), not_lval);
+ return value::zero (sym->type (), not_lval);
if (SYMBOL_COMPUTED_OPS (sym) == NULL
|| SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
@@ -1165,7 +1165,7 @@ eval_op_register (struct type *expect_type, struct expression *exp,
of the evaluation mode. */
if (noside == EVAL_AVOID_SIDE_EFFECTS
&& regno < gdbarch_num_cooked_regs (exp->gdbarch))
- val = value_zero (register_type (exp->gdbarch, regno), not_lval);
+ val = value::zero (register_type (exp->gdbarch, regno), not_lval);
else
val = value_of_register (regno, get_selected_frame (NULL));
if (val == NULL)
@@ -1224,7 +1224,7 @@ eval_op_structop_struct (struct type *expect_type, struct expression *exp,
struct value *arg3 = value_struct_elt (&arg1, {}, string,
NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3));
+ arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3));
return arg3;
}
@@ -1280,7 +1280,7 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp,
struct value *arg3 = value_struct_elt (&arg1, {}, string,
NULL, "structure pointer");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- arg3 = value_zero (arg3->type (), VALUE_LVAL (arg3));
+ arg3 = value::zero (arg3->type (), VALUE_LVAL (arg3));
return arg3;
}
@@ -1299,7 +1299,7 @@ eval_op_member (struct type *expect_type, struct expression *exp,
{
case TYPE_CODE_METHODPTR:
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type->target_type (), not_lval);
+ return value::zero (type->target_type (), not_lval);
else
{
arg2 = cplus_method_ptr_to_value (&arg1, arg2);
@@ -1447,7 +1447,7 @@ eval_op_subscript (struct type *expect_type, struct expression *exp,
}
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type->target_type (), VALUE_LVAL (arg1));
+ return value::zero (type->target_type (), VALUE_LVAL (arg1));
else
return value_subscript (arg1, value_as_long (arg2));
}
@@ -1693,11 +1693,11 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
if (type->is_pointer_or_reference ()
/* In C you can dereference an array to get the 1st elt. */
|| type->code () == TYPE_CODE_ARRAY)
- return value_zero (type->target_type (),
+ return value::zero (type->target_type (),
lval_memory);
else if (type->code () == TYPE_CODE_INT)
/* GDB allows dereferencing an int. */
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ return value::zero (builtin_type (exp->gdbarch)->builtin_int,
lval_memory);
else
error (_("Attempt to take contents of a non-pointer value."));
@@ -1738,7 +1738,7 @@ eval_op_memval (struct type *expect_type, struct expression *exp,
struct value *arg1, struct type *type)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type, lval_memory);
+ return value::zero (type, lval_memory);
else
return value_at_lazy (type, value_as_address (arg1));
}
@@ -2588,10 +2588,10 @@ evaluate_subexp_for_address_base (struct expression *exp, enum noside noside,
struct type *type = check_typedef (x->type ());
if (TYPE_IS_REFERENCE (type))
- return value_zero (lookup_pointer_type (type->target_type ()),
+ return value::zero (lookup_pointer_type (type->target_type ()),
not_lval);
else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
- return value_zero (lookup_pointer_type (x->type ()),
+ return value::zero (lookup_pointer_type (x->type ()),
not_lval);
else
error (_("Attempt to take address of "
@@ -2656,7 +2656,7 @@ var_msym_value_operation::evaluate_for_address (struct expression *exp,
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = lookup_pointer_type (val->type ());
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
}
else
return value_addr (val);
@@ -2702,7 +2702,7 @@ var_value_operation::evaluate_for_address (struct expression *exp,
|| sym_class == LOC_REGISTER)
error (_("Attempt to take address of register or constant."));
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
}
else
return address_of_variable (var, std::get<0> (m_storage).block);
@@ -2852,7 +2852,7 @@ var_value_operation::evaluate_for_sizeof (struct expression *exp,
/* FIXME: This should be size_t. */
struct type *size_type = builtin_type (exp->gdbarch)->builtin_int;
if (type_not_allocated (type) || type_not_associated (type))
- return value_zero (size_type, not_lval);
+ return value::zero (size_type, not_lval);
else if (is_dynamic_type (type->index_type ())
&& type->bounds ()->high.kind () == PROP_UNDEFINED)
return value::allocate_optimized_out (size_type);
@@ -2867,7 +2867,7 @@ var_msym_value_operation::evaluate_for_cast (struct type *to_type,
enum noside noside)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (to_type, not_lval);
+ return value::zero (to_type, not_lval);
const bound_minimal_symbol &b = std::get<0> (m_storage);
value *val = evaluate_var_msym_value (noside, b.objfile, b.minsym);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index ccaf4fd612f..10c46fa0c29 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -961,7 +961,7 @@ eval_op_f_cmplx (type *expect_type, expression *exp, noside noside,
return value_cast (result_type, arg1);
else
return value_literal_complex (arg1,
- value_zero (arg1->type (), not_lval),
+ value::zero (arg1->type (), not_lval),
result_type);
}
@@ -1637,7 +1637,7 @@ fortran_structop_operation::evaluate (struct type *expect_type,
= gdb::make_array_view (valaddr, elt_type->length ());
elt_type = resolve_dynamic_type (elt_type, view, address);
}
- elt = value_zero (elt_type, VALUE_LVAL (elt));
+ elt = value::zero (elt_type, VALUE_LVAL (elt));
}
return elt;
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index 6c8a094242f..12f83d58755 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -303,7 +303,7 @@ frame_unwind_got_constant (frame_info_ptr frame, int regnum,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct value *reg_val;
- reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
+ reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
store_unsigned_integer (value_contents_writeable (reg_val).data (),
register_size (gdbarch, regnum), byte_order, val);
return reg_val;
@@ -315,7 +315,7 @@ frame_unwind_got_bytes (frame_info_ptr frame, int regnum, const gdb_byte *buf)
struct gdbarch *gdbarch = frame_unwind_arch (frame);
struct value *reg_val;
- reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
+ reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
memcpy (value_contents_raw (reg_val).data (), buf,
register_size (gdbarch, regnum));
return reg_val;
@@ -332,7 +332,7 @@ frame_unwind_got_address (frame_info_ptr frame, int regnum,
struct gdbarch *gdbarch = frame_unwind_arch (frame);
struct value *reg_val;
- reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
+ reg_val = value::zero (register_type (gdbarch, regnum), not_lval);
pack_long (value_contents_writeable (reg_val).data (),
register_type (gdbarch, regnum), addr);
return reg_val;
diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c
index af472c1aff3..dcbdef5f4b0 100644
--- a/gdb/guile/scm-math.c
+++ b/gdb/guile/scm-math.c
@@ -109,7 +109,7 @@ vlscm_unop_gdbthrow (enum valscm_unary_opcode opcode, SCM x,
res_val = arg1;
break;
case VALSCM_ABS:
- if (value_less (arg1, value_zero (arg1->type (), not_lval)))
+ if (value_less (arg1, value::zero (arg1->type (), not_lval)))
res_val = value_neg (arg1);
else
res_val = arg1;
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 42af96d96f2..ffa2faa44a9 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -104,7 +104,7 @@ eval_op_m2_subscript (struct type *expect_type, struct expression *exp,
}
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (type->target_type (), VALUE_LVAL (arg1));
+ return value::zero (type->target_type (), VALUE_LVAL (arg1));
else
return value_subscript (arg1, value_as_long (arg2));
}
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 25be86ee98a..dc34dee2995 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -278,7 +278,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
if (n == 1)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- ret = value_zero (elm_type, not_lval);
+ ret = value::zero (elm_type, not_lval);
else
ret = value_subscript (val, indices[0]);
}
@@ -715,7 +715,7 @@ opencl_structop_operation::evaluate (struct type *expect_type,
NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- v = value_zero (v->type (), VALUE_LVAL (v));
+ v = value::zero (v->type (), VALUE_LVAL (v));
return v;
}
}
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index b387bb813e7..6a176c7efda 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1506,7 +1506,7 @@ valpy_absolute (PyObject *self)
{
scoped_value_mark free_values;
- if (value_less (value, value_zero (value->type (), not_lval)))
+ if (value_less (value, value::zero (value->type (), not_lval)))
isabs = 0;
}
catch (const gdb_exception &except)
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index edffad4afe7..ff30babca75 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1070,7 +1070,7 @@ rust_range (struct type *expect_type, struct expression *exp,
high == NULL ? NULL : "end", index_type);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (range_type, lval_memory);
+ return value::zero (range_type, lval_memory);
addrval = value_allocate_space_in_inferior (range_type->length ());
addr = value_as_long (addrval);
@@ -1204,7 +1204,7 @@ rust_subscript (struct type *expect_type, struct expression *exp,
else
new_type = base_type;
- return value_zero (new_type, VALUE_LVAL (lhs));
+ return value::zero (new_type, VALUE_LVAL (lhs));
}
else
{
@@ -1470,7 +1470,7 @@ rust_structop::evaluate (struct type *expect_type,
else
result = value_struct_elt (&lhs, {}, field_name, NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- result = value_zero (result->type (), VALUE_LVAL (result));
+ result = value::zero (result->type (), VALUE_LVAL (result));
return result;
}
@@ -1571,7 +1571,7 @@ rust_structop::evaluate_funcall (struct type *expect_type,
args[i + 1] = ops[i]->evaluate (nullptr, exp, noside);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (fn_type->target_type (), not_lval);
+ return value::zero (fn_type->target_type (), not_lval);
return call_function_by_hand (function, NULL, args);
}
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 5494dde9310..a2fc1829cd3 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -517,7 +517,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
if (return_type == NULL)
error (_("Xmethod is missing return type."));
- return value_zero (return_type, VALUE_LVAL (arg1));
+ return value::zero (return_type, VALUE_LVAL (arg1));
}
return call_xmethod (argvec[0], argvec.slice (1));
}
@@ -526,7 +526,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
struct type *return_type;
return_type = check_typedef (argvec[0]->type ())->target_type ();
- return value_zero (return_type, VALUE_LVAL (arg1));
+ return value::zero (return_type, VALUE_LVAL (arg1));
}
return call_function_by_hand (argvec[0], NULL,
argvec.slice (1, 2 - static_memfuncp));
@@ -630,7 +630,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
if (return_type == NULL)
error (_("Xmethod is missing return type."));
- return value_zero (return_type, VALUE_LVAL (arg1));
+ return value::zero (return_type, VALUE_LVAL (arg1));
}
return call_xmethod (argvec[0], argvec[1]);
}
@@ -639,7 +639,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
struct type *return_type;
return_type = check_typedef (argvec[0]->type ())->target_type ();
- return value_zero (return_type, VALUE_LVAL (arg1));
+ return value::zero (return_type, VALUE_LVAL (arg1));
}
return call_function_by_hand (argvec[0], NULL,
argvec.slice (1, nargs));
@@ -973,7 +973,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
else
{
arg1_real = arg1;
- arg1_imag = value_zero (arg1_type, not_lval);
+ arg1_imag = value::zero (arg1_type, not_lval);
}
if (arg2_type->code () == TYPE_CODE_COMPLEX)
{
@@ -983,7 +983,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
else
{
arg2_real = arg2;
- arg2_imag = value_zero (arg2_type, not_lval);
+ arg2_imag = value::zero (arg2_type, not_lval);
}
struct type *comp_type = promotion_type (arg1_real->type (),
@@ -1898,7 +1898,7 @@ value_neg (struct value *arg1)
if (is_integral_type (type) || is_floating_type (type))
return value_binop (value_from_longest (type, 0), arg1, BINOP_SUB);
else if (is_fixed_point_type (type))
- return value_binop (value_zero (type, not_lval), arg1, BINOP_SUB);
+ return value_binop (value::zero (type, not_lval), arg1, BINOP_SUB);
else if (type->code () == TYPE_CODE_ARRAY && type->is_vector ())
{
struct value *val = value::allocate (type);
diff --git a/gdb/valops.c b/gdb/valops.c
index 19f5fb6f3c9..a6357f0afca 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -271,7 +271,7 @@ value_cast_structs (struct type *type, struct value *v2)
T2. This wouldn't work properly for classes with virtual
bases, but those were handled above. */
v = search_struct_field (t2->name (),
- value_zero (t1, not_lval), t1, 1);
+ value::zero (t1, not_lval), t1, 1);
if (v)
{
/* Downcasting is possible (t1 is superclass of v2). */
@@ -640,7 +640,7 @@ value_cast (struct type *type, struct value *arg2)
error (_("can only cast scalar to vector of same size"));
else if (code1 == TYPE_CODE_VOID)
{
- return value_zero (to_type, not_lval);
+ return value::zero (to_type, not_lval);
}
else if (type->length () == type2->length ())
{
@@ -848,7 +848,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
/* Handle NULL pointers. */
if (value_as_long (arg) == 0)
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
arg = value_ind (arg);
}
@@ -928,7 +928,7 @@ value_dynamic_cast (struct type *type, struct value *arg)
: value_addr (result));
if (resolved_type->code () == TYPE_CODE_PTR)
- return value_zero (type, not_lval);
+ return value::zero (type, not_lval);
error (_("dynamic_cast failed"));
}
@@ -4167,7 +4167,7 @@ cast_into_complex (struct type *type, struct value *val)
else if (val->type ()->code () == TYPE_CODE_FLT
|| val->type ()->code () == TYPE_CODE_INT)
return value_literal_complex (val,
- value_zero (real_type, not_lval),
+ value::zero (real_type, not_lval),
type);
else
error (_("cannot cast non-number to complex"));
diff --git a/gdb/value.c b/gdb/value.c
index f0e58a41768..550bcb4709f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3252,11 +3252,10 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num)
}
}
-
-/* Create a value of type TYPE that is zero, and return it. */
+/* See value.h. */
struct value *
-value_zero (struct type *type, enum lval_type lv)
+value::zero (struct type *type, enum lval_type lv)
{
struct value *val = value::allocate_lazy (type);
diff --git a/gdb/value.h b/gdb/value.h
index 771e50a0b38..e45ff9f8d9f 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -177,6 +177,9 @@ struct value
/* Allocate NOT_LVAL value for type TYPE being OPTIMIZED_OUT. */
static struct value *allocate_optimized_out (struct type *type);
+ /* Create a value of type TYPE that is zero, and return it. */
+ static struct value *zero (struct type *type, enum lval_type lv);
+
~value ();
DISABLE_COPY_AND_ASSIGN (value);
@@ -399,7 +402,7 @@ struct value
used instead of read_memory to enable extra caching. */
unsigned int m_stack : 1;
- /* True if this is a zero value, created by 'value_zero'; false
+ /* True if this is a zero value, created by 'value::zero'; false
otherwise. */
bool m_is_zero : 1;
@@ -1143,8 +1146,6 @@ extern struct value *value_reinterpret_cast (struct type *type,
extern struct value *value_dynamic_cast (struct type *type, struct value *arg);
-extern struct value *value_zero (struct type *type, enum lval_type lv);
-
extern struct value *value_one (struct type *type);
extern struct value *value_repeat (struct value *arg1, int count);
--
2.39.1
next prev parent reply other threads:[~2023-02-09 21:38 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 21:38 [PATCH 00/47] Use methods for struct value Tom Tromey
2023-02-09 21:38 ` [PATCH 01/47] Rename all fields of " Tom Tromey
2023-02-10 21:05 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 02/47] Move ~value body out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 03/47] Move struct value to value.h Tom Tromey
2023-02-09 21:38 ` [PATCH 04/47] Turn value_type into method Tom Tromey
2023-02-09 21:38 ` [PATCH 05/47] Turn deprecated_set_value_type into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 06/47] Turn value_arch into method Tom Tromey
2023-02-10 2:08 ` Simon Marchi
2023-02-10 16:36 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 07/47] Turn value_bitsize " Tom Tromey
2023-02-09 21:38 ` [PATCH 08/47] Turn value_bitpos " Tom Tromey
2023-02-09 21:38 ` [PATCH 09/47] Turn value_parent " Tom Tromey
2023-02-09 21:38 ` [PATCH 10/47] Turn value_offset " Tom Tromey
2023-02-09 21:38 ` [PATCH 11/47] Turn deprecated_value_modifiable " Tom Tromey
2023-02-09 21:38 ` [PATCH 12/47] Turn value_enclosing_type " Tom Tromey
2023-02-09 21:38 ` [PATCH 13/47] Turn some value offset functions " Tom Tromey
2023-02-09 21:38 ` [PATCH 14/47] Turn value_lazy and set_value_lazy functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 15/47] Turn value_stack and set_value_stack " Tom Tromey
2023-02-09 21:38 ` [PATCH 16/47] Turn value_computed_closure and value_computed_funcs " Tom Tromey
2023-02-09 21:38 ` [PATCH 17/47] Convert value_lval_const and deprecated_lval_hack to methods Tom Tromey
2023-02-09 21:38 ` [PATCH 18/47] Turn value_initialized and set_value_initialized functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 19/47] Turn value_address and set_value_address " Tom Tromey
2023-02-09 21:38 ` [PATCH 20/47] Turn more deprecated_* " Tom Tromey
2023-02-09 21:38 ` [PATCH 21/47] Turn allocate_value_lazy into a static "constructor" Tom Tromey
2023-02-09 21:38 ` [PATCH 22/47] Turn allocate_value " Tom Tromey
2023-02-09 21:38 ` [PATCH 23/47] Turn allocate_computed_value into " Tom Tromey
2023-02-09 21:38 ` [PATCH 24/47] Turn allocate_optimized_out_value " Tom Tromey
2023-02-09 21:38 ` Tom Tromey [this message]
2023-02-09 21:38 ` [PATCH 26/47] Turn some value_contents functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 27/47] Turn value_fetch_lazy into a method Tom Tromey
2023-02-09 21:38 ` [PATCH 28/47] Turn allocate_value_contents " Tom Tromey
2023-02-09 21:38 ` [PATCH 29/47] Turn value_contents_eq " Tom Tromey
2023-02-10 2:18 ` Simon Marchi
2023-02-10 17:46 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 30/47] Turn value_bits_synthetic_pointer " Tom Tromey
2023-02-09 21:38 ` [PATCH 31/47] Move value_ref_policy methods out-of-line Tom Tromey
2023-02-09 21:38 ` [PATCH 32/47] Turn value_incref and value_decref into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 33/47] Turn remaining value_contents functions " Tom Tromey
2023-02-10 2:24 ` Simon Marchi
2023-02-10 17:46 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 34/47] Fully qualify calls to copy in value.c Tom Tromey
2023-02-09 21:38 ` [PATCH 35/47] Turn value_copy into a method Tom Tromey
2023-02-10 2:42 ` Simon Marchi
2023-02-10 18:03 ` Tom Tromey
2023-02-09 21:38 ` [PATCH 36/47] Turn many optimized-out value functions into methods Tom Tromey
2023-02-09 21:38 ` [PATCH 37/47] Turn value_non_lval and value_force_lval " Tom Tromey
2023-02-09 21:38 ` [PATCH 38/47] Turn set_value_component_location into method Tom Tromey
2023-02-09 21:39 ` [PATCH 39/47] Change some code to use value methods Tom Tromey
2023-02-09 21:39 ` [PATCH 40/47] Turn some xmethod functions into methods Tom Tromey
2023-02-09 21:39 ` [PATCH 41/47] Turn preserve_one_value into method Tom Tromey
2023-02-09 21:39 ` [PATCH 42/47] Turn various value copying-related functions into methods Tom Tromey
2023-02-10 20:20 ` Tom Tromey
2023-02-09 21:39 ` [PATCH 43/47] Add value::set_modifiable Tom Tromey
2023-02-09 21:39 ` [PATCH 44/47] Make struct value data members private Tom Tromey
2023-02-09 21:39 ` [PATCH 45/47] Make ~value private Tom Tromey
2023-02-09 21:39 ` [PATCH 46/47] Introduce set_lval method on value Tom Tromey
2023-02-09 21:39 ` [PATCH 47/47] Remove deprecated_lval_hack Tom Tromey
2023-02-10 2:54 ` [PATCH 00/47] Use methods for struct value Simon Marchi
2023-02-10 18:08 ` Tom Tromey
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=20230209-submit-value-fixups-2023-v1-25-55dc2794dbb9@tromey.com \
--to=tom@tromey.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).