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 3/6] Change value::m_initialized to bool
Date: Tue, 14 Feb 2023 13:23:33 -0700	[thread overview]
Message-ID: <20230214-submit-more-value-stuff-v1-3-2fb85efbaa72@tromey.com> (raw)
In-Reply-To: <20230214-submit-more-value-stuff-v1-0-2fb85efbaa72@tromey.com>

This changes value::m_initialized to be a bool and updates the various
uses.
---
 gdb/dwarf2/expr.c |  4 ++--
 gdb/dwarf2/expr.h |  6 +++---
 gdb/value.h       | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 60d9bf5f1f9..760c5c4b0d0 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -1496,7 +1496,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
   type *address_type = this->address_type ();
 
   this->m_location = DWARF_VALUE_MEMORY;
-  this->m_initialized = 1;  /* Default is initialized.  */
+  this->m_initialized = true;  /* Default is initialized.  */
 
   if (this->m_recursion_depth > this->m_max_recursion_depth)
     error (_("DWARF-2 expression error: Loop detected (%d)."),
@@ -2192,7 +2192,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
 	    error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "
 		   "be the very last op."));
 
-	  this->m_initialized = 0;
+	  this->m_initialized = false;
 	  goto no_push;
 
 	case DW_OP_call2:
diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h
index 44fc645116a..7a64316160e 100644
--- a/gdb/dwarf2/expr.h
+++ b/gdb/dwarf2/expr.h
@@ -164,9 +164,9 @@ struct dwarf_expr_context
   ULONGEST m_len = 0;
   const gdb_byte *m_data = nullptr;
 
-  /* Initialization status of variable: Non-zero if variable has been
-     initialized; zero otherwise.  */
-  int m_initialized = 0;
+  /* Initialization status of variable: True if variable has been
+     initialized; false otherwise.  */
+  bool m_initialized = false;
 
   /* A vector of pieces.
 
diff --git a/gdb/value.h b/gdb/value.h
index 233f42d32a0..41327ebe3b8 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -134,7 +134,7 @@ struct value
   explicit value (struct type *type_)
     : m_modifiable (true),
       m_lazy (true),
-      m_initialized (1),
+      m_initialized (true),
       m_stack (0),
       m_is_zero (false),
       m_in_history (false),
@@ -338,11 +338,11 @@ struct value
 
   /* Set or return field indicating whether a variable is initialized or
      not, based on debugging information supplied by the compiler.
-     1 = initialized; 0 = uninitialized.  */
-  int initialized () const
+     true = initialized; false = uninitialized.  */
+  bool initialized () const
   { return m_initialized; }
 
-  void set_initialized (int value)
+  void set_initialized (bool value)
   { m_initialized = value; }
 
   /* If lval == lval_memory, return the address in the inferior.  If
@@ -638,7 +638,7 @@ struct value
   bool m_lazy : 1;
 
   /* If value is a variable, is it initialized or not.  */
-  unsigned int m_initialized : 1;
+  bool m_initialized : 1;
 
   /* If value is from the stack.  If this is set, read_stack will be
      used instead of read_memory to enable extra caching.  */

-- 
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 ` Tom Tromey [this message]
2023-02-21 15:10   ` [PATCH 3/6] Change value::m_initialized " 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 ` [PATCH 5/6] Have value::bits_synthetic_pointer return bool Tom Tromey
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-3-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).