[30/47] Turn value_bits_synthetic_pointer into a method

Message ID 20230209-submit-value-fixups-2023-v1-30-55dc2794dbb9@tromey.com
State Committed
Commit e989e63761c66d632e1e3b9b40feb12e76cc5dd3
Headers
Series Use methods for struct value |

Commit Message

Tom Tromey Feb. 9, 2023, 9:38 p.m. UTC
  This changes value_bits_synthetic_pointer to be a method of value.
---
 gdb/cp-valprint.c |  6 +++---
 gdb/dwarf2/expr.c |  4 ++--
 gdb/opencl-lang.c |  5 ++---
 gdb/p-valprint.c  |  6 +++---
 gdb/valops.c      |  4 ++--
 gdb/valprint.c    |  9 ++++-----
 gdb/value.c       | 12 +++++-------
 gdb/value.h       | 11 +++++------
 8 files changed, 26 insertions(+), 31 deletions(-)
  

Patch

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index dd396825798..5f18d372aa3 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -270,9 +270,9 @@  cp_print_value_fields (struct value *val, struct ui_file *stream,
 		  fputs_styled ("<optimized out or zero length>",
 				metadata_style.style (), stream);
 		}
-	      else if (value_bits_synthetic_pointer
-			 (val, type->field (i).loc_bitpos (),
-			  TYPE_FIELD_BITSIZE (type, i)))
+	      else if (val->bits_synthetic_pointer
+		       (type->field (i).loc_bitpos (),
+			TYPE_FIELD_BITSIZE (type, i)))
 		{
 		  fputs_styled (_("<synthetic pointer>"),
 				metadata_style.style (), stream);
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index e08dca01a67..ef93b89aaa9 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -576,8 +576,8 @@  coerce_pieced_ref (const value *value)
 {
   struct type *type = check_typedef (value->type ());
 
-  if (value_bits_synthetic_pointer (value, value->embedded_offset (),
-				    TARGET_CHAR_BIT * type->length ()))
+  if (value->bits_synthetic_pointer (value->embedded_offset (),
+				     TARGET_CHAR_BIT * type->length ()))
     {
       const piece_closure *closure
 	= (piece_closure *) value->computed_closure ();
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 8bc727cdfdf..e4a88a23d49 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -215,9 +215,8 @@  lval_func_check_synthetic_pointer (const struct value *v,
       int comp_offset = (i == start) ? startrest : 0;
       int comp_length = (i == end) ? endrest : elsize;
 
-      if (!value_bits_synthetic_pointer (c->val,
-					 c->indices[i] * elsize + comp_offset,
-					 comp_length))
+      if (!c->val->bits_synthetic_pointer (c->indices[i] * elsize + comp_offset,
+					   comp_length))
 	return 0;
     }
 
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index c6b9b5571dd..4b84ec1c43f 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -609,9 +609,9 @@  pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		  fputs_styled ("<optimized out or zero length>",
 				metadata_style.style (), stream);
 		}
-	      else if (value_bits_synthetic_pointer
-			 (val, type->field (i).loc_bitpos (),
-			  TYPE_FIELD_BITSIZE (type, i)))
+	      else if (val->bits_synthetic_pointer
+		       (type->field (i).loc_bitpos (),
+			TYPE_FIELD_BITSIZE (type, i)))
 		{
 		  fputs_styled (_("<synthetic pointer>"),
 				metadata_style.style (), stream);
diff --git a/gdb/valops.c b/gdb/valops.c
index ceec461c483..d2249d79b15 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1556,8 +1556,8 @@  value_addr (struct value *arg1)
 
   if (TYPE_IS_REFERENCE (type))
     {
-      if (value_bits_synthetic_pointer (arg1, arg1->embedded_offset (),
-	  TARGET_CHAR_BIT * type->length ()))
+      if (arg1->bits_synthetic_pointer (arg1->embedded_offset (),
+					TARGET_CHAR_BIT * type->length ()))
 	arg1 = coerce_ref (arg1);
       else
 	{
diff --git a/gdb/valprint.c b/gdb/valprint.c
index decaaa2710c..d94121edd29 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -381,8 +381,8 @@  valprint_check_validity (struct ui_file *stream,
 	  return 0;
 	}
 
-      if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset,
-					TARGET_CHAR_BIT * type->length ()))
+      if (val->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset,
+				       TARGET_CHAR_BIT * type->length ()))
 	{
 	  const int is_ref = type->code () == TYPE_CODE_REF;
 	  int ref_is_addressable = 0;
@@ -568,9 +568,8 @@  generic_val_print_ref (struct type *type,
   struct type *elttype = check_typedef (type->target_type ());
   struct value *deref_val = NULL;
   const int value_is_synthetic
-    = value_bits_synthetic_pointer (original_value,
-				    TARGET_CHAR_BIT * embedded_offset,
-				    TARGET_CHAR_BIT * type->length ());
+    = original_value->bits_synthetic_pointer (TARGET_CHAR_BIT * embedded_offset,
+					      TARGET_CHAR_BIT * type->length ());
   const int must_coerce_ref = ((options->addressprint && value_is_synthetic)
 			       || options->deref_ref);
   const int type_is_defined = elttype->code () != TYPE_CODE_UNDEF;
diff --git a/gdb/value.c b/gdb/value.c
index 342f7edb034..1b304e07204 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1237,15 +1237,13 @@  mark_value_bits_optimized_out (struct value *value,
 }
 
 int
-value_bits_synthetic_pointer (const struct value *value,
-			      LONGEST offset, LONGEST length)
+value::bits_synthetic_pointer (LONGEST offset, LONGEST length) const
 {
-  if (value->m_lval != lval_computed
-      || !value->m_location.computed.funcs->check_synthetic_pointer)
+  if (m_lval != lval_computed
+      || !m_location.computed.funcs->check_synthetic_pointer)
     return 0;
-  return value->m_location.computed.funcs->check_synthetic_pointer (value,
-								  offset,
-								  length);
+  return m_location.computed.funcs->check_synthetic_pointer (this, offset,
+							     length);
 }
 
 const struct lval_funcs *
diff --git a/gdb/value.h b/gdb/value.h
index 2253784aedb..bf5effccfa9 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -456,6 +456,11 @@  struct value
      values.  */
   bool contents_eq (const struct value *val2) const;
 
+  /* Given a value, determine whether the bits starting at OFFSET and
+     extending for LENGTH bits are a synthetic pointer.  */
+
+  int bits_synthetic_pointer (LONGEST offset, LONGEST length) const;
+
 
   /* Type of value; either not an lval, or one of the various
      different possible kinds of lval.  */
@@ -828,12 +833,6 @@  extern struct value *coerce_ref (struct value *value);
 
 extern struct value *coerce_array (struct value *value);
 
-/* Given a value, determine whether the bits starting at OFFSET and
-   extending for LENGTH bits are a synthetic pointer.  */
-
-extern int value_bits_synthetic_pointer (const struct value *value,
-					 LONGEST offset, LONGEST length);
-
 /* Given a value, determine whether the contents bytes starting at
    OFFSET and extending for LENGTH bytes are available.  This returns
    nonzero if all bytes in the given range are available, zero if any