public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v3 06/50] Turn deprecated_set_value_type into a method
Date: Sun, 12 Feb 2023 20:15:22 -0700	[thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v3-6-45e91a20c742@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v3-0-45e91a20c742@tromey.com>

This changes deprecated_set_value_type to be a method of value.  Much
of this patch was written by script.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
 gdb/ada-lang.c     |  6 +++---
 gdb/ada-valprint.c |  2 +-
 gdb/eval.c         |  2 +-
 gdb/gnu-v2-abi.c   |  3 +--
 gdb/i386-tdep.c    |  2 +-
 gdb/objc-lang.c    |  2 +-
 gdb/valops.c       | 19 +++++++++----------
 gdb/value.c        | 11 ++---------
 gdb/value.h        | 13 ++++++-------
 9 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index da49149c56d..c5b5b14163b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2924,7 +2924,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
       memcpy (value_contents_raw (val).data (),
 	      value_contents (fromval).data (),
 	      type->length ());
-      deprecated_set_value_type (val, type);
+      val->deprecated_set_type (type);
 
       return val;
     }
@@ -3033,7 +3033,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind)
 	     than as an access.  Another symptom of the same issue
 	     would be that an expression trying to dereference the
 	     element would also be improperly rejected.  */
-	  deprecated_set_value_type (elt, saved_elt_type);
+	  elt->deprecated_set_type (saved_elt_type);
 	}
 
       elt_type = ada_check_typedef (elt->type ());
@@ -9334,7 +9334,7 @@ coerce_for_assign (struct type *type, struct value *val)
 
       if (type2->target_type ()->length () != type->target_type ()->length ())
 	error (_("Incompatible types in assignment"));
-      deprecated_set_value_type (val, type);
+      val->deprecated_set_type (type);
     }
   return val;
 }
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 1f22ab61ce2..761d3150937 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1029,7 +1029,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
   if (type != saved_type)
     {
       val = value_copy (val);
-      deprecated_set_value_type (val, type);
+      val->deprecated_set_type (type);
     }
 
   if (is_fixed_point_type (type))
diff --git a/gdb/eval.c b/gdb/eval.c
index c24ff258b43..6fa359966ec 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2183,7 +2183,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
       /* Function objc_msg_lookup returns a pointer.  */
       struct type *tem_type = called_method->type ();
       tem_type = lookup_pointer_type (lookup_function_type (tem_type));
-      deprecated_set_value_type (called_method, tem_type);
+      called_method->deprecated_set_type (tem_type);
       called_method = call_function_by_hand (called_method, NULL, args);
     }
 
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index c28df183c8b..b27649051a4 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -174,8 +174,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
   else
     error (_("I'm confused:  virtual function table has bad type"));
   /* Reinstantiate the function pointer with the correct type.  */
-  deprecated_set_value_type (vfn,
-			     lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)));
+  vfn->deprecated_set_type (lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)));
 
   *arg1p = arg1;
   return vfn;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index b799ac5ee27..090f5468067 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3087,7 +3087,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
 	= i386_return_value (gdbarch, function, inner_type, regcache,
 			     read_value, writebuf);
       if (read_value != nullptr)
-	deprecated_set_value_type (*read_value, type);
+	(*read_value)->deprecated_set_type (type);
       return result;
     }
 
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e17a4c406c0..f43d158a770 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -212,7 +212,7 @@ value_nsstring (struct gdbarch *gdbarch, const char *ptr, int len)
   else
     type = lookup_pointer_type(sym->type ());
 
-  deprecated_set_value_type (nsstringValue, type);
+  nsstringValue->deprecated_set_type (type);
   return nsstringValue;
 }
 
diff --git a/gdb/valops.c b/gdb/valops.c
index a56afce0235..1cac2496183 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -319,14 +319,14 @@ value_cast_pointers (struct type *type, struct value *arg2,
 	{
 	  struct value *v = value_addr (v2);
 
-	  deprecated_set_value_type (v, type);
+	  v->deprecated_set_type (type);
 	  return v;
 	}
     }
 
   /* No superclass found, just change the pointer type.  */
   arg2 = value_copy (arg2);
-  deprecated_set_value_type (arg2, type);
+  arg2->deprecated_set_type (type);
   set_value_enclosing_type (arg2, type);
   set_value_pointed_to_offset (arg2, 0);	/* pai: chk_val */
   return arg2;
