public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 48/48] Rely on value_ref_ptr::operator->
Date: Fri, 10 Feb 2023 14:53:06 -0700	[thread overview]
Message-ID: <20230209-submit-value-fixups-2023-v2-48-b0b27fd97177@tromey.com> (raw)
In-Reply-To: <20230209-submit-value-fixups-2023-v2-0-b0b27fd97177@tromey.com>

Simon pointed out some spots were doing val.get()->mumble, where val
is a value_ref_ptr.  These were introduced by the function-to-method
script, replacing older code that passed the result of .get() to a
function.

Now that value.h is using methods, we can instead rely on operator->.
This patch replaces all the newly-introduced instances of this.
---
 gdb/ada-varobj.c |  2 +-
 gdb/breakpoint.c |  4 ++--
 gdb/c-varobj.c   |  4 ++--
 gdb/printcmd.c   |  4 ++--
 gdb/value.c      | 14 +++++++-------
 gdb/varobj.c     | 14 +++++++-------
 6 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 63e851e7ae5..d4db032cbc1 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -943,7 +943,7 @@ static bool
 ada_value_is_changeable_p (const struct varobj *var)
 {
   struct type *type = (var->value != nullptr
-		       ? var->value.get ()->type () : var->type);
+		       ? var->value->type () : var->type);
 
   if (type->code () == TYPE_CODE_REF)
     type = type->target_type ();
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 239926ffd4a..42bda879468 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4407,7 +4407,7 @@ bpstat::bpstat (const bpstat &other)
     print_it (other.print_it)
 {
   if (other.old_val != NULL)
-    old_val = release_value (other.old_val.get ()->copy ());
+    old_val = release_value (other.old_val->copy ());
 }
 
 /* Return a copy of a bpstat.  Like "bs1 = bs2" but all storage that
@@ -10285,7 +10285,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
   w->cond_exp_valid_block = cond_exp_valid_block;
   if (just_location)
     {
-      struct type *t = val.get ()->type ();
+      struct type *t = val->type ();
       CORE_ADDR addr = value_as_address (val.get ());
 
       w->exp_string_reparse
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 3e3919a65c0..ef4d0bd5047 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -506,14 +506,14 @@ c_value_of_variable (const struct varobj *var,
 	  }
 	else
 	  {
-	    if (var->not_fetched && var->value.get ()->lazy ())
+	    if (var->not_fetched && var->value->lazy ())
 	      /* Frozen variable and no value yet.  We don't
 		 implicitly fetch the value.  MI response will
 		 use empty string for the value, which is OK.  */
 	      return std::string ();
 
 	    gdb_assert (varobj_value_is_changeable_p (var));
-	    gdb_assert (!var->value.get ()->lazy ());
+	    gdb_assert (!var->value->lazy ());
 	    
 	    /* If the specified format is the current one,
 	       we can reuse print_value.  */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c6b55e97f40..321d0a7b3ca 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1918,7 +1918,7 @@ x_command (const char *exp, int from_tty)
       /* Make last address examined available to the user as $_.  Use
 	 the correct pointer type.  */
       struct type *pointer_type
-	= lookup_pointer_type (last_examine_value.get ()->type ());
+	= lookup_pointer_type (last_examine_value->type ());
       set_internalvar (lookup_internalvar ("_"),
 		       value_from_pointer (pointer_type,
 					   last_examine_address));
@@ -1927,7 +1927,7 @@ x_command (const char *exp, int from_tty)
 	 as $__.  If the last value has not been fetched from memory
 	 then don't fetch it now; instead mark it by voiding the $__
 	 variable.  */
-      if (last_examine_value.get ()->lazy ())
+      if (last_examine_value->lazy ())
 	clear_internalvar (lookup_internalvar ("__"));
       else
 	set_internalvar (lookup_internalvar ("__"), last_examine_value.get ());
diff --git a/gdb/value.c b/gdb/value.c
index 23a0e4abd0f..799af142f2b 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1218,7 +1218,7 @@ value::address () const
   if (m_lval != lval_memory)
     return 0;
   if (m_parent != NULL)
-    return m_parent.get ()->address () + m_offset;
+    return m_parent->address () + m_offset;
   if (NULL != TYPE_DATA_LOCATION (type ()))
     {
       gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type ()));
