From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 78DDB3857701; Tue, 3 Oct 2023 22:55:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 78DDB3857701 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-99c3d3c3db9so248044966b.3; Tue, 03 Oct 2023 15:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696373741; x=1696978541; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4SW6gry/9pMDHs0kgBErnzS0zHnxrhjXIeno/GoEM9g=; b=ES73WupSy6VIgmWIuAjYaOAkqZ11nTSzFLmut5Zl9vluvaqVYx73QPvnMBtifL/y+D ZXmkCjGSLr/yW5JN7FqOQc4oSIkXJvzD+HXQmYUb0cPMTCL+3kN12sL78F0SopRJ9RmN eYGISnZJJC3ujX6FH39cGaSS0bTp4iNVCtE+SMOSyCL0kSb3ZwRsELlOfEC55y50aail dgewZ9NzyaEfH0SJMRgpyfAl8M/AXINoijYUo8OzmIZxCZTPZrmBnGWujBqZ4IITB4c+ GXZLymoHwIs6hUanxXKYVEAsmRciKjQP/mtn2SnzphXFuPG95f6vhh+Fynv5b/mDLwt/ ioHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696373741; x=1696978541; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4SW6gry/9pMDHs0kgBErnzS0zHnxrhjXIeno/GoEM9g=; b=Qld9sLz1smPlS9Wcwns8o+rEUeRal8V8NuzHGOf1xC3J2CrD/1jzg1H63WjZjnJ4JC Eu0w8Z/9ZKSH8Af2i93XRHvInoKxkpnj8LZPRiK87JclUX2Mz4z2LYYH3kFF3jNgOrmb fNoB04ks7HACgOjUfu4f30NFTgPD4V2lIzhAyazkMXEMa2zHWlZK2kXdUVTqxbboHmFu iSWfA485HmUMsyZTyzBOWFee24/LUYqYI+8oPxClkrFhAY0/IXGxBRq6d+JWER1aNfIn sbHagplKHqRA8T56oViG/gjSdKI6HXRYazO+KIAWFG9CcVJFObPTaYnL2kHCGQ2Y92Iv iegA== X-Gm-Message-State: AOJu0YyFshNUJ9RTsW3euNanLyw6yJrwVWQdaO/HvB+zwXK40M2phdya 0GSy32OpJN4JIh6f2WuYNWhf6H4Dv2MAEx2dTlI= X-Google-Smtp-Source: AGHT+IGPtgJiXkctEh2+DEar5fkoucbykscS4qF2MpAA8agjI1huU7TjkjMBYzFbWupMGsuYDvIergbDMEwoHq8IRZU= X-Received: by 2002:a17:907:7ea0:b0:9a5:9038:b1e7 with SMTP id qb32-20020a1709077ea000b009a59038b1e7mr609946ejc.36.1696373740981; Tue, 03 Oct 2023 15:55:40 -0700 (PDT) MIME-Version: 1.0 References: <20231003171851.1161340-1-tromey@adacore.com> <20231003171851.1161340-3-tromey@adacore.com> In-Reply-To: <20231003171851.1161340-3-tromey@adacore.com> From: Jonathan Wakely Date: Tue, 3 Oct 2023 23:55:27 +0100 Message-ID: Subject: Re: [PATCH 2/2] libstdc++: _versioned_namespace is always non-None To: Tom Tromey Cc: gcc-patches , "libstdc++" Content-Type: multipart/alternative; boundary="0000000000003cd01e0606d7ca8c" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: --0000000000003cd01e0606d7ca8c Content-Type: text/plain; charset="UTF-8" On Tue, 3 Oct 2023, 19:27 Tom Tromey, wrote: > Some code in the pretty-printers seems to assume that the > _versioned_namespace global might be None (or the empty string). > However, doesn't occur, as the variable is never reassigned. > ok for trunk, but we should just remove that bit from xmethods.py as the variable is never even set in that file. > libstdc++-v3/ChangeLog: > > * python/libstdcxx/v6/printers.py: Assume that > _versioned_namespace is non-None. > * python/libstdcxx/v6/xmethods.py (is_specialization_of): > Assume that _versioned_namespace is non-None. > --- > libstdc++-v3/python/libstdcxx/v6/printers.py | 15 ++++++--------- > libstdc++-v3/python/libstdcxx/v6/xmethods.py | 3 +-- > 2 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py > b/libstdc++-v3/python/libstdcxx/v6/printers.py > index 23efbd171ec..e370551cbe1 100644 > --- a/libstdc++-v3/python/libstdcxx/v6/printers.py > +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py > @@ -139,7 +139,7 @@ def lookup_templ_spec(templ, *args): > except gdb.error as e: > # Type not found, try again in versioned namespace. > global _versioned_namespace > - if _versioned_namespace and _versioned_namespace not in templ: > + if _versioned_namespace not in templ: > t = t.replace('::', '::' + _versioned_namespace, 1) > try: > return gdb.lookup_type(t) > @@ -211,16 +211,13 @@ def is_specialization_of(x, template_name): > global _versioned_namespace > if isinstance(x, gdb.Type): > x = x.tag > - if _versioned_namespace: > - template_name = '(%s)?%s' % (_versioned_namespace, template_name) > + template_name = '(%s)?%s' % (_versioned_namespace, template_name) > return re.match('^std::%s<.*>$' % template_name, x) is not None > > > def strip_versioned_namespace(typename): > global _versioned_namespace > - if _versioned_namespace: > - return typename.replace(_versioned_namespace, '') > - return typename > + return typename.replace(_versioned_namespace, '') > > > def strip_inline_namespaces(type_str): > @@ -2355,7 +2352,7 @@ class Printer(object): > # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. > def add_version(self, base, name, function): > self.add(base + name, function) > - if _versioned_namespace and '__cxx11' not in base: > + if '__cxx11' not in base: > vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % > _versioned_namespace, base) > self.add(vbase + name, function) > @@ -2527,7 +2524,7 @@ def add_one_template_type_printer(obj, name, > defargs): > printer = TemplateTypePrinter('std::__debug::' + name, defargs) > gdb.types.register_type_printer(obj, printer) > > - if _versioned_namespace and '__cxx11' not in name: > + if '__cxx11' not in name: > # Add second type printer for same type in versioned namespace: > ns = 'std::' + _versioned_namespace > # PR 86112 Cannot use dict comprehension here: > @@ -2628,7 +2625,7 @@ class FilteringTypePrinter(object): > def add_one_type_printer(obj, template, name, targ1=None): > printer = FilteringTypePrinter('std::' + template, 'std::' + name, > targ1) > gdb.types.register_type_printer(obj, printer) > - if _versioned_namespace and '__cxx11' not in template: > + if '__cxx11' not in template: > ns = 'std::' + _versioned_namespace > printer = FilteringTypePrinter(ns + template, ns + name, targ1) > gdb.types.register_type_printer(obj, printer) > diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py > b/libstdc++-v3/python/libstdcxx/v6/xmethods.py > index 8ccf57c4d6b..42e60eb57b1 100644 > --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py > +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py > @@ -39,8 +39,7 @@ def is_specialization_of(x, template_name): > """ > if isinstance(x, gdb.Type): > x = x.tag > - if _versioned_namespace: > - template_name = '(%s)?%s' % (_versioned_namespace, template_name) > + template_name = '(%s)?%s' % (_versioned_namespace, template_name) > return re.match(r'^std::(__\d::)?%s<.*>$' % template_name, x) is not > None > > class LibStdCxxXMethod(gdb.xmethod.XMethod): > -- > 2.40.1 > > --0000000000003cd01e0606d7ca8c--