From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id B5FD33858C30 for ; Tue, 3 Oct 2023 17:19:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B5FD33858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3528bc102adso4209675ab.2 for ; Tue, 03 Oct 2023 10:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696353542; x=1696958342; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQutYBjZrMl0t1Pwc1HW6mT51dOnPqEHrafNvCrf/HU=; b=BHzHOXWxe5ODFqNM02IEqUD59t3V/zchc/+cB15C1DcQHsXF+qfMH29L87jI1gwAbJ 7zAtriqCE/MZRo3SfJuWzIf72W/tyg9/tm1ejFC05CtBAacekMdhVcLkFEbyXSRCtM8P IeaQ/QVs1ER48S5/saxq7oN8+uPtCt9oR/cT3Ot1tB4Dbi5STz74Qw5ooo1Kettb5ddm 6f1klpSmRHpcGff7orwWz5bXherQcMxjIVZH2+c24u6/uclaAA1gVbn4eBzOyxbGUsq/ AqBgmDuuaNJL5vgGOsoyWpHo/wKvuKs+pD7GwiXs6/bkklBjcpaX/oUyc9AAq2+SZndK nBdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696353542; x=1696958342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQutYBjZrMl0t1Pwc1HW6mT51dOnPqEHrafNvCrf/HU=; b=mf05o8TItI0j4GSxAKeeqdexWMM6A1VVzDXPR8+j/pOIYYDWuKelD/vTNQMJQZr5T8 mWo83WJBMVpHlQLvqLxb5bwVpDuiihjnya7iRrMkRYrwqvN02ZLcrwsTcc3BLZJS3GLy SkWYKF57EkXOgSZGwEx1jHa6Vq8qzd4O2UUe/Ek0sD4tv7T9fuNPtFpvBPE/ADyReqtV Abe5R5cT++hZQTtXACq1cjxZNmdCkGZ9IOVJlj6JeJRFwMi+W65sF9R/5XC0VhE4FdJN CHrs1ET3usXKdXiaFB7sk8RbMi8u0HFyQtbHM87wijPgEHWLqyBfGFUY9fLH5mBWQDoR C/eg== X-Gm-Message-State: AOJu0YzvLRCemSBiL1SSQAYKyWasf+K2x/9G9+ohqRpSQYam398sBIWU CEkSQ5rwisAwJfF0BFeWX0Dk4w== X-Google-Smtp-Source: AGHT+IH9ugIMzaG/178tD4IQXWsx2dQy7aOOBjIQj4jH9Mbz/DDALq6StKiTrKW8gpU8eTOUh5cHug== X-Received: by 2002:a05:6e02:2189:b0:34f:35e8:5098 with SMTP id j9-20020a056e02218900b0034f35e85098mr88678ila.20.1696353541940; Tue, 03 Oct 2023 10:19:01 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p7-20020a92c607000000b0035134215863sm480967ilm.55.2023.10.03.10.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 10:19:01 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 2/2] libstdc++: _versioned_namespace is always non-None Date: Tue, 3 Oct 2023 11:18:51 -0600 Message-Id: <20231003171851.1161340-3-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231003171851.1161340-1-tromey@adacore.com> References: <20231003171851.1161340-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. 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