[v2,22/48] Turn allocate_value into a static "constructor"

Message ID 20230209-submit-value-fixups-2023-v2-22-b0b27fd97177@tromey.com
State New
Headers
Series Use methods for struct value |

Commit Message

Tom Tromey Feb. 10, 2023, 9:52 p.m. UTC
  This changes allocate_value to be a static "constructor" of value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
 gdb/aarch64-tdep.c       |  4 ++--
 gdb/ada-lang.c           | 26 +++++++++++++-------------
 gdb/amd64-tdep.c         |  4 ++--
 gdb/amd64-windows-tdep.c |  2 +-
 gdb/arch-utils.c         |  2 +-
 gdb/arm-tdep.c           |  4 ++--
 gdb/breakpoint.c         |  2 +-
 gdb/c-lang.c             |  2 +-
 gdb/cli/cli-cmds.c       |  2 +-
 gdb/cp-valprint.c        |  2 +-
 gdb/dwarf2/expr.c        |  6 +++---
 gdb/dwarf2/loc.c         |  2 +-
 gdb/dwarf2/read.c        |  2 +-
 gdb/elfread.c            |  6 +++---
 gdb/eval.c               | 16 ++++++++--------
 gdb/expop.h              |  4 ++--
 gdb/f-lang.c             |  6 +++---
 gdb/findvar.c            |  8 ++++----
 gdb/gdbtypes.h           |  2 +-
 gdb/i386-tdep.c          |  4 ++--
 gdb/infcall.c            |  2 +-
 gdb/infrun.c             |  2 +-
 gdb/opencl-lang.c        | 12 ++++++------
 gdb/ppc-linux-tdep.c     |  2 +-
 gdb/python/py-xmethods.c |  2 +-
 gdb/regcache.c           |  2 +-
 gdb/riscv-tdep.c         |  6 +++---
 gdb/rust-lang.c          |  4 ++--
 gdb/sparc-tdep.c         |  2 +-
 gdb/std-regs.c           |  4 ++--
 gdb/tracepoint.c         |  4 ++--
 gdb/valarith.c           | 20 ++++++++++----------
 gdb/valops.c             | 36 ++++++++++++++++++------------------
 gdb/valprint.c           |  2 +-
 gdb/value.c              | 40 +++++++++++++++++++---------------------
 gdb/value.h              |  5 +++--
 gdb/windows-tdep.c       |  2 +-
 37 files changed, 126 insertions(+), 127 deletions(-)
  

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 058d5bfce85..76c92fd99bd 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -2492,7 +2492,7 @@  aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
 
   if (read_value)
     {
-      *read_value = allocate_value (valtype);
+      *read_value = value::allocate (valtype);
       aarch64_extract_return_value (valtype, regcache,
 				    value_contents_raw (*read_value).data ());
     }
@@ -2781,7 +2781,7 @@  aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache,
 			   int regnum)
 {
   aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
-  struct value *result_value = allocate_value (register_type (gdbarch, regnum));
+  struct value *result_value = value::allocate (register_type (gdbarch, regnum));
 
   VALUE_LVAL (result_value) = lval_register;
   VALUE_REGNUM (result_value) = regnum;
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index ae2f4df5332..3d2c9f4f2ab 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -564,7 +564,7 @@  coerce_unspec_val_to_type (struct value *val, struct type *type)
 	result = value::allocate_lazy (type);
       else
 	{
-	  result = allocate_value (type);
+	  result = value::allocate (type);
 	  value_contents_copy (result, 0, val, 0, type->length ());
 	}
       set_value_component_location (result, val);
@@ -2807,7 +2807,7 @@  ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
 
   if (obj == NULL)
     {
-      v = allocate_value (type);
+      v = value::allocate (type);
       src = valaddr + offset;
     }
   else if (VALUE_LVAL (obj) == lval_memory && obj->lazy ())
@@ -2822,7 +2822,7 @@  ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
     }
   else
     {
-      v = allocate_value (type);
+      v = value::allocate (type);
       src = value_contents (obj).data () + offset;
     }
 
@@ -3404,7 +3404,7 @@  empty_array (struct type *arr_type, int low, int high)
 	 high < low ? low - 1 : high);
   struct type *elt_type = ada_array_element_type (arr_type0, 1);
 
-  return allocate_value (create_array_type (NULL, elt_type, index_type));
+  return value::allocate (create_array_type (NULL, elt_type, index_type));
 }
 
 
@@ -4528,7 +4528,7 @@  ada_convert_actual (struct value *actual, struct type *formal_type0)
 	      struct value *val;
 
 	      actual_type = ada_check_typedef (actual->type ());
-	      val = allocate_value (actual_type);
+	      val = value::allocate (actual_type);
 	      copy (value_contents (actual), value_contents_raw (val));
 	      actual = ensure_lval (val);
 	    }
