public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Smith <psmith@gnu.org>
To: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: [PATCH 1/2] libstdc++: Count pretty-printed tuple elements from 0 not 1
Date: Sun, 13 Jun 2021 12:34:28 -0400	[thread overview]
Message-ID: <c960889250652636ae1ff798765079f7adb765a9.camel@gnu.org> (raw)

Show 0-based offsets for std::tuple members, to match with std::get.

libstdc++-v3/ChangeLog:

        * python/libstdcxx/v6/printers.py (StdTuplePrinter): don't increment
        self.count until after generating the result string.
---
 libstdc++-v3/python/libstdcxx/v6/printers.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 550e0ecdd22..14a6d998690 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -560,16 +560,17 @@ class StdTuplePrinter:
                 # Process left node and set it as head.
                 self.head  = self.head.cast (nodes[0].type)

-            self.count = self.count + 1
-
             # Finally, check the implementation.  If it is
             # wrapped in _M_head_impl return that, otherwise return
             # the value "as is".
             fields = impl.type.fields ()
-            if len (fields) < 1 or fields[0].name != "_M_head_impl":
-                return ('[%d]' % self.count, impl)
-            else:
-                return ('[%d]' % self.count, impl['_M_head_impl'])
+            if len (fields) > 0 and fields[0].name == "_M_head_impl":
+                impl = impl['_M_head_impl']
+
+            out = '[%d]' % self.count
+            self.count = self.count + 1
+
+            return (out, impl)

     def __init__ (self, typename, val):
         self.typename = strip_versioned_namespace(typename)
--
2.28.0


             reply	other threads:[~2021-06-13 16:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 16:34 Paul Smith [this message]
2021-06-14 11:36 ` Jonathan Wakely

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=c960889250652636ae1ff798765079f7adb765a9.camel@gnu.org \
    --to=psmith@gnu.org \
    --cc=gcc@gcc.gnu.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).