]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use new_reference for struct value
authorTom Tromey <tom@tromey.com>
Mon, 30 Apr 2018 03:07:03 +0000 (21:07 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 30 Apr 2018 17:33:11 +0000 (11:33 -0600)
value_incref returned its argument just as a convenience, which in the
end turned out to only be used in precisely the cases where
new_reference helps.  So, this patch changes value_incref to return
void and changes some value-using code to use new_reference.

I also noticed that the comments for value_incref and value_decref
were swapped, so this patch fixes those.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* varobj.c (install_new_value): Use new_reference.
* value.h (value_incref): Return void.  Swap intro comment with
value_decref.
* value.c (set_value_parent): Use new_reference.
(value_incref): Return void.  Update intro comment.
(release_value): Use new_reference.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use new_reference.

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

index 7da8ca3c2a81956f0218c3972390443ef97f41f9..dbac3e8c9ee6c67cd8efde07eb45a89fcd47520c 100644 (file)
@@ -1,3 +1,13 @@
+2018-04-30  Tom Tromey  <tom@tromey.com>
+
+       * varobj.c (install_new_value): Use new_reference.
+       * value.h (value_incref): Return void.  Swap intro comment with
+       value_decref.
+       * value.c (set_value_parent): Use new_reference.
+       (value_incref): Return void.  Update intro comment.
+       (release_value): Use new_reference.
+       * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use new_reference.
+
 2018-04-30  Tom Tromey  <tom@tromey.com>
 
        * symfile-mem.c (symbol_file_add_from_memory): Use new_reference.
index 243e047b9a7ca4e8644c0710afd6e3ca0e12463a..78d46688bcf38101d746e4fc32fb1269782dea90 100644 (file)
@@ -2482,7 +2482,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
            /* Preserve VALUE because we are going to free values back
               to the mark, but we still need the value contents
               below.  */
-           value_ref_ptr value_holder (value_incref (value));
+           value_ref_ptr value_holder = value_ref_ptr::new_reference (value);
            free_values.free_to_mark ();
 
            retval = allocate_value (subobj_type);
index 12aa2b8bb467bcbd2249ea95aef2e51454611b48..eefaaaab490c2c040fb663784601e950844955a8 100644 (file)
@@ -1133,7 +1133,7 @@ value_parent (const struct value *value)
 void
 set_value_parent (struct value *value, struct value *parent)
 {
-  value->parent = value_ref_ptr (value_incref (parent));
+  value->parent = value_ref_ptr::new_reference (parent);
 }
 
 gdb_byte *
@@ -1572,14 +1572,12 @@ value_mark (void)
   return all_values.back ().get ();
 }
 
-/* Take a reference to VAL.  VAL will not be deallocated until all
-   references are released.  */
+/* See value.h.  */
 
-struct value *
+void
 value_incref (struct value *val)
 {
   val->reference_count++;
-  return val;
 }
 
 /* Release a reference to VAL, which was acquired with value_incref.
@@ -1635,7 +1633,7 @@ release_value (struct value *val)
   /* We must always return an owned reference.  Normally this happens
      because we transfer the reference from the value chain, but in
      this case the value was not on the chain.  */
-  return value_ref_ptr (value_incref (val));
+  return value_ref_ptr::new_reference (val);
 }
 
 /* See value.h.  */
index b58f78998a1f675f18f2e7781940e68b14cec785..4d75c966edd61ce4b9d58bab57649cee8a2b8f2d 100644 (file)
@@ -88,12 +88,12 @@ struct value_print_options;
 
 struct value;
 
-/* Decrease VAL's reference count.  When the reference count drops to
-   0, VAL will be freed.  */
+/* Increase VAL's reference count.  */
 
-extern struct value *value_incref (struct value *val);
+extern void value_incref (struct value *val);
 
-/* Increate VAL's reference count.  VAL is returned.  */
+/* Decrease VAL's reference count.  When the reference count drops to
+   0, VAL will be freed.  */
 
 extern void value_decref (struct value *val);
 
index 2d00964317aa97d346458c1fa99c1c783fd9147c..4656bfa6b9e48d288c6bf886a6b7505d59e55a37 100644 (file)
@@ -1329,7 +1329,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial)
      code that might release it.  */
   value_ref_ptr value_holder;
   if (value != NULL)
-    value_holder.reset (value_incref (value));
+    value_holder = value_ref_ptr::new_reference (value);
 
   /* Below, we'll be comparing string rendering of old and new
      values.  Don't get string rendering if the value is