@@ -1547,7 +1547,7 @@ access_value_history (int num)
 
   absnum--;
 
-  return value_history[absnum].get ()->copy ();
+  return value_history[absnum]->copy ();
 }
 
 /* See value.h.  */
@@ -2240,7 +2240,7 @@ preserve_one_varobj (struct varobj *varobj, struct objfile *objfile,
     }
 
   if (varobj->value != nullptr)
-    varobj->value.get ()->preserve (objfile, copied_types);
+    varobj->value->preserve (objfile, copied_types);
 }
 
 /* Update the internal variables and value history when OBJFILE is
@@ -2259,7 +2259,7 @@ preserve_values (struct objfile *objfile)
   htab_up copied_types = create_copied_types_hash ();
 
   for (const value_ref_ptr &item : value_history)
-    item.get ()->preserve (objfile, copied_types.get ());
+    item->preserve (objfile, copied_types.get ());
 
   for (var = internalvars; var; var = var->next)
     preserve_one_internalvar (var, objfile, copied_types.get ());
@@ -3924,10 +3924,10 @@ test_value_copy ()
   /* Verify that we can copy an entirely optimized out value, that may not have
      its contents allocated.  */
   value_ref_ptr val = release_value (value::allocate_optimized_out (type));
-  value_ref_ptr copy = release_value (val.get ()->copy ());
+  value_ref_ptr copy = release_value (val->copy ());
 
-  SELF_CHECK (val.get ()->entirely_optimized_out ());
-  SELF_CHECK (copy.get ()->entirely_optimized_out ());
+  SELF_CHECK (val->entirely_optimized_out ());
+  SELF_CHECK (copy->entirely_optimized_out ());
 }
 
 } /* namespace selftests */
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 37b64a0c4bd..7f34cd01e26 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -504,7 +504,7 @@ varobj_set_display_format (struct varobj *var,
     }
 
   if (varobj_value_is_changeable_p (var) 
-      && var->value != nullptr && !var->value.get ()->lazy ())
+      && var->value != nullptr && !var->value->lazy ())
     {
       var->print_value = varobj_value_get_print_value (var->value.get (),
 						       var->format, var);
@@ -1007,7 +1007,7 @@ varobj_set_value (struct varobj *var, const char *expression)
   gdb_assert (varobj_value_is_changeable_p (var));
 
   /* The value of a changeable variable object must not be lazy.  */
-  gdb_assert (!var->value.get ()->lazy ());
+  gdb_assert (!var->value->lazy ());
 
   /* Need to coerce the input.  We want to check if the
      value of the variable object will be different
@@ -1312,7 +1312,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
 	{
 	  /* Try to compare the values.  That requires that both
 	     values are non-lazy.  */
-	  if (var->not_fetched && var->value.get ()->lazy ())
+	  if (var->not_fetched && var->value->lazy ())
 	    {
 	      /* This is a frozen varobj and the value was never read.
 		 Presumably, UI shows some "never read" indicator.
@@ -1330,7 +1330,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
 	    }
 	  else
 	    {
-	      gdb_assert (!var->value.get ()->lazy ());
+	      gdb_assert (!var->value->lazy ());
 	      gdb_assert (!value->lazy ());
 
 	      gdb_assert (!var->print_value.empty () && !print_value.empty ());
@@ -1370,7 +1370,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
     }
   var->print_value = print_value;
 
-  gdb_assert (var->value == nullptr || var->value.get ()->type ());
+  gdb_assert (var->value == nullptr || var->value->type ());
 
   return changed;
 }
@@ -1886,7 +1886,7 @@ varobj_get_value_type (const struct varobj *var)
   struct type *type;
 
   if (var->value != nullptr)
-    type = var->value.get ()->type ();
+    type = var->value->type ();
   else
     type = var->type;
 
@@ -2270,7 +2270,7 @@ varobj_editable_p (const struct varobj *var)
   struct type *type;
 
   if (!(var->root->is_valid && var->value != nullptr
-	&& var->value.get ()->lval ()))
+	&& var->value->lval ()))
     return false;
 
   type = varobj_get_value_type (var);

-- 
2.39.1


  parent reply	other threads:[~2023-02-10 23:23 UTC|newest]

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