Add ATTRIBUTE_UNUSED_RESULT to ref_ptr::release
authorTom Tromey <tromey@adacore.com>
Tue, 26 Feb 2019 21:59:47 +0000 (14:59 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 5 Mar 2019 15:48:40 +0000 (08:48 -0700)
This applies ATTRIBUTE_UNUSED_RESULT to ref_ptr::release and updates a
few spots to comply.  I believe one use in install_default_visualizer
was in error, fixed by this patch.

gdb/ChangeLog
2019-03-05  Tom Tromey  <tromey@adacore.com>

* varobj.c (update_dynamic_varobj_children): Update.
(install_default_visualizer): Use reset, not release.
* value.c (set_internalvar): Update.
* dwarf2loc.c (value_of_dwarf_reg_entry): Update.
* common/gdb_ref_ptr.h (class ref_ptr) <release>: Add
ATTRIBUTE_UNUSED_RESULT.

gdb/ChangeLog
gdb/common/gdb_ref_ptr.h
gdb/dwarf2loc.c
gdb/value.c
gdb/varobj.c

index 6ed91e2894caa3f0c8135f73f1873c64362f647e..bb94ae250630fa40077f11ac9fd562e3e947c75f 100644 (file)
@@ -1,3 +1,12 @@
+2019-03-05  Tom Tromey  <tromey@adacore.com>
+
+       * varobj.c (update_dynamic_varobj_children): Update.
+       (install_default_visualizer): Use reset, not release.
+       * value.c (set_internalvar): Update.
+       * dwarf2loc.c (value_of_dwarf_reg_entry): Update.
+       * common/gdb_ref_ptr.h (class ref_ptr) <release>: Add
+       ATTRIBUTE_UNUSED_RESULT.
+
 2019-03-05  Tom Tromey  <tromey@adacore.com>
 
        * remote.c (class scoped_remote_fd) <release>: Add
index b104556cc5f4251cb46a027a061a33cce6419933..c31c9a2e58b8bceb5df556b37d3f740438a9ac9f 100644 (file)
@@ -135,7 +135,7 @@ class ref_ptr
   /* Return this instance's referent, and stop managing this
      reference.  The caller is now responsible for the ownership of
      the reference.  */
-  T *release ()
+  ATTRIBUTE_UNUSED_RESULT T *release ()
   {
     T *result = m_obj;
 
index 9c974a11133d1c1dcb8c4ecdea9733469ed771dc..29d289b4d0c3136afa1453b7f67ce91d857607cf 100644 (file)
@@ -1472,9 +1472,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
                                               target_type, caller_frame,
                                               caller_per_cu);
 
-  release_value (target_val).release ();
   val = allocate_computed_value (type, &entry_data_value_funcs,
-                                target_val /* closure */);
+                                release_value (target_val).release ());
 
   /* Copy the referencing pointer to the new computed value.  */
   memcpy (value_contents_raw (val), value_contents_raw (outer_val),
index 95b6a56f32e69ae28a1de370e728fee6e5fec46b..50e47a936aa37d35574f94ab3950d2acfa53bddf 100644 (file)
@@ -2274,20 +2274,20 @@ set_internalvar (struct internalvar *var, struct value *val)
 
     default:
       new_kind = INTERNALVAR_VALUE;
-      new_data.value = value_copy (val);
-      new_data.value->modifiable = 1;
+      struct value *copy = value_copy (val);
+      copy->modifiable = 1;
 
       /* Force the value to be fetched from the target now, to avoid problems
         later when this internalvar is referenced and the target is gone or
         has changed.  */
-      if (value_lazy (new_data.value))
-       value_fetch_lazy (new_data.value);
+      if (value_lazy (copy))
+       value_fetch_lazy (copy);
 
       /* Release the value from the value chain to prevent it from being
         deleted by free_all_values.  From here on this function should not
         call error () until new_data is installed into the var->u to avoid
         leaking memory.  */
-      release_value (new_data.value).release ();
+      new_data.value = release_value (copy).release ();
 
       /* Internal variables which are created from values with a dynamic
          location don't need the location property of the origin anymore.
index b03307068f30a4b3a1ff984cb4a539bb6848f024..3715bb6a7dfe216f9a0ed42b067479e1d14f7160 100644 (file)
@@ -760,7 +760,7 @@ update_dynamic_varobj_children (struct varobj *var,
          /* Release vitem->value so its lifetime is not bound to the
             execution of a command.  */
          if (item != NULL && item->value != NULL)
-           release_value (item->value).release ();
+           item->value = release_value (item->value).release ();
        }
 
       if (item == NULL)
@@ -1127,7 +1127,7 @@ install_default_visualizer (struct varobj *var)
        }
 
       if (pretty_printer == Py_None)
-       pretty_printer.release ();
+       pretty_printer.reset (nullptr);
   
       install_visualizer (var->dynamic, NULL, pretty_printer.release ());
     }
This page took 0.033827 seconds and 4 git commands to generate.