[v2,39/48] Change some code to use value methods

Message ID 20230209-submit-value-fixups-2023-v2-39-b0b27fd97177@tromey.com
State New
Headers
Series Use methods for struct value |

Commit Message

Tom Tromey Feb. 10, 2023, 9:52 p.m. UTC
  A few functions in value.c were accessing the internal fields of
struct value.  However, in these cases it seemed simpler to change
them to use the public API rather than convert them to be methods.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
---
 gdb/value.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
  

Patch

diff --git a/gdb/value.c b/gdb/value.c
index 0d340897f10..b36c77694f6 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -819,7 +819,7 @@  value::allocate (struct type *type)
   struct value *val = value::allocate_lazy (type);
 
   val->allocate_contents ();
-  val->m_lazy = 0;
+  val->set_lazy (0);
   return val;
 }
 
@@ -1930,7 +1930,7 @@  value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var)
      want.  */
 
   if (var->kind != INTERNALVAR_MAKE_VALUE
-      && val->m_lval != lval_computed)
+      && val->lval () != lval_computed)
     {
       VALUE_LVAL (val) = lval_internalvar;
       VALUE_INTERNALVAR (val) = var;
@@ -2742,15 +2742,15 @@  value_primitive_field (struct value *arg1, LONGEST offset,
       LONGEST container_bitsize = type->length () * 8;
 
       v = value::allocate_lazy (type);
-      v->m_bitsize = TYPE_FIELD_BITSIZE (arg_type, fieldno);
-      if ((bitpos % container_bitsize) + v->m_bitsize <= container_bitsize
+      v->set_bitsize (TYPE_FIELD_BITSIZE (arg_type, fieldno));
+      if ((bitpos % container_bitsize) + v->bitsize () <= container_bitsize
 	  && type->length () <= (int) sizeof (LONGEST))
-	v->m_bitpos = bitpos % container_bitsize;
+	v->set_bitpos (bitpos % container_bitsize);
       else
-	v->m_bitpos = bitpos % 8;
-      v->m_offset = (arg1->embedded_offset ()
-		   + offset
-		   + (bitpos - v->m_bitpos) / 8);
+	v->set_bitpos (bitpos % 8);
+      v->set_offset ((arg1->embedded_offset ()
+		      + offset
+		      + (bitpos - v->bitpos ()) / 8));
       v->set_parent (arg1);
       if (!arg1->lazy ())
 	v->fetch_lazy ();
@@ -2786,9 +2786,9 @@  value_primitive_field (struct value *arg1, LONGEST offset,
 	  value_contents_copy_raw (v, 0, arg1, 0,
 				   arg1->enclosing_type ()->length ());
 	}
-      v->m_type = type;
-      v->m_offset = arg1->offset ();
-      v->m_embedded_offset = offset + arg1->embedded_offset () + boffset;
+      v->deprecated_set_type (type);
+      v->set_offset (arg1->offset ());
+      v->set_embedded_offset (offset + arg1->embedded_offset () + boffset);
     }
   else if (NULL != TYPE_DATA_LOCATION (type))
     {
@@ -2820,8 +2820,8 @@  value_primitive_field (struct value *arg1, LONGEST offset,
 				   arg1, arg1->embedded_offset () + offset,
 				   type_length_units (type));
 	}
-      v->m_offset = (arg1->offset () + offset
-		     + arg1->embedded_offset ());
+      v->set_offset ((arg1->offset () + offset
+		      + arg1->embedded_offset ()));
     }
   v->set_component_location (arg1);
   return v;
@@ -3420,7 +3420,7 @@  value_from_component (struct value *whole, struct type *type, LONGEST offset)
 			   whole, whole->embedded_offset () + offset,
 			   type_length_units (type));
     }
-  v->m_offset = whole->offset () + offset + whole->embedded_offset ();
+  v->set_offset (whole->offset () + offset + whole->embedded_offset ());
   v->set_component_location (whole);
 
   return v;