Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 01/23] gdb/dwarf: change die_needs_namespace to return bool
Date: Wed, 11 Mar 2026 14:05:26 -0400	[thread overview]
Message-ID: <20260311180825.720803-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260311180825.720803-1-simon.marchi@efficios.com>

Change the return type to bool, and do some other trivial refactoring:

 - remove unnecessary `attr` variable, which I don't think helps code
   readability
 - change an `if (cond) return false; return true` pattern to be just
   one return expression.

Change-Id: I647c3ad73af94bb76c4b59f580bbdfd1eef45888
---
 gdb/dwarf2/read.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 25ea7644ed08..d52f0651de1b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -4980,11 +4980,9 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
    needs to have the name of the scope prepended to the name listed in the
    die.  */
 
-static int
+static bool
 die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
 {
-  struct attribute *attr;
-
   if (tag_is_type (die->tag) && die->tag != DW_TAG_template_type_param)
     {
       /* Historically GNAT emitted some types in funny scopes.  For
@@ -4997,7 +4995,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
 	  .    DW_AT_name: natural
 
 	  To detect this, we look up the DIE tree for a node that has
-	  a name; and if that name is fully qualified, we return 0
+	  a name; and if that name is fully qualified, we return false
 	  here.  */
       if (cu->lang () == language_ada)
 	{
@@ -5013,7 +5011,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
 		}
 	    }
 	}
-      return 1;
+      return true;
     }
 
   switch (die->tag)
@@ -5024,7 +5022,7 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_entry_point:
     case DW_TAG_member:
     case DW_TAG_imported_declaration:
-      return 1;
+      return true;
 
     case DW_TAG_module:
       /* We don't need the namespace for Fortran modules, but we do
@@ -5046,22 +5044,21 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
 				      spec_cu);
 	}
 
-      attr = dwarf2_attr (die, DW_AT_external, cu);
-      if (attr == NULL && die->parent->tag != DW_TAG_namespace
+      if (dwarf2_attr (die, DW_AT_external, cu) == nullptr
+	  && die->parent->tag != DW_TAG_namespace
 	  && die->parent->tag != DW_TAG_module)
-	return 0;
+	return false;
+
       /* A variable in a lexical block of some kind does not need a
 	 namespace, even though in C++ such variables may be external
 	 and have a mangled name.  */
-      if (die->parent->tag ==  DW_TAG_lexical_block
-	  || die->parent->tag ==  DW_TAG_try_block
-	  || die->parent->tag ==  DW_TAG_catch_block
-	  || die->parent->tag == DW_TAG_subprogram)
-	return 0;
-      return 1;
+      return (die->parent->tag != DW_TAG_lexical_block
+	      && die->parent->tag != DW_TAG_try_block
+	      && die->parent->tag != DW_TAG_catch_block
+	      && die->parent->tag != DW_TAG_subprogram);
 
     default:
-      return 0;
+      return false;
     }
 }
 
-- 
2.53.0


  reply	other threads:[~2026-03-11 18:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 18:05 [PATCH 00/23] int -> bool in dwarf2/ Simon Marchi
2026-03-11 18:05 ` Simon Marchi [this message]
2026-03-11 18:05 ` [PATCH 02/23] gdb/dwarf: change dwarf2_flag_true_p to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 03/23] gdb/dwarf: change die_is_declaration " Simon Marchi
2026-03-11 18:05 ` [PATCH 04/23] gdb/dwarf: change need_gnat_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 05/23] gdb/dwarf: change attr_to_dynamic_prop " Simon Marchi
2026-03-11 18:05 ` [PATCH 06/23] gdb/dwarf: change dwarf2_is_constructor " Simon Marchi
2026-03-11 18:05 ` [PATCH 07/23] gdb/dwarf: change is_vtable_name " Simon Marchi
2026-03-11 18:05 ` [PATCH 08/23] gdb/dwarf: change prototyped_function_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 09/23] gdb/dwarf: change dwarf2_ranges_process " Simon Marchi
2026-03-11 18:05 ` [PATCH 10/23] gdb/dwarf: change dwarf2_ranges_read " Simon Marchi
2026-03-12 12:44   ` Tom Tromey
2026-03-12 14:21     ` Simon Marchi
2026-03-11 18:05 ` [PATCH 11/23] gdb/dwarf: change unavailable_retaddr and undefined_retaddr to bool Simon Marchi
2026-03-11 18:05 ` [PATCH 12/23] gdb/dwarf: change frame_is_tailcall to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 13/23] gdb/dwarf: change call_site_parameter_matches " Simon Marchi
2026-03-11 18:05 ` [PATCH 14/23] gdb/dwarf: change dwarf2_fetch_cfa_info " Simon Marchi
2026-03-11 18:05 ` [PATCH 15/23] gdb/dwarf: change dwarf2_locexpr_baton_eval " Simon Marchi
2026-03-11 18:05 ` [PATCH 16/23] gdb/dwarf: change base_types_equal_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 17/23] gdb/dwarf: change dwarf2_frame_signal_frame_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 18/23] gdb/dwarf: change piece_end_p " Simon Marchi
2026-03-11 18:05 ` [PATCH 19/23] gdb/dwarf: define type aliases for dwarf2_frame_ops function types Simon Marchi
2026-03-11 18:05 ` [PATCH 20/23] gdb/dwarf: change dwarf2_frame_ops to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 21/23] gdb/dwarf: use true/false in read_gdb_index_from_buffer Simon Marchi
2026-03-11 18:05 ` [PATCH 22/23] gdb/dwarf: change dwarf_block_to_sp_offset to return bool Simon Marchi
2026-03-11 18:05 ` [PATCH 23/23] gdb/dwarf: change dwarf_block_to_fb_offset " Simon Marchi
2026-03-12 12:59 ` [PATCH 00/23] int -> bool in dwarf2/ Tom Tromey
2026-03-12 14:21   ` Simon Marchi

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=20260311180825.720803-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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