@@ -429,7 +429,7 @@ value_cast (struct type *type, struct value *arg2)
       if (arg2->type () != type)
 	{
 	  arg2 = value_copy (arg2);
-	  deprecated_set_value_type (arg2, type);
+	  arg2->deprecated_set_type (type);
 	}
       return arg2;
     }
@@ -494,8 +494,7 @@ value_cast (struct type *type, struct value *arg2)
 						 range_type->target_type (),
 						 low_bound,
 						 new_length + low_bound - 1);
-	  deprecated_set_value_type (arg2, 
-				     create_array_type (NULL,
+	  arg2->deprecated_set_type (create_array_type (NULL,
 							element_type, 
 							range_type));
 	  return arg2;
@@ -649,7 +648,7 @@ value_cast (struct type *type, struct value *arg2)
 	return value_cast_pointers (to_type, arg2, 0);
 
       arg2 = value_copy (arg2);
-      deprecated_set_value_type (arg2, to_type);
+      arg2->deprecated_set_type (to_type);
       set_value_enclosing_type (arg2, to_type);
       set_value_pointed_to_offset (arg2, 0);	/* pai: chk_val */
       return arg2;
@@ -1574,7 +1573,7 @@ value_addr (struct value *arg1)
 	    = lookup_pointer_type (enclosing_type->target_type ());
 
 	  arg2 = value_copy (arg1);
-	  deprecated_set_value_type (arg2, type_ptr);
+	  arg2->deprecated_set_type (type_ptr);
 	  set_value_enclosing_type (arg2, enclosing_type_ptr);
 
 	  return arg2;
@@ -1622,7 +1621,7 @@ value_ref (struct value *arg1, enum type_code refcode)
     return arg1;
 
   arg2 = value_addr (arg1);
-  deprecated_set_value_type (arg2, lookup_reference_type (type, refcode));
+  arg2->deprecated_set_type (lookup_reference_type (type, refcode));
   return arg2;
 }
 
@@ -2110,7 +2109,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
 	  else
 	    {
 	      v2 = value_copy (arg1);
-	      deprecated_set_value_type (v2, basetype);
+	      v2->deprecated_set_type (basetype);
 	      set_value_embedded_offset (v2, boffset);
 	    }
 
@@ -3981,7 +3980,7 @@ value_full_object (struct value *argp,
      value_rtti_type used for its computation.  */
   new_val = value_at_lazy (real_type, value_address (argp) - top +
 			   (using_enc ? 0 : value_embedded_offset (argp)));
-  deprecated_set_value_type (new_val, argp->type ());
+  new_val->deprecated_set_type (argp->type ());
   set_value_embedded_offset (new_val, (using_enc
 				       ? top + value_embedded_offset (argp)
 				       : top));
diff --git a/gdb/value.c b/gdb/value.c
index 6f176b0fad9..9347acd09ce 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1024,12 +1024,6 @@ allocate_optimized_out_value (struct type *type)
 
 /* Accessor methods.  */
 
-void
-deprecated_set_value_type (struct value *value, struct type *type)
-{
-  value->m_type = type;
-}
-
 LONGEST
 value_offset (const struct value *value)
 {
@@ -1737,8 +1731,7 @@ make_cv_value (int cnst, int voltl, struct value *v)
   struct type *m_enclosing_type = value_enclosing_type (v);
   struct value *cv_val = value_copy (v);
 
-  deprecated_set_value_type (cv_val,
-			     make_cv_type (cnst, voltl, val_type, NULL));
+  cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL));
   set_value_enclosing_type (cv_val,
 			    make_cv_type (cnst, voltl, m_enclosing_type, NULL));
 
@@ -3836,7 +3829,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type,
 			    original_value_address);
 
   /* Re-adjust type.  */
-  deprecated_set_value_type (value, resolved_original_target_type);
+  value->deprecated_set_type (resolved_original_target_type);
 
   /* Add embedding info.  */
   set_value_enclosing_type (value, enc_type);
diff --git a/gdb/value.h b/gdb/value.h
index 80c92c4753e..2b626adbb29 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -164,6 +164,12 @@ struct value
   struct type *type () const
   { return m_type; }
 
+  /* This is being used to change the type of an existing value, that
+     code should instead be creating a new value with the changed type
+     (but possibly shared content).  */
+  void deprecated_set_type (struct type *type)
+  { m_type = type; }
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -346,13 +352,6 @@ struct value
 
 extern struct gdbarch *get_value_arch (const struct value *value);
 