@@ -4544,7 +4544,7 @@  ada_convert_actual (struct value *actual, struct type *formal_type0)
     {
       /* We need to turn this parameter into an aligner type
 	 as well.  */
-      struct value *aligner = allocate_value (formal_type);
+      struct value *aligner = value::allocate (formal_type);
       struct value *component = ada_value_struct_elt (aligner, "F", 0);
 
       value_assign_to_component (aligner, component, actual);
@@ -4584,8 +4584,8 @@  make_array_descriptor (struct type *type, struct value *arr)
 {
   struct type *bounds_type = desc_bounds_type (type);
   struct type *desc_type = desc_base_type (type);
-  struct value *descriptor = allocate_value (desc_type);
-  struct value *bounds = allocate_value (bounds_type);
+  struct value *descriptor = value::allocate (desc_type);
+  struct value *bounds = value::allocate (bounds_type);
   int i;
 
   for (i = ada_array_arity (ada_check_typedef (arr->type ()));
@@ -9281,7 +9281,7 @@  ada_promote_array_of_integrals (struct type *type, struct value *val)
   if (!get_array_bounds (type, &lo, &hi))
     error (_("unable to determine array bounds"));
 
-  value *res = allocate_value (type);
+  value *res = value::allocate (type);
   gdb::array_view<gdb_byte> res_contents = value_contents_writeable (res);
 
   /* Promote each array element.  */
@@ -9403,7 +9403,7 @@  ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
       v = 0;
     }
 
-  val = allocate_value (type1);
+  val = value::allocate (type1);
   store_unsigned_integer (value_contents_raw (val).data (),
 			  val->type ()->length (),
 			  type_byte_order (type1), v);
@@ -10667,7 +10667,7 @@  ada_string_operation::evaluate (struct type *expect_type,
 	   historical behavior.  */
 	struct type *stringtype
 	  = lookup_array_range_type (char_type, 1, str.length ());
-	struct value *val = allocate_value (stringtype);
+	struct value *val = value::allocate (stringtype);
 	memcpy (value_contents_raw (val).data (), str.c_str (),
 		str.length ());
 	return val;
@@ -10702,7 +10702,7 @@  ada_string_operation::evaluate (struct type *expect_type,
     = lookup_array_range_type (char_type, 1,
 			       obstack_object_size (&converted)
 			       / char_type->length ());
-  struct value *val = allocate_value (stringtype);
+  struct value *val = value::allocate (stringtype);
   memcpy (value_contents_raw (val).data (),
 	  obstack_base (&converted),
 	  obstack_object_size (&converted));
@@ -11208,7 +11208,7 @@  ada_funcall_operation::evaluate (struct type *expect_type,
 	{
 	  if (type->target_type () == NULL)
 	    error_call_unknown_return_type (NULL);
-	  return allocate_value (type->target_type ());
+	  return value::allocate (type->target_type ());
 	}
       return call_function_by_hand (callee, NULL, argvec);
     case TYPE_CODE_INTERNAL_FUNCTION:
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 5e098b1ce79..03e9ac951c8 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -355,7 +355,7 @@  amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
 {
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
 
-  value *result_value = allocate_value (register_type (gdbarch, regnum));
+  value *result_value = value::allocate (register_type (gdbarch, regnum));
   VALUE_LVAL (result_value) = lval_register;
   VALUE_REGNUM (result_value) = regnum;
   gdb_byte *buf = value_contents_raw (result_value).data ();
@@ -831,7 +831,7 @@  amd64_return_value (struct gdbarch *gdbarch, struct value *function,
   gdb_byte *readbuf = nullptr;
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (type);
+      *read_value = value::allocate (type);
       readbuf = value_contents_raw (*read_value).data ();
     }
 
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 5c779cbb118..aea8aaa6200 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -408,7 +408,7 @@  amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
       /* Extract the return value from the register where it was stored.  */
       if (read_value != nullptr)
 	{
-	  *read_value = allocate_value (type);
+	  *read_value = value::allocate (type);
 	  regcache->raw_read_part (regnum, 0, len,
 				   value_contents_raw (*read_value).data ());
 	}
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 617768225d3..49c699fd124 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -1178,7 +1178,7 @@  default_gdbarch_return_value
 
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (valtype);
+      *read_value = value::allocate (valtype);
       readbuf = value_contents_raw (*read_value).data ();
     }
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a21f7120ab4..c4b92ea17d9 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9192,7 +9192,7 @@  arm_return_value (struct gdbarch *gdbarch, struct value *function,
       gdb_byte *readbuf = nullptr;
       if (read_value != nullptr)
 	{
-	  *read_value = allocate_value (valtype);
+	  *read_value = value::allocate (valtype);
 	  readbuf = value_contents_raw (*read_value).data ();
 	}
 
@@ -9268,7 +9268,7 @@  arm_return_value (struct gdbarch *gdbarch, struct value *function,
 
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (valtype);
+      *read_value = value::allocate (valtype);
       gdb_byte *readbuf = value_contents_raw (*read_value).data ();
       arm_extract_return_value (valtype, regcache, readbuf);
     }
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f4b8c272f65..07f616338a6 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1856,7 +1856,7 @@  extract_bitfield_from_watchpoint_value (struct watchpoint *w, struct value *val)
   if (val == NULL)
     return NULL;
 
-  bit_val = allocate_value (val->type ());
+  bit_val = value::allocate (val->type ());
 
   unpack_value_bitfield (bit_val,
 			 w->val_bitpos,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a2c50c3ba74..255901887d6 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -673,7 +673,7 @@  c_string_operation::evaluate (struct type *expect_type,
 	      > (high_bound - low_bound + 1))
 	    error (_("Too many array elements"));
 
-	  result = allocate_value (expect_type);
+	  result = value::allocate (expect_type);
 	  memcpy (value_contents_raw (result).data (), obstack_base (&output),
 		  obstack_object_size (&output));
 	}
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 7267d607916..ce4bf6bc9cd 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -2231,7 +2231,7 @@  value_from_setting (const setting &var, struct gdbarch *gdbarch)
 		if (l->val.has_value ())
 		  value = *l->val;
 		else
-		  return allocate_value (builtin_type (gdbarch)->builtin_void);
+		  return value::allocate (builtin_type (gdbarch)->builtin_void);
 		break;
 	      }
 
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index ebed52c8ea9..268a414a37b 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -761,7 +761,7 @@  test_print_fields (gdbarch *arch)
       FIELD_BITSIZE (*f) = 1;
     }
 
-  value *val = allocate_value (the_struct);
+  value *val = value::allocate (the_struct);
   gdb_byte *contents = value_contents_writeable (val).data ();
   store_unsigned_integer (contents, val->enclosing_type ()->length (),
 			  gdbarch_byte_order (arch), 0xe9);
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index d6ad0f1776b..fc92de85840 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -968,7 +968,7 @@  dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 		   inspecting a register ($pc, $sp, etc.), return a
 		   generic optimized out value instead, so that we show
 		   <optimized out> instead of <not saved>.  */
-		value *tmp = allocate_value (subobj_type);
+		value *tmp = value::allocate (subobj_type);
 		value_contents_copy (tmp, 0, retval, 0,
 				     subobj_type->length ());
 		retval = tmp;
@@ -1019,7 +1019,7 @@  dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 	    if (subobj_offset + len > max)
 	      invalid_synthetic_pointer ();
 
-	    retval = allocate_value (subobj_type);
+	    retval = value::allocate (subobj_type);
 
 	    /* The given offset is relative to the actual object.  */
 	    if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
@@ -1037,7 +1037,7 @@  dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
 	    if (subobj_offset + n > this->m_len)
 	      invalid_synthetic_pointer ();
 
-	    retval = allocate_value (subobj_type);
+	    retval = value::allocate (subobj_type);
 	    bfd_byte *contents = value_contents_raw (retval).data ();
 	    memcpy (contents, this->m_data + subobj_offset, n);
 	  }
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index b1dc5ab72f1..2e0b4a8b45d 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -1514,7 +1514,7 @@  dwarf2_evaluate_loc_desc_full (struct type *type, frame_info_ptr frame,
       if (ex.error == NOT_AVAILABLE_ERROR)
 	{
 	  free_values.free_to_mark ();
-	  retval = allocate_value (subobj_type);
+	  retval = value::allocate (subobj_type);
 	  mark_value_bytes_unavailable (retval, 0,
 					subobj_type->length ());
 	  return retval;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index fb5aa7b8e5b..7da86798454 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9025,7 +9025,7 @@  dwarf2_compute_name (const char *name,
 						      baton->per_objfile);
 		      else if (bytes != NULL)
 			{
-			  v = allocate_value (type);
+			  v = value::allocate (type);
 			  memcpy (value_contents_writeable (v).data (), bytes,
 				  type->length ());
 			}
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 02d473570b0..6107a7fac69 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -922,7 +922,7 @@  elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
   else
     name_at_pc = NULL;
 
-  function = allocate_value (func_func_type);
+  function = value::allocate (func_func_type);
   VALUE_LVAL (function) = lval_memory;
   function->set_address (pc);
 
@@ -1033,11 +1033,11 @@  elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b)
   gdb_assert (b->type == bp_gnu_ifunc_resolver);
   gdb_assert (b->loc->next == NULL);
 
-  func_func = allocate_value (func_func_type);
+  func_func = value::allocate (func_func_type);
   VALUE_LVAL (func_func) = lval_memory;
   func_func->set_address (b->loc->related_address);
 
-  value = allocate_value (value_type);
+  value = value::allocate (value_type);
   gdbarch_return_value_as_value (gdbarch, func_func, value_type, regcache,
 				 &value, NULL);
   resolved_address = value_as_address (value);
diff --git a/gdb/eval.c b/gdb/eval.c
index 28b307f07c9..5f8d294322b 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -666,7 +666,7 @@  evaluate_subexp_do_call (expression *exp, enum noside noside,
 	  if (return_type == NULL)
 	    error_call_unknown_return_type (function_name);
 
-	  return allocate_value (return_type);
+	  return value::allocate (return_type);
 	}
       else
 	error (_("Expression of type other than "
@@ -1880,7 +1880,7 @@  eval_op_type (struct type *expect_type, struct expression *exp,
 	      enum noside noside, struct type *type)
 {
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    return allocate_value (type);
+    return value::allocate (type);
   else
     error (_("Attempt to use a type name as an expression"));
 }
@@ -2162,9 +2162,9 @@  eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
       if (callee_type)
 	{
 	  if ((callee_type->code () == TYPE_CODE_ERROR) && expect_type)
-	    return allocate_value (expect_type);
+	    return value::allocate (expect_type);
 	  else
-	    return allocate_value (callee_type);
+	    return value::allocate (callee_type);
 	}
       else
 	error (_("Expression of type other than "
@@ -2440,7 +2440,7 @@  array_operation::evaluate (struct type *expect_type,
   if (expect_type != nullptr
       && type->code () == TYPE_CODE_STRUCT)
     {
-      struct value *rec = allocate_value (expect_type);
+      struct value *rec = value::allocate (expect_type);
 
       memset (value_contents_raw (rec).data (), '\0', type->length ());
       return evaluate_struct_tuple (rec, exp, noside, nargs);
@@ -2451,7 +2451,7 @@  array_operation::evaluate (struct type *expect_type,
     {
       struct type *range_type = type->index_type ();
       struct type *element_type = type->target_type ();
-      struct value *array = allocate_value (expect_type);
+      struct value *array = value::allocate (expect_type);
       int element_size = check_typedef (element_type)->length ();
       LONGEST low_bound, high_bound, index;
 
@@ -2485,7 +2485,7 @@  array_operation::evaluate (struct type *expect_type,
   if (expect_type != nullptr
       && type->code () == TYPE_CODE_SET)
     {
-      struct value *set = allocate_value (expect_type);
+      struct value *set = value::allocate (expect_type);
       gdb_byte *valaddr = value_contents_raw (set).data ();
       struct type *element_type = type->index_type ();
       struct type *check_type = element_type;
@@ -2569,7 +2569,7 @@  unop_extract_operation::evaluate (struct type *expect_type,
   if (type->length () > old_value->type ()->length ())
     error (_("length type is larger than the value type"));
 
-  struct value *result = allocate_value (type);
+  struct value *result = value::allocate (type);
   value_contents_copy (result, 0, old_value, 0, type->length ());
   return result;
 }
diff --git a/gdb/expop.h b/gdb/expop.h
index 7460343cb48..e53474711fe 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -1618,7 +1618,7 @@  class decltype_operation
 	    if (!TYPE_IS_REFERENCE (type))
 	      {
 		type = lookup_lvalue_reference_type (type);
-		result = allocate_value (type);
+		result = value::allocate (type);
 	      }
 	  }
 
@@ -1653,7 +1653,7 @@  class typeid_operation
     value *result = std::get<0> (m_storage)->evaluate (nullptr, exp,
 						       sub_noside);
     if (noside != EVAL_NORMAL)
-      return allocate_value (cplus_typeid_type (exp->gdbarch));
+      return value::allocate (cplus_typeid_type (exp->gdbarch));
     return cplus_typeid (result);
   }
 
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 68d45168be7..ccaf4fd612f 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -137,7 +137,7 @@  fortran_bounds_all_dims (bool lbound_p,
 				1, ndimensions);
   struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
   struct type *result_type = create_array_type (nullptr, elm_type, range);
-  struct value *result = allocate_value (result_type);
+  struct value *result = value::allocate (result_type);
 
   /* Walk the array dimensions backwards due to the way the array will be
      laid out in memory, the first dimension will be the most inner.  */
@@ -720,7 +720,7 @@  fortran_array_shape (struct gdbarch *gdbarch, const language_defn *lang,
 				1, ndimensions);
   struct type *elm_type = builtin_f_type (gdbarch)->builtin_integer;
   struct type *result_type = create_array_type (nullptr, elm_type, range);
-  struct value *result = allocate_value (result_type);
+  struct value *result = value::allocate (result_type);
   LONGEST elm_len = elm_type->length ();
 
   /* Walk the array dimensions backwards due to the way the array will be
@@ -1440,7 +1440,7 @@  fortran_undetermined::value_subarray (value *array,
 
       /* Now copy the elements from the original ARRAY into the packed
 	 array value DEST.  */
-      struct value *dest = allocate_value (repacked_array_type);
+      struct value *dest = value::allocate (repacked_array_type);
       if (array->lazy ()
 	  || (total_offset + array_slice_type->length ()
 	      > check_typedef (array->type ())->length ()))
diff --git a/gdb/findvar.c b/gdb/findvar.c
index cb4eb758bf2..b59962c65ba 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -586,7 +586,7 @@  language_defn::read_var_value (struct symbol *var,
 	  type = resolve_dynamic_type (type, {}, /* Unused address.  */ 0);
 	}
       /* Put the constant back in target format. */
-      v = allocate_value (type);
+      v = value::allocate (type);
       store_signed_integer (value_contents_raw (v).data (), type->length (),
 			    type_byte_order (type), var->value_longest ());
       VALUE_LVAL (v) = not_lval;
@@ -626,7 +626,7 @@  language_defn::read_var_value (struct symbol *var,
 	  /* Value is a constant byte-sequence and needs no memory access.  */
 	  type = resolve_dynamic_type (type, {}, /* Unused address.  */ 0);
 	}
-      v = allocate_value (type);
+      v = value::allocate (type);
       memcpy (value_contents_raw (v).data (), var->value_bytes (),
 	      type->length ());
       VALUE_LVAL (v) = not_lval;
@@ -801,7 +801,7 @@  default_value_from_register (struct gdbarch *gdbarch, struct type *type,
 			     int regnum, struct frame_id frame_id)
 {
   int len = type->length ();
-  struct value *value = allocate_value (type);
+  struct value *value = value::allocate (type);
   frame_info_ptr frame;
 
   VALUE_LVAL (value) = lval_register;
@@ -895,7 +895,7 @@  value_from_register (struct type *type, int regnum, frame_info_ptr frame)
 	 the corresponding [integer] type (see Alpha).  The assumption
 	 is that gdbarch_register_to_value populates the entire value
 	 including the location.  */
-      v = allocate_value (type);
+      v = value::allocate (type);
       VALUE_LVAL (v) = lval_register;
       VALUE_NEXT_FRAME_ID (v) = get_frame_id (get_next_frame_sentinel_okay (frame));
       VALUE_REGNUM (v) = regnum;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2a1bf31f290..c2253310666 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -931,7 +931,7 @@  struct type
 
   /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
      But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
-     so you only have to call check_typedef once.  Since allocate_value
+     so you only have to call check_typedef once.  Since value::allocate
      calls check_typedef, X->type ()->length () is safe.  */
   ULONGEST length () const
   {
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index f2f8db3aa2c..5857e16ff36 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3093,7 +3093,7 @@  i386_return_value (struct gdbarch *gdbarch, struct value *function,
 
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (type);
+      *read_value = value::allocate (type);
       i386_extract_return_value (gdbarch, type, regcache,
 				 value_contents_raw (*read_value).data ());
     }
@@ -3557,7 +3557,7 @@  i386_pseudo_register_read_value (struct gdbarch *gdbarch,
 {
   struct value *result;
 
-  result = allocate_value (register_type (gdbarch, regnum));
+  result = value::allocate (register_type (gdbarch, regnum));
   VALUE_LVAL (result) = lval_register;
   VALUE_REGNUM (result) = regnum;
 
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 3e0da94ab17..05ae1638857 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -466,7 +466,7 @@  get_call_return_value (struct call_return_meta_info *ri)
   bool stack_temporaries = thread_stack_temporaries_enabled_p (thr);
 
   if (ri->value_type->code () == TYPE_CODE_VOID)
-    retval = allocate_value (ri->value_type);
+    retval = value::allocate (ri->value_type);
   else if (ri->struct_return_p)
     {
       if (stack_temporaries)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9e2512e8446..acf93033a86 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -9197,7 +9197,7 @@  siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
       return allocate_computed_value (type, &siginfo_value_funcs, nullptr);
     }
 
-  return allocate_value (builtin_type (gdbarch)->builtin_void);
+  return value::allocate (builtin_type (gdbarch)->builtin_void);
 }
 
 
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index f7a22b35931..c76f948a3ed 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -177,7 +177,7 @@  lval_func_write (struct value *v, struct value *fromval)
 
   for (i = offset; i < n; i++)
     {
-      struct value *from_elm_val = allocate_value (eltype);
+      struct value *from_elm_val = value::allocate (eltype);
       struct value *to_elm_val = value_subscript (c->val, c->indices[i]);
 
       memcpy (value_contents_writeable (from_elm_val).data (),
@@ -297,7 +297,7 @@  create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
       make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
 
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
-	ret = allocate_value (dst_type);
+	ret = value::allocate (dst_type);
       else
 	{
 	  /* Check whether to create a lvalue or not.  */
@@ -310,7 +310,7 @@  create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
 	    {
 	      int i;
 
-	      ret = allocate_value (dst_type);
+	      ret = value::allocate (dst_type);
 
 	      /* Copy src val contents into the destination value.  */
 	      for (i = 0; i < n; i++)
@@ -464,7 +464,7 @@  opencl_logical_not (struct type *expect_type, struct expression *exp,
       rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
 					   eltype->length (), 0,
 					   highb - lowb + 1);
-      ret = allocate_value (rettype);
+      ret = value::allocate (rettype);
 
       for (i = 0; i < highb - lowb + 1; i++)
 	{
@@ -564,7 +564,7 @@  vector_relop (struct expression *exp, struct value *val1, struct value *val2,
   rettype = lookup_opencl_vector_type (exp->gdbarch, TYPE_CODE_INT,
 				       eltype1->length (), 0,
 				       highb1 - lowb1 + 1);
-  ret = allocate_value (rettype);
+  ret = value::allocate (rettype);
 
   for (i = 0; i < highb1 - lowb1 + 1; i++)
     {
@@ -831,7 +831,7 @@  Cannot perform operation on vectors with different types"));
 	error (_("\
 Cannot perform conditional operation on vectors with different sizes"));
 
-      ret = allocate_value (type2);
+      ret = value::allocate (type2);
 
       for (i = 0; i < highb1 - lowb1 + 1; i++)
 	{
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 918d8aad7da..2084e2b618f 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -254,7 +254,7 @@  ppc_linux_return_value (struct gdbarch *gdbarch, struct value *function,
   gdb_byte *readbuf = nullptr;
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (valtype);
+      *read_value = value::allocate (valtype);
       readbuf = value_contents_raw (*read_value).data ();
     }
 
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index d3afd26c26e..2db6793b507 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -580,7 +580,7 @@  python_xmethod_worker::invoke (struct value *obj,
     }
   else
     {
-      res = allocate_value (lookup_typename (current_language,
+      res = value::allocate (lookup_typename (current_language,
 					     "void", NULL, 0));
     }
 
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 4de7026fc28..4a31dd5e706 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -743,7 +743,7 @@  readable_regcache::cooked_read_value (int regnum)
     {
       struct value *result;
 
-      result = allocate_value (register_type (m_descr->gdbarch, regnum));
+      result = value::allocate (register_type (m_descr->gdbarch, regnum));
       VALUE_LVAL (result) = lval_register;
       VALUE_REGNUM (result) = regnum;
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d34eb56c1b6..375ba4228a2 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -3277,7 +3277,7 @@  riscv_return_value (struct gdbarch  *gdbarch,
 						   arg_type->length ()),
 			     type_byte_order (arg_type),
 			     arg_type->is_unsigned ());
-	      abi_val = allocate_value (info.type);
+	      abi_val = value::allocate (info.type);
 	      unscaled.write (value_contents_raw (abi_val),
 			      type_byte_order (info.type),
 			      info.type->is_unsigned ());
@@ -3291,7 +3291,7 @@  riscv_return_value (struct gdbarch  *gdbarch,
 	}
       else
 	{
-	  abi_val = allocate_value (info.type);
+	  abi_val = value::allocate (info.type);
 	  readbuf = value_contents_raw (abi_val).data ();
 	}
       arg_len = info.type->length ();
@@ -3408,7 +3408,7 @@  riscv_return_value (struct gdbarch  *gdbarch,
 	      unscaled.read (value_contents (abi_val),
 			     type_byte_order (info.type),
 			     info.type->is_unsigned ());
-	      *read_value = allocate_value (arg_type);
+	      *read_value = value::allocate (arg_type);
 	      unscaled.write (value_contents_raw (*read_value),
 			      type_byte_order (arg_type),
 			      arg_type->is_unsigned ());
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 8f0953649ae..edffad4afe7 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1351,7 +1351,7 @@  eval_op_rust_array (struct type *expect_type, struct expression *exp,
     {
       struct type *arraytype
 	= lookup_array_range_type (elt->type (), 0, copies - 1);
-      return allocate_value (arraytype);
+      return value::allocate (arraytype);
     }
 }
 
@@ -1518,7 +1518,7 @@  rust_aggregate_operation::evaluate (struct type *expect_type,
     }
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    result = allocate_value (type);
+    result = value::allocate (type);
   else
     result = value_at_lazy (type, addr);
 
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 6c41cfd04e2..44f16215bb2 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1530,7 +1530,7 @@  sparc32_return_value (struct gdbarch *gdbarch, struct value *function,
 
   if (read_value != nullptr)
     {
-      *read_value = allocate_value (type);
+      *read_value = value::allocate (type);
       gdb_byte *readbuf = value_contents_raw (*read_value).data ();
       sparc32_extract_return_value (type, regcache, readbuf);
     }
diff --git a/gdb/std-regs.c b/gdb/std-regs.c
index 4458c244122..5520789ea95 100644
--- a/gdb/std-regs.c
+++ b/gdb/std-regs.c
@@ -43,7 +43,7 @@  value_of_builtin_frame_fp_reg (frame_info_ptr frame, const void *baton)
   else
     {
       struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-      struct value *val = allocate_value (data_ptr_type);
+      struct value *val = value::allocate (data_ptr_type);
       gdb_byte *buf = value_contents_raw (val).data ();
 
       gdbarch_address_to_pointer (gdbarch, data_ptr_type,
@@ -62,7 +62,7 @@  value_of_builtin_frame_pc_reg (frame_info_ptr frame, const void *baton)
   else
     {
       struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
-      struct value *val = allocate_value (func_ptr_type);
+      struct value *val = value::allocate (func_ptr_type);
       gdb_byte *buf = value_contents_raw (val).data ();
 
       gdbarch_address_to_pointer (gdbarch, func_ptr_type,
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 4c181dc7de7..bd02cae05ee 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -3777,12 +3777,12 @@  sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
 
       type = init_vector_type (builtin_type (gdbarch)->builtin_true_char,
 			       buf->size ());
-      v = allocate_value (type);
+      v = value::allocate (type);
       memcpy (value_contents_raw (v).data (), buf->data (), buf->size ());
       return v;
     }
   else
-    return allocate_value (builtin_type (gdbarch)->builtin_void);
+    return value::allocate (builtin_type (gdbarch)->builtin_void);
 }
 
 #if !defined(HAVE_LIBEXPAT)
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 47eccdbe8a0..5494dde9310 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -701,7 +701,7 @@  value_concat (struct value *arg1, struct value *arg2)
 						lowbound,
 						lowbound + n_elts - 1);
 
-  struct value *result = allocate_value (atype);
+  struct value *result = value::allocate (atype);
   gdb::array_view<gdb_byte> contents = value_contents_raw (result);
   gdb::array_view<const gdb_byte> lhs_contents = value_contents (arg1);
   gdb::array_view<const gdb_byte> rhs_contents = value_contents (arg2);
@@ -854,7 +854,7 @@  fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 
   auto fixed_point_to_value = [type1] (const gdb_mpq &fp)
     {
-      value *fp_val = allocate_value (type1);
+      value *fp_val = value::allocate (type1);
 
       fp.write_fixed_point
 	(value_contents_raw (fp_val),
@@ -1164,7 +1164,7 @@  scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
   if (is_floating_type (type1) || is_floating_type (type2))
     {
       result_type = promotion_type (type1, type2);
-      val = allocate_value (result_type);
+      val = value::allocate (result_type);
 
       struct type *eff_type_v1, *eff_type_v2;
       gdb::byte_vector v1, v2;
@@ -1214,7 +1214,7 @@  scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 
       result_type = type1;
 
-      val = allocate_value (result_type);
+      val = value::allocate (result_type);
       store_signed_integer (value_contents_raw (val).data (),
 			    result_type->length (),
 			    type_byte_order (result_type),
@@ -1360,7 +1360,7 @@  scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 	      error (_("Invalid binary operation on numbers."));
 	    }
 
-	  val = allocate_value (result_type);
+	  val = value::allocate (result_type);
 	  store_unsigned_integer (value_contents_raw (val).data (),
 				  val->type ()->length (),
 				  type_byte_order (result_type),
@@ -1521,7 +1521,7 @@  scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 	      error (_("Invalid binary operation on numbers."));
 	    }
 
-	  val = allocate_value (result_type);
+	  val = value::allocate (result_type);
 	  store_signed_integer (value_contents_raw (val).data (),
 				val->type ()->length (),
 				type_byte_order (result_type),
@@ -1566,7 +1566,7 @@  value_vector_widen (struct value *scalar_value, struct type *vector_type)
       && !value_equal (elval, scalar_value))
     error (_("conversion of scalar to vector involves truncation"));
 
-  value *val = allocate_value (vector_type);
+  value *val = value::allocate (vector_type);
   gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
   int elt_len = eltype->length ();
 
@@ -1613,7 +1613,7 @@  vector_binop (struct value *val1, struct value *val2, enum exp_opcode op)
       || low_bound1 != low_bound2 || high_bound1 != high_bound2)
     error (_("Cannot perform operation on vectors with different types"));
 
-  value *val = allocate_value (type1);
+  value *val = value::allocate (type1);
   gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
   scoped_value_mark mark;
   for (i = 0; i < high_bound1 - low_bound1 + 1; i++)
@@ -1901,7 +1901,7 @@  value_neg (struct value *arg1)
     return value_binop (value_zero (type, not_lval), arg1, BINOP_SUB);
   else if (type->code () == TYPE_CODE_ARRAY && type->is_vector ())
     {
-      struct value *val = allocate_value (type);
+      struct value *val = value::allocate (type);
       struct type *eltype = check_typedef (type->target_type ());
       int i;
       LONGEST low_bound, high_bound;
@@ -1953,7 +1953,7 @@  value_complement (struct value *arg1)
       if (!get_array_bounds (type, &low_bound, &high_bound))
 	error (_("Could not determine the vector bounds"));
 
-      val = allocate_value (type);
+      val = value::allocate (type);
       gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
       int elt_len = eltype->length ();
 
diff --git a/gdb/valops.c b/gdb/valops.c
index 5e6095db81f..b711f3132ae 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -391,7 +391,7 @@  value_cast_to_fixed_point (struct type *to_type, struct value *from_val)
 
   /* Finally, create the result value, and pack the unscaled value
      in it.  */
-  struct value *result = allocate_value (to_type);
+  struct value *result = value::allocate (to_type);
   unscaled.write (value_contents_raw (result),
 		  type_byte_order (to_type),
 		  to_type->is_unsigned ());
@@ -543,7 +543,7 @@  value_cast (struct type *type, struct value *arg2)
     {
       if (is_floating_value (arg2))
 	{
-	  struct value *v = allocate_value (to_type);
+	  struct value *v = value::allocate (to_type);
 	  target_float_convert (value_contents (arg2).data (), type2,
 				value_contents_raw (v).data (), type);
 	  return v;
@@ -557,7 +557,7 @@  value_cast (struct type *type, struct value *arg2)
 				   type2->is_unsigned (),
 				   type2->fixed_point_scaling_factor ());
 
-	  struct value *v = allocate_value (to_type);
+	  struct value *v = value::allocate (to_type);
 	  target_float_from_host_double (value_contents_raw (v).data (),
 					 to_type, mpq_get_d (fp_val.val));
 	  return v;
@@ -618,7 +618,7 @@  value_cast (struct type *type, struct value *arg2)
   else if (code1 == TYPE_CODE_METHODPTR && code2 == TYPE_CODE_INT
 	   && value_as_long (arg2) == 0)
     {
-      struct value *result = allocate_value (to_type);
+      struct value *result = value::allocate (to_type);
 
       cplus_make_method_ptr (to_type,
 			     value_contents_writeable (result).data (), 0, 0);
@@ -954,7 +954,7 @@  value_one (struct type *type)
       if (!get_array_bounds (type1, &low_bound, &high_bound))
 	error (_("Could not determine the vector bounds"));
 
-      val = allocate_value (type);
+      val = value::allocate (type);
       gdb::array_view<gdb_byte> val_contents = value_contents_writeable (val);
       int elt_len = eltype->length ();
 
@@ -1724,7 +1724,7 @@  value_array (int lowbound, int highbound, struct value **elemvec)
 
   if (!current_language->c_style_arrays_p ())
     {
-      val = allocate_value (arraytype);
+      val = value::allocate (arraytype);
       for (idx = 0; idx < nelem; idx++)
 	value_contents_copy (val, idx * typelength, elemvec[idx], 0,
 			     typelength);
@@ -1734,7 +1734,7 @@  value_array (int lowbound, int highbound, struct value **elemvec)
   /* Allocate space to store the array, and then initialize it by
      copying in each element.  */
 
-  val = allocate_value (arraytype);
+  val = value::allocate (arraytype);
   for (idx = 0; idx < nelem; idx++)
     value_contents_copy (val, idx * typelength, elemvec[idx], 0, typelength);
   return val;
@@ -1749,7 +1749,7 @@  value_cstring (const char *ptr, ssize_t len, struct type *char_type)
   struct type *stringtype
     = lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
 
-  val = allocate_value (stringtype);
+  val = value::allocate (stringtype);
   memcpy (value_contents_raw (val).data (), ptr, len);
   return val;
 }
@@ -1772,7 +1772,7 @@  value_string (const char *ptr, ssize_t len, struct type *char_type)
   struct type *stringtype
     = lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
 
-  val = allocate_value (stringtype);
+  val = value::allocate (stringtype);
   memcpy (value_contents_raw (val).data (), ptr, len);
   return val;
 }
@@ -3598,7 +3598,7 @@  value_struct_elt_for_reference (struct type *domain, int offset,
 	      (lookup_memberptr_type (t->field (i).type (), domain),
 	       offset + (LONGEST) (t->field (i).loc_bitpos () >> 3));
 	  else if (noside != EVAL_NORMAL)
-	    return allocate_value (t->field (i).type ());
+	    return value::allocate (t->field (i).type ());
 	  else
 	    {
 	      /* Try to evaluate NAME as a qualified name with implicit
@@ -3737,14 +3737,14 @@  value_struct_elt_for_reference (struct type *domain, int offset,
 	    {
 	      if (want_address)
 		{
-		  result = allocate_value
+		  result = value::allocate
 		    (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
 		  cplus_make_method_ptr (result->type (),
 					 value_contents_writeable (result).data (),
 					 TYPE_FN_FIELD_VOFFSET (f, j), 1);
 		}
 	      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-		return allocate_value (TYPE_FN_FIELD_TYPE (f, j));
+		return value::allocate (TYPE_FN_FIELD_TYPE (f, j));
 	      else
 		error (_("Cannot reference virtual member function \"%s\""),
 		       name);
@@ -3763,7 +3763,7 @@  value_struct_elt_for_reference (struct type *domain, int offset,
 		result = v;
 	      else
 		{
-		  result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
+		  result = value::allocate (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
 		  cplus_make_method_ptr (result->type (),
 					 value_contents_writeable (result).data (),
 					 v->address (), 0);
@@ -3839,7 +3839,7 @@  value_maybe_namespace_elt (const struct type *curtype,
     return NULL;
   else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
 	   && (sym.symbol->aclass () == LOC_TYPEDEF))
-    result = allocate_value (sym.symbol->type ());
+    result = value::allocate (sym.symbol->type ());
   else
     result = value_of_variable (sym.symbol, sym.block);
 
@@ -4082,7 +4082,7 @@  value_slice (struct value *array, int lowbound, int length)
       slice = value::allocate_lazy (slice_type);
     else
       {
-	slice = allocate_value (slice_type);
+	slice = value::allocate (slice_type);
 	value_contents_copy (slice, 0, array, offset,
 			     type_length_units (slice_type));
       }
@@ -4104,7 +4104,7 @@  value_literal_complex (struct value *arg1,
   struct value *val;
   struct type *real_type = type->target_type ();
 
-  val = allocate_value (type);
+  val = value::allocate (type);
   arg1 = value_cast (real_type, arg1);
   arg2 = value_cast (real_type, arg2);
 
@@ -4153,8 +4153,8 @@  cast_into_complex (struct type *type, struct value *val)
   if (val->type ()->code () == TYPE_CODE_COMPLEX)
     {
       struct type *val_real_type = val->type ()->target_type ();
-      struct value *re_val = allocate_value (val_real_type);
-      struct value *im_val = allocate_value (val_real_type);
+      struct value *re_val = value::allocate (val_real_type);
+      struct value *im_val = value::allocate (val_real_type);
       int len = val_real_type->length ();
 
       copy (value_contents (val).slice (0, len),
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 20cf64ad2c4..4a2aa5f4878 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -3091,7 +3091,7 @@  test_print_flags (gdbarch *arch)
   append_flags_type_field (flags_type, 3, 2, field_type, "B");
   append_flags_type_field (flags_type, 5, 3, field_type, "C");
 
-  value *val = allocate_value (flags_type);
+  value *val = value::allocate (flags_type);
   gdb_byte *contents = value_contents_writeable (val).data ();
   store_unsigned_integer (contents, 4, gdbarch_byte_order (arch), 0xaa);
 
diff --git a/gdb/value.c b/gdb/value.c
index 772e6f47644..2fb226a94f6 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -834,10 +834,8 @@  allocate_value_contents (struct value *val)
     }
 }
 
-/* Allocate a  value  and its contents for type TYPE.  */
-
 struct value *
-allocate_value (struct type *type)
+value::allocate (struct type *type)
 {
   struct value *val = value::allocate_lazy (type);
 
@@ -861,7 +859,7 @@  allocate_repeat_value (struct type *type, int count)
   struct type *array_type
     = lookup_array_range_type (type, low_bound, count + low_bound - 1);
 
-  return allocate_value (array_type);
+  return value::allocate (array_type);
 }
 
 struct value *
@@ -1417,7 +1415,7 @@  value_copy (const value *arg)
   if (arg->lazy ())
     val = value::allocate_lazy (encl_type);
   else
-    val = allocate_value (encl_type);
+    val = value::allocate (encl_type);
   val->m_type = arg->m_type;
   VALUE_LVAL (val) = arg->m_lval;
   val->m_location = arg->m_location;
@@ -1481,7 +1479,7 @@  value_non_lval (struct value *arg)
   if (VALUE_LVAL (arg) != not_lval)
     {
       struct type *enc_type = arg->enclosing_type ();
-      struct value *val = allocate_value (enc_type);
+      struct value *val = value::allocate (enc_type);
 
       copy (value_contents_all (arg), value_contents_all_raw (val));
       val->m_type = arg->m_type;
@@ -1913,18 +1911,18 @@  value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var)
 	val = value_from_longest (builtin_type (gdbarch)->builtin_int64,
 				  tsv->value);
       else
-	val = allocate_value (builtin_type (gdbarch)->builtin_void);
+	val = value::allocate (builtin_type (gdbarch)->builtin_void);
       return val;
     }
 
   switch (var->kind)
     {
     case INTERNALVAR_VOID:
-      val = allocate_value (builtin_type (gdbarch)->builtin_void);
+      val = value::allocate (builtin_type (gdbarch)->builtin_void);
       break;
 
     case INTERNALVAR_FUNCTION:
-      val = allocate_value (builtin_type (gdbarch)->internal_fn);
+      val = value::allocate (builtin_type (gdbarch)->internal_fn);
       break;
 
     case INTERNALVAR_INTEGER:
@@ -2402,7 +2400,7 @@  value_from_xmethod (xmethod_worker_up &&worker)
 {
   struct value *v;
 
-  v = allocate_value (builtin_type (target_gdbarch ())->xmethod);
+  v = value::allocate (builtin_type (target_gdbarch ())->xmethod);
   v->m_lval = lval_xcallable;
   v->m_location.xm_worker = worker.release ();
   v->m_modifiable = 0;
@@ -2825,7 +2823,7 @@  value_primitive_field (struct value *arg1, LONGEST offset,
 	v = value::allocate_lazy (arg1->enclosing_type ());
       else
 	{
-	  v = allocate_value (arg1->enclosing_type ());
+	  v = value::allocate (arg1->enclosing_type ());
 	  value_contents_copy_raw (v, 0, arg1, 0,
 				   arg1->enclosing_type ()->length ());
 	}
@@ -2858,7 +2856,7 @@  value_primitive_field (struct value *arg1, LONGEST offset,
 	v = value::allocate_lazy (type);
       else
 	{
-	  v = allocate_value (type);
+	  v = value::allocate (type);
 	  value_contents_copy_raw (v, v->embedded_offset (),
 				   arg1, arg1->embedded_offset () + offset,
 				   type_length_units (type));
@@ -2906,7 +2904,7 @@  value_fn_field (struct value **arg1p, struct fn_field *f,
 	return NULL;
     }
 
-  v = allocate_value (ftype);
+  v = value::allocate (ftype);
   VALUE_LVAL (v) = lval_memory;
   if (sym)
     {
@@ -3095,7 +3093,7 @@  value_field_bitfield (struct type *type, int fieldno,
 {
   int bitpos = type->field (fieldno).loc_bitpos ();
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
-  struct value *res_val = allocate_value (type->field (fieldno).type ());
+  struct value *res_val = value::allocate (type->field (fieldno).type ());
 
   unpack_value_bitfield (res_val, bitpos, bitsize,
 			 valaddr, embedded_offset, val);
@@ -3272,7 +3270,7 @@  value_zero (struct type *type, enum lval_type lv)
 struct value *
 value_from_longest (struct type *type, LONGEST num)
 {
-  struct value *val = allocate_value (type);
+  struct value *val = value::allocate (type);
 
   pack_long (value_contents_raw (val).data (), type, num);
   return val;
@@ -3284,7 +3282,7 @@  value_from_longest (struct type *type, LONGEST num)
 struct value *
 value_from_ulongest (struct type *type, ULONGEST num)
 {
-  struct value *val = allocate_value (type);
+  struct value *val = value::allocate (type);
 
   pack_unsigned_long (value_contents_raw (val).data (), type, num);
 
@@ -3298,7 +3296,7 @@  value_from_ulongest (struct type *type, ULONGEST num)
 struct value *
 value_from_pointer (struct type *type, CORE_ADDR addr)
 {
-  struct value *val = allocate_value (type);
+  struct value *val = value::allocate (type);
 
   store_typed_address (value_contents_raw (val).data (),
 		       check_typedef (type), addr);
@@ -3312,7 +3310,7 @@  value_from_pointer (struct type *type, CORE_ADDR addr)
 struct value *
 value_from_host_double (struct type *type, double d)
 {
-  struct value *value = allocate_value (type);
+  struct value *value = value::allocate (type);
   gdb_assert (type->code () == TYPE_CODE_FLT);
   target_float_from_host_double (value_contents_raw (value).data (),
 				 value->type (), d);
@@ -3379,7 +3377,7 @@  value_from_contents (struct type *type, const gdb_byte *contents)
 {
   struct value *result;
 
-  result = allocate_value (type);
+  result = value::allocate (type);
   memcpy (value_contents_raw (result).data (), contents, type->length ());
   return result;
 }
@@ -3459,7 +3457,7 @@  value_from_component (struct value *whole, struct type *type, LONGEST offset)
     v = value::allocate_lazy (type);
   else
     {
-      v = allocate_value (type);
+      v = value::allocate (type);
       value_contents_copy (v, v->embedded_offset (),
 			   whole, whole->embedded_offset () + offset,
 			   type_length_units (type));
@@ -3486,7 +3484,7 @@  value_from_component_bitsize (struct value *whole, struct type *type,
       && bit_length == TARGET_CHAR_BIT * type->length ())
     return value_from_component (whole, type, bit_offset / TARGET_CHAR_BIT);
 
-  struct value *v = allocate_value (type);
+  struct value *v = value::allocate (type);
 
   LONGEST dst_offset = TARGET_CHAR_BIT * v->embedded_offset ();
   if (is_scalar_type (type) && type_byte_order (type) == BFD_ENDIAN_BIG)
diff --git a/gdb/value.h b/gdb/value.h
index 26f09cf0896..b8ead79a61c 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -165,6 +165,9 @@  struct value
      NULL; it will be allocated when it is fetched from the target.  */
   static struct value *allocate_lazy (struct type *type);
 
+  /* Allocate a value and its contents for type TYPE.  */
+  static struct value *allocate (struct type *type);
+
   ~value ();
 
   DISABLE_COPY_AND_ASSIGN (value);
@@ -999,8 +1002,6 @@  extern struct value *read_var_value (struct symbol *var,
 				     const struct block *var_block,
 				     frame_info_ptr frame);
 
-extern struct value *allocate_value (struct type *type);
-
 extern void value_contents_copy (struct value *dst, LONGEST dst_offset,
 				 struct value *src, LONGEST src_offset,
 				 LONGEST length);
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index af21aa159f4..741333cf677 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -436,7 +436,7 @@  tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
       return allocate_computed_value (type, &tlb_value_funcs, NULL);
     }
 
-  return allocate_value (builtin_type (gdbarch)->builtin_void);
+  return value::allocate (builtin_type (gdbarch)->builtin_void);
 }