public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: make inherit_abstract_dies use vector iterators
Date: Fri, 21 Oct 2022 18:27:30 +0000 (GMT)	[thread overview]
Message-ID: <20221021182730.0C58A3856DC0@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=129d1afcc50c0aa3cf69fb3c5d4d8c825bec1061

commit 129d1afcc50c0aa3cf69fb3c5d4d8c825bec1061
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Oct 21 09:17:53 2022 -0400

    gdb: make inherit_abstract_dies use vector iterators
    
    Small cleanup to use std::vector iterators rather than raw pointers.
    
    Approved-By: Tom Tromey <tom@tromey.com>
    Change-Id: I8d50dbb3f2d8dad7ff94066a578d523f1f31b590

Diff:
---
 gdb/dwarf2/read.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 077af064663..071d0c48e99 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -11952,29 +11952,28 @@ inherit_abstract_dies (struct die_info *die, struct dwarf2_cu *cu)
   if (!offsets.empty ())
     {
       std::sort (offsets.begin (), offsets.end ());
-      sect_offset *offsets_end = offsets.data () + offsets.size ();
-      for (sect_offset *offsetp = offsets.data () + 1;
-	   offsetp < offsets_end;
-	   offsetp++)
-	if (offsetp[-1] == *offsetp)
+
+      for (auto offsets_it = offsets.begin () + 1;
+	   offsets_it < offsets.end ();
+	   ++offsets_it)
+	if (*(offsets_it - 1) == *offsets_it)
 	  complaint (_("Multiple children of DIE %s refer "
 		       "to DIE %s as their abstract origin"),
 		     sect_offset_str (die->sect_off),
-		     sect_offset_str (*offsetp));
+		     sect_offset_str (*offsets_it));
     }
 
-  sect_offset *offsetp = offsets.data ();
-  sect_offset *offsets_end = offsets.data () + offsets.size ();
+  auto offsets_it = offsets.begin ();
   die_info *origin_child_die = origin_die->child;
   while (origin_child_die != nullptr && origin_child_die->tag != 0)
     {
       /* Is ORIGIN_CHILD_DIE referenced by any of the DIE children?  */
-      while (offsetp < offsets_end
-	     && *offsetp < origin_child_die->sect_off)
-	offsetp++;
+      while (offsets_it < offsets.end ()
+	     && *offsets_it < origin_child_die->sect_off)
+	++offsets_it;
 
-      if (offsetp >= offsets_end
-	  || *offsetp > origin_child_die->sect_off)
+      if (offsets_it == offsets.end ()
+	  || *offsets_it > origin_child_die->sect_off)
 	{
 	  /* Found that ORIGIN_CHILD_DIE is really not referenced.
 	     Check whether we're already processing ORIGIN_CHILD_DIE.

                 reply	other threads:[~2022-10-21 18:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221021182730.0C58A3856DC0@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@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).