From b64e260290108f8eb4f7a75f80a8355448aef7e4 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 31 Jan 2023 13:29:49 -0700 Subject: [PATCH] Turn allocate_computed_value into static "constructor" This turns allocate_computed_value into a static "constructor" of value. Approved-By: Simon Marchi --- gdb/dwarf2/expr.c | 2 +- gdb/dwarf2/loc.c | 2 +- gdb/infrun.c | 2 +- gdb/opencl-lang.c | 2 +- gdb/value.c | 6 +++--- gdb/value.h | 13 ++++++------- gdb/windows-tdep.c | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index fc92de85840..ad6cf563562 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -932,7 +932,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, piece_closure *c = allocate_piece_closure (this->m_per_cu, this->m_per_objfile, std::move (this->m_pieces), this->m_frame); - retval = allocate_computed_value (subobj_type, + retval = value::allocate_computed (subobj_type, &pieced_value_funcs, c); retval->set_offset (subobj_offset); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 2e0b4a8b45d..743a0cefd6d 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1359,7 +1359,7 @@ value_of_dwarf_reg_entry (struct type *type, frame_info_ptr frame, caller_per_cu, caller_per_objfile); - val = allocate_computed_value (type, &entry_data_value_funcs, + val = value::allocate_computed (type, &entry_data_value_funcs, release_value (target_val).release ()); /* Copy the referencing pointer to the new computed value. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index acf93033a86..c45c6b5c802 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9194,7 +9194,7 @@ siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var, { struct type *type = gdbarch_get_siginfo_type (gdbarch); - return allocate_computed_value (type, &siginfo_value_funcs, nullptr); + return value::allocate_computed (type, &siginfo_value_funcs, nullptr); } return value::allocate (builtin_type (gdbarch)->builtin_void); diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index c76f948a3ed..25be86ee98a 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -304,7 +304,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, if (VALUE_LVAL (val) != not_lval && !array_has_dups (indices, n)) { struct lval_closure *c = allocate_lval_closure (indices, n, val); - ret = allocate_computed_value (dst_type, &opencl_value_funcs, c); + ret = value::allocate_computed (dst_type, &opencl_value_funcs, c); } else { diff --git a/gdb/value.c b/gdb/value.c index 11c9237c91e..7fb12d8e9a6 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -995,9 +995,9 @@ allocate_repeat_value (struct type *type, int count) } struct value * -allocate_computed_value (struct type *type, - const struct lval_funcs *funcs, - void *closure) +value::allocate_computed (struct type *type, + const struct lval_funcs *funcs, + void *closure) { struct value *v = value::allocate_lazy (type); diff --git a/gdb/value.h b/gdb/value.h index c1c9199168e..dbbb61932b8 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -169,6 +169,12 @@ public: /* Allocate a value and its contents for type TYPE. */ static struct value *allocate (struct type *type); + /* Create a computed lvalue, with type TYPE, function pointers + FUNCS, and closure CLOSURE. */ + static struct value *allocate_computed (struct type *type, + const struct lval_funcs *funcs, + void *closure); + ~value (); DISABLE_COPY_AND_ASSIGN (value); @@ -619,13 +625,6 @@ struct lval_funcs void (*free_closure) (struct value *v); }; -/* Create a computed lvalue, with type TYPE, function pointers FUNCS, - and closure CLOSURE. */ - -extern struct value *allocate_computed_value (struct type *type, - const struct lval_funcs *funcs, - void *closure); - extern struct value *allocate_optimized_out_value (struct type *type); /* Throw an error complaining that the value has been optimized diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 741333cf677..893e34d9912 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -433,7 +433,7 @@ tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore) if (target_has_stack () && inferior_ptid != null_ptid) { struct type *type = windows_get_tlb_type (gdbarch); - return allocate_computed_value (type, &tlb_value_funcs, NULL); + return value::allocate_computed (type, &tlb_value_funcs, NULL); } return value::allocate (builtin_type (gdbarch)->builtin_void); -- 2.30.2