]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Rely on value_ref_ptr::operator->
authorTom Tromey <tom@tromey.com>
Fri, 10 Feb 2023 17:48:50 +0000 (10:48 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 13 Feb 2023 22:24:27 +0000 (15:24 -0700)
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.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-varobj.c
gdb/breakpoint.c
gdb/c-varobj.c
gdb/printcmd.c
gdb/value.c
gdb/varobj.c

index 63e851e7ae5cf820248301b7bf9ff74c57e39790..d4db032cbc1b40a41c431c27603b719ba942bb2c 100644 (file)
@@ -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 ();
index ebb28432cab625d58588e524edc48b2d29770711..3b9aebc56056deaba3b11d42f93e403c75b42f7f 100644 (file)
@@ -4415,7 +4415,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
@@ -10316,7 +10316,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
index 3e3919a65c0bd9c92b6dd279052904a53ffd0242..ef4d0bd5047073ccce6b228cdcf434a64515c007 100644 (file)
@@ -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.  */
index 13945abc36cc3d35e250c96d26a106c2585808d0..df47bccc326210980ce621787e1cb9a00fde6dab 100644 (file)
@@ -1934,7 +1934,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));
@@ -1943,7 +1943,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 ());
index 0adf6faa152d72c702e474eaab0cb4f33316aaa2..7873aeb9558ef6a32772903e746b94be6f6f4143 100644 (file)
@@ -1347,7 +1347,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 ()));
@@ -1707,7 +1707,7 @@ access_value_history (int num)
 
   absnum--;
 
-  return value_history[absnum].get ()->copy ();
+  return value_history[absnum]->copy ();
 }
 
 /* See value.h.  */
@@ -2400,7 +2400,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
@@ -2419,7 +2419,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 ());
@@ -4097,10 +4097,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 */
index 37b64a0c4bda618ebe7bc31afb7ee40ff4639aa5..7f34cd01e26d1b789cf16e61f6e2b999391aad8b 100644 (file)
@@ -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);