-/* This is being used to change the type of an existing value, that
-   code should instead be creating a new value with the changed type
-   (but possibly shared content).  */
-
-extern void deprecated_set_value_type (struct value *value,
-				       struct type *type);
-
 /* Only used for bitfields; number of bits contained in them.  */
 
 extern LONGEST value_bitsize (const struct value *);

-- 
2.39.1


  parent reply	other threads:[~2023-02-13  3:15 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13  3:15 [PATCH v3 00/50] Use methods for struct value Tom Tromey
2023-02-13  3:15 ` [PATCH v3 01/50] Automatic date update in version.in Tom Tromey
2023-02-13  3:24   ` Tom Tromey
2023-02-13  3:15 ` [PATCH v3 02/50] Rename all fields of struct value Tom Tromey
2023-02-13  3:15 ` [PATCH v3 03/50] Move ~value body out-of-line Tom Tromey
2023-02-13  3:15 ` [PATCH v3 04/50] Move struct value to value.h Tom Tromey
2023-02-13  3:15 ` [PATCH v3 05/50] Turn value_type into method Tom Tromey
2023-02-13  3:15 ` Tom Tromey [this message]
2023-02-13  3:15 ` [PATCH v3 07/50] Turn value_arch " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 08/50] Turn value_bitsize " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 09/50] Turn value_bitpos " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 10/50] Turn value_parent " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 11/50] Turn value_offset " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 12/50] Turn deprecated_value_modifiable " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 13/50] Turn value_enclosing_type " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 14/50] Turn some value offset functions " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 15/50] Turn value_lazy and set_value_lazy functions into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 16/50] Turn value_stack and set_value_stack " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 17/50] Turn value_computed_closure and value_computed_funcs " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 18/50] Convert value_lval_const and deprecated_lval_hack to methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 19/50] Turn value_initialized and set_value_initialized functions into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 20/50] Turn value_address and set_value_address " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 21/50] Turn more deprecated_* " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 22/50] Turn allocate_value_lazy into a static "constructor" Tom Tromey
2023-02-13  3:15 ` [PATCH v3 23/50] Turn allocate_value " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 24/50] Turn allocate_computed_value into " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 25/50] Turn allocate_optimized_out_value " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 26/50] Turn value_zero " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 27/50] Turn some value_contents functions into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 28/50] Turn value_fetch_lazy into a method Tom Tromey
2023-02-13 17:35   ` Simon Marchi
2023-02-13  3:15 ` [PATCH v3 29/50] Turn allocate_value_contents " Tom Tromey
2023-02-13 17:37   ` Simon Marchi
2023-02-13  3:15 ` [PATCH v3 30/50] Turn value_contents_eq " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 31/50] Turn value_bits_synthetic_pointer " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 32/50] Move value_ref_policy methods out-of-line Tom Tromey
2023-02-13  3:15 ` [PATCH v3 33/50] Turn value_incref and value_decref into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 34/50] Turn remaining value_contents functions " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 35/50] Fully qualify calls to copy in value.c Tom Tromey
2023-02-13  3:15 ` [PATCH v3 36/50] Turn value_copy into a method Tom Tromey
2023-02-13  3:15 ` [PATCH v3 37/50] Turn many optimized-out value functions into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 38/50] Turn value_non_lval and value_force_lval " Tom Tromey
2023-02-13  3:15 ` [PATCH v3 39/50] Turn set_value_component_location into method Tom Tromey
2023-02-13  3:15 ` [PATCH v3 40/50] Change some code to use value methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 41/50] Turn some xmethod functions into methods Tom Tromey
2023-02-13  3:15 ` [PATCH v3 42/50] Turn preserve_one_value into method Tom Tromey
2023-02-13  3:15 ` [PATCH v3 43/50] Turn various value copying-related functions into methods Tom Tromey
2023-02-13  3:16 ` [PATCH v3 44/50] Add value::set_modifiable Tom Tromey
2023-02-13  3:16 ` [PATCH v3 45/50] Turn record_latest_value into a method Tom Tromey
2023-02-13 17:38   ` Simon Marchi
2023-02-13  3:16 ` [PATCH v3 46/50] Make struct value data members private Tom Tromey
2023-02-13  3:16 ` [PATCH v3 47/50] Make ~value private Tom Tromey
2023-02-13  3:16 ` [PATCH v3 48/50] Introduce set_lval method on value Tom Tromey
2023-02-13  3:16 ` [PATCH v3 49/50] Remove deprecated_lval_hack Tom Tromey
2023-02-13 22:26 ` [PATCH v3 00/50] Use methods for struct value 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-v3-6-45e91a20c742@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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).