public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/6] Have value::bits_synthetic_pointer return bool
Date: Tue, 14 Feb 2023 13:23:35 -0700	[thread overview]
Message-ID: <20230214-submit-more-value-stuff-v1-5-2fb85efbaa72@tromey.com> (raw)
In-Reply-To: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com>

This changes value::bits_synthetic_pointer to return bool and fixes up
some fallout from this.
---
 gdb/dwarf2/expr.c |  6 +++---
 gdb/opencl-lang.c | 10 +++++-----
 gdb/valprint.c    |  2 +-
 gdb/value.c       |  4 ++--
 gdb/value.h       |  6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 3f040e7b2d3..b48bab0b410 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -459,7 +459,7 @@ is_optimized_out_pieced_value (value *v)
 /* An implementation of an lval_funcs method to see whether a value is
    a synthetic pointer.  */
 
-static int
+static bool
 check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset,
 				int bit_length)
 {
@@ -490,10 +490,10 @@ check_pieced_synthetic_pointer (const value *value, LONGEST bit_offset,
 	bit_length -= this_size_bits;
 
       if (p->location != DWARF_VALUE_IMPLICIT_POINTER)
-	return 0;
+	return false;
     }
 
-  return 1;
+  return true;
 }
 
 /* An implementation of an lval_funcs method to indirect through a
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 3e4a9c360b2..ae1a6d4446d 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -187,10 +187,10 @@ lval_func_write (struct value *v, struct value *fromval)
     }
 }
 
-/* Return nonzero if bits in V from OFFSET and LENGTH represent a
+/* Return true if bits in V from OFFSET and LENGTH represent a
    synthetic pointer.  */
 
-static int
+static bool
 lval_func_check_synthetic_pointer (const struct value *v,
 				   LONGEST offset, int length)
 {
@@ -208,7 +208,7 @@ lval_func_check_synthetic_pointer (const struct value *v,
     end++;
 
   if (end > c->n)
-    return 0;
+    return false;
 
   for (i = start; i < end; i++)
     {
@@ -217,10 +217,10 @@ lval_func_check_synthetic_pointer (const struct value *v,
 
       if (!c->val->bits_synthetic_pointer (c->indices[i] * elsize + comp_offset,
 					   comp_length))
-	return 0;
+	return false;
     }
 
-  return 1;
+  return true;
 }
 
 static void *
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 8c067693492..357db3815b0 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -566,7 +566,7 @@ 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
+  const bool value_is_synthetic
     = 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)
diff --git a/gdb/value.c b/gdb/value.c
index 6a8c12823c4..9e561e28551 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1315,12 +1315,12 @@ value::mark_bits_optimized_out (LONGEST offset, LONGEST length)
   insert_into_bit_range_vector (&m_optimized_out, offset, length);
 }
 
-int
+bool
 value::bits_synthetic_pointer (LONGEST offset, LONGEST length) const
 {
   if (m_lval != lval_computed
       || !m_location.computed.funcs->check_synthetic_pointer)
-    return 0;
+    return false;
   return m_location.computed.funcs->check_synthetic_pointer (this, offset,
 							     length);
 }
diff --git a/gdb/value.h b/gdb/value.h
index 4cb6fac4104..5536e00332e 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -475,7 +475,7 @@ struct value
   /* 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;
+  bool bits_synthetic_pointer (LONGEST offset, LONGEST length) const;
 
   /* Increase this value's reference count.  */
   void incref ()
@@ -924,8 +924,8 @@ struct lval_funcs
 
   /* If non-NULL, this is used to determine whether the indicated bits
      of VALUE are a synthetic pointer.  */
-  int (*check_synthetic_pointer) (const struct value *value,
-				  LONGEST offset, int length);
+  bool (*check_synthetic_pointer) (const struct value *value,
+				   LONGEST offset, int length);
 
   /* Return a duplicate of VALUE's closure, for use in a new value.
      This may simply return the same closure, if VALUE's is

-- 
2.39.1


  parent reply	other threads:[~2023-02-14 20:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 20:23 [PATCH 0/6] Use bool in value Tom Tromey
2023-02-14 20:23 ` [PATCH 1/6] Change value::m_modifiable to bool Tom Tromey
2023-02-21 14:36   ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 2/6] Change value::m_lazy " Tom Tromey
2023-02-15 11:53   ` Bruno Larsen
2023-02-15 21:52     ` Tom Tromey
2023-02-14 20:23 ` [PATCH 3/6] Change value::m_initialized " Tom Tromey
2023-02-21 15:10   ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` [PATCH 4/6] Change value::m_stack " Tom Tromey
2023-02-21 15:30   ` Alexandra Petlanova Hajkova
2023-02-14 20:23 ` Tom Tromey [this message]
2023-02-14 20:23 ` [PATCH 6/6] Return bool from more value methods Tom Tromey
2023-02-15 12:22 ` [PATCH 0/6] Use bool in value Bruno Larsen
2023-02-15 21:54   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230214-submit-more-value-stuff-v1-5-2fb85efbaa72@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).