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@polymtl.ca>
Subject: [PATCH 3/3] gdb: use enumerate in gdbtypes.c
Date: Fri, 20 Feb 2026 15:19:43 -0500	[thread overview]
Message-ID: <20260220202002.860008-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20260220202002.860008-1-simon.marchi@efficios.com>

From: Simon Marchi <simon.marchi@polymtl.ca>

Use the new enumerate util to move to a range-based loop, while keeping
the counter.

Change-Id: If82eaec7afa4e78fa51e973fae4d0ecef728ea95
---
 gdb/gdbtypes.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 2b6244d6f38b..396588e70e0c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -44,6 +44,7 @@
 #include "rust-lang.h"
 #include "ada-lang.h"
 #include "extract-store-integer.h"
+#include "gdbsupport/enumerate.h"
 
 /* The value of an invalid conversion badness.  */
 #define INVALID_CONVERSION 100
@@ -4765,12 +4766,12 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
 static void
 print_args (gdb::array_view<struct field> args, int spaces)
 {
-  for (int i = 0; i < args.size (); i++)
+  for (auto [i, arg] : gdb::enumerate (args))
     {
       gdb_printf
-	("%*s[%d] name '%s'\n", spaces, "", i,
-	 args[i].name () != NULL ? args[i].name () : "<NULL>");
-      recursive_dump_type (args[i].type (), spaces + 2);
+	("%*s[%zu] name '%s'\n", spaces, "", i,
+	 arg.name () != nullptr ? arg.name () : "<NULL>");
+      recursive_dump_type (arg.type (), spaces + 2);
     }
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-02-20 20:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-20 20:19 [PATCH 1/3] gdbsupport: add gdb::enumerate util Simon Marchi
2026-02-20 20:19 ` [PATCH 2/3] gdb/dwarf: use enumerate in index-write.c Simon Marchi
2026-02-20 20:19 ` Simon Marchi [this message]
2026-02-20 20:47 ` [PATCH 1/3] gdbsupport: add gdb::enumerate util Tom Tromey
2026-02-21  0:58   ` Simon Marchi
2026-02-21  1:18 ` [PATCH v2 1/3] gdbsupport: add gdb::ranges::views::enumerate util simon.marchi
2026-02-21  1:18   ` [PATCH v2 2/3] gdb/dwarf: use enumerate in index-write.c simon.marchi
2026-02-21  1:19   ` [PATCH v2 3/3] gdb: use enumerate in gdbtypes.c simon.marchi
2026-03-14 17:32   ` [PATCH v2 1/3] gdbsupport: add gdb::ranges::views::enumerate util Simon Marchi
2026-04-16 19:52   ` 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=20260220202002.860008-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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