From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 737AC3857017 for ; Thu, 24 Aug 2023 12:41:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 737AC3857017 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692880885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fZaIAGci0WIJS8znrFJbjCnw9DGLRiya4ckPmyfHTuI=; b=A+CqNIugjN+2D7jz5vLjzsaeo2H5kPz0tQb3p4tXv6eRPPkdxfEEmwmeTtX9DC3t3tFlq4 KRBPv8EQ3Ug58I0BxLvw0vqdjQ7wPkNJRS9foeMYm2wNO/t8dbKHREfpoOFwg6bLb0rfyY NCRSp0hbwNVRa2oxZF9exHfIi1dWdlA= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-684-6P0OE88YOmiPmkZP6sfX4w-1; Thu, 24 Aug 2023 08:41:23 -0400 X-MC-Unique: 6P0OE88YOmiPmkZP6sfX4w-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BE00381494F; Thu, 24 Aug 2023 12:41:23 +0000 (UTC) Received: from localhost (unknown [10.42.28.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 513D740C2073; Thu, 24 Aug 2023 12:41:23 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Declutter std::optional and std:variant pretty printers [PR110944] Date: Thu, 24 Aug 2023 13:41:08 +0100 Message-ID: <20230824124122.431361-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- As the PR says, including the template arguments in the GDB output of these class templates can result in very long names, especially for std::variant. You can use 'whatis' or other GDB commands to get details of the type, we don't need to include it in the value. We could consider including the type if it's not too long, but I think consistency is better (and we already omit the template arguments for std::vector and other class templates). libstdc++-v3/ChangeLog: PR libstdc++/110944 * python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Do not show template arguments. (StdVariantPrinter): Likewise. * testsuite/libstdc++-prettyprinters/compat.cc: Adjust expected output. * testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise. * testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 3 +-- .../libstdc++-prettyprinters/compat.cc | 8 +++---- .../libstdc++-prettyprinters/cxx17.cc | 22 +++++++++---------- .../libstdc++-prettyprinters/libfundts.cc | 12 +++++----- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 0187c4b60e6..1a8017adb22 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1343,7 +1343,7 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): def __init__ (self, typename, val): valtype = self._recognize (val.type.template_argument(0)) typename = strip_versioned_namespace(typename) - self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % valtype, typename, 1) + self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3', typename, 1) payload = val['_M_payload'] if self.typename.startswith('std::experimental'): engaged = val['_M_engaged'] @@ -1375,7 +1375,6 @@ class StdVariantPrinter(SingleObjContainerPrinter): def __init__(self, typename, val): alternatives = get_template_arg_list(val.type) self.typename = strip_versioned_namespace(typename) - self.typename = "%s<%s>" % (self.typename, ', '.join([self._recognize(alt) for alt in alternatives])) self.index = val['_M_index'] if self.index >= len(alternatives): self.contained_type = None diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc index 34022cf1459..acc20a30d8e 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc @@ -102,13 +102,13 @@ main() using std::optional; optional o; -// { dg-final { note-test o {std::optional [no contained value]} } } +// { dg-final { note-test o {std::optional [no contained value]} } } optional ob{false}; -// { dg-final { note-test ob {std::optional = {[contained value] = false}} } } +// { dg-final { note-test ob {std::optional = {[contained value] = false}} } } optional oi{5}; -// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } } +// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } } optional op{nullptr}; -// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } } +// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } } __builtin_puts(""); return 0; // Mark SPOT diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc index 3962a5e9b7e..eb8dc957a43 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc @@ -50,18 +50,18 @@ main() // { dg-final { note-test str "\"string\"" } } optional o; -// { dg-final { note-test o {std::optional [no contained value]} } } +// { dg-final { note-test o {std::optional [no contained value]} } } optional ob{false}; -// { dg-final { note-test ob {std::optional = {[contained value] = false}} } } +// { dg-final { note-test ob {std::optional = {[contained value] = false}} } } optional oi{5}; -// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } } +// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } } optional op{nullptr}; -// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } } +// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } } optional> om; om = std::map{ {1, 2.}, {3, 4.}, {5, 6.} }; -// { dg-final { regexp-test om {std::optional> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } +// { dg-final { regexp-test om {std::optional containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } optional os{ "stringy" }; -// { dg-final { note-test os {std::optional = {[contained value] = "stringy"}} } } +// { dg-final { note-test os {std::optional = {[contained value] = "stringy"}} } } any a; // { dg-final { note-test a {std::any [no contained value]} } } @@ -83,18 +83,18 @@ main() struct S { operator int() { throw 42; }}; variant v0; -// { dg-final { note-test v0 {std::variant [index 0] = {0}} } } +// { dg-final { note-test v0 {std::variant [index 0] = {0}} } } variant v1{ 0.5f }; -// { dg-final { note-test v1 {std::variant [index 0] = {0.5}} } } +// { dg-final { note-test v1 {std::variant [index 0] = {0.5}} } } variant v2; try { v2.emplace<1>(S()); } catch (int) { } -// { dg-final { note-test v2 {std::variant [no contained value]} } } +// { dg-final { note-test v2 {std::variant [no contained value]} } } variant v3{ 3 }; -// { dg-final { note-test v3 {std::variant [index 1] = {3}} } } +// { dg-final { note-test v3 {std::variant [index 1] = {3}} } } variant v4{ str }; -// { dg-final { note-test v4 {std::variant [index 2] = {"string"}} } } +// { dg-final { note-test v4 {std::variant [index 2] = {"string"}} } } map m{ {1, "one"} }; map::node_type n0; diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc index 29e8bc8f194..8f70f3fd151 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc @@ -42,18 +42,18 @@ main() // { dg-final { note-test str "\"string\"" } } optional o; -// { dg-final { note-test o {std::experimental::optional [no contained value]} } } +// { dg-final { note-test o {std::experimental::optional [no contained value]} } } optional ob{false}; -// { dg-final { note-test ob {std::experimental::optional = {[contained value] = false}} } } +// { dg-final { note-test ob {std::experimental::optional = {[contained value] = false}} } } optional oi{5}; -// { dg-final { note-test oi {std::experimental::optional = {[contained value] = 5}} } } +// { dg-final { note-test oi {std::experimental::optional = {[contained value] = 5}} } } optional op{nullptr}; -// { dg-final { note-test op {std::experimental::optional = {[contained value] = 0x0}} } } +// { dg-final { note-test op {std::experimental::optional = {[contained value] = 0x0}} } } optional> om; om = std::map{ {1, 2.}, {3, 4.}, {5, 6.} }; -// { dg-final { regexp-test om {std::experimental::optional> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } +// { dg-final { regexp-test om {std::experimental::optional containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } optional os{ "stringy" }; -// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} } } +// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} } } any a; // { dg-final { note-test a {std::experimental::any [no contained value]} } } -- 2.41.0