From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 6174B3858C52; Thu, 28 Sep 2023 18:51:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6174B3858C52 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-x630.google.com with SMTP id a640c23a62f3a-9ad8bf9bfabso1773391366b.3; Thu, 28 Sep 2023 11:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695927106; x=1696531906; 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=WImJHwtGBTNReHcCTDePtmjmJwUmykWVtfAOe64Xuv0=; b=by5Ghx5tCJ9OfPqcUB9F1fsSuOYLwP535NlX8yCnciwjk2wukfCIedJJTBAkrc4RWS IFGtCQtJPTDSGbS9y4WDzBCBfWkLcQaVSCMEBQhUA+jQpJJ8FaYhOx4NSG6N2T6FEZb2 vsBIJWgZY52xgvE5HJ2b7NCndFJDwUIEg3NkmCgq97yBUPGpcmw6Z8AIHvnG1mypTXHe xMg93/vxC2VWnjImlO7ENV04QrAtulgdeJMMPeOU5ZeHQmWExEHIMldW3fegeaEc1H9x VqEU+W+XeGtfhQU9ruJOu6yUwUPerx/If3E447qVZb/cLzsbXp4Ayo+EnkIjo+k7oB6e CTqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695927106; x=1696531906; 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=WImJHwtGBTNReHcCTDePtmjmJwUmykWVtfAOe64Xuv0=; b=VoeXQKktxEO57W+V6iEU56azTmyeu9SQbVY48D26LZ2OAmBG7hUHWR3ANdqDN8FFDI bB2DJxxX/EkSxKXwsnzgm7rhJgESCvaoHdPSVBDP0Rx4yqAwM23TW96UkCBkpQVkQVkP yGNer2lO6qyvVOdtX1SpAPj0Iibik9OAESsODZa0X8RJezpPy0mOmimNYYIFH6kj4oA1 +1FoM0IXXHTweF8phP5b5tvA66l+zGJuprpL5H22y8Tpu7r8o9fVw8nSiEUw8K9kHWHo 0kI7YJsljt9kD6EtlOJPPToAg3vclQqaKJFy/mKMdXQ+axaI65TI27/qWJaaszXk6UqW rlYA== X-Gm-Message-State: AOJu0YwE2LsW6hhovJp9STDHhMBqRDX76SmDK21833HqUuo7UmfwPoie ZmcAVo120KrbIQ3IwvXvns7RxQ9240rm4fbT6oZofJZJ X-Google-Smtp-Source: AGHT+IFwDv4zmi1UCCKu0mzHwvvo9uwPAIGtWSNajDWr/drrNy1l4HU5B2bRbiaOmMf9By18HRDTmgbWyd1LmZQsXJQ= X-Received: by 2002:a17:906:31d2:b0:9b2:8b14:7a20 with SMTP id f18-20020a17090631d200b009b28b147a20mr1963173ejf.45.1695927105655; Thu, 28 Sep 2023 11:51:45 -0700 (PDT) MIME-Version: 1.0 References: <20230928174630.4004388-1-tromey@adacore.com> <20230928174630.4004388-7-tromey@adacore.com> In-Reply-To: <20230928174630.4004388-7-tromey@adacore.com> From: Jonathan Wakely Date: Thu, 28 Sep 2023 19:51:34 +0100 Message-ID: Subject: Re: [PATCH 6/7] libstdc++: Fix regex escapes in pretty-printers To: Tom Tromey Cc: gcc-patches , "libstdc++" Content-Type: multipart/alternative; boundary="000000000000b2996506066fccfe" X-Spam-Status: No, score=-6.6 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: --000000000000b2996506066fccfe Content-Type: text/plain; charset="UTF-8" On Thu, 28 Sept 2023, 18:50 Tom Tromey via Libstdc++, wrote: > flake8 pointed out that some regexes in the pretty-printers are > missing a backslash. This patch fixes these. > I already have a patch to use r'...' for these, so we only need the single backslash. I'm also refactoring all those re.match calls in xmethods.exp to use a common function. So please don't commit this one, I think it will be unnecessary in a couple of hours. > libstdc++-v3/ChangeLog: > > * python/libstdcxx/v6/printers.py > (StdExpAnyPrinter.__init__, StdExpOptionalPrinter.__init__): > Add missing backslash. > * python/libstdcxx/v6/xmethods.py > (ArrayMethodsMatcher.match, DequeMethodsMatcher.match) > (ForwardListMethodsMatcher.match, ListMethodsMatcher.match) > (VectorMethodsMatcher.match) > (AssociativeContainerMethodsMatcher.match) > (UniquePtrGetWorker.__call__, UniquePtrMethodsMatcher.match) > (SharedPtrSubscriptWorker.__call__) > (SharedPtrMethodsMatcher.match): Add missing backslash. > --- > libstdc++-v3/python/libstdcxx/v6/printers.py | 6 +++--- > libstdc++-v3/python/libstdcxx/v6/xmethods.py | 22 ++++++++++---------- > 2 files changed, 14 insertions(+), 14 deletions(-) > > diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py > b/libstdc++-v3/python/libstdcxx/v6/printers.py > index 94ac9232da7..d125236b777 100644 > --- a/libstdc++-v3/python/libstdcxx/v6/printers.py > +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py > @@ -1344,7 +1344,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): > def __init__(self, typename, val): > self._typename = strip_versioned_namespace(typename) > self._typename = re.sub( > - '^std::experimental::fundamentals_v\d::', > 'std::experimental::', self._typename, 1) > + '^std::experimental::fundamentals_v\\d::', > 'std::experimental::', self._typename, 1) > self._val = val > self._contained_type = None > contained_value = None > @@ -1377,7 +1377,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): > mgrtypes = [] > for s in strings: > try: > - x = re.sub("std::string(?!\w)", s, m.group(1)) > + x = re.sub("std::string(?!\\w)", s, m.group(1)) > # The following lookup might raise gdb.error if > the > # manager function was never instantiated for 's' > in the > # program, because there will be no such type. > @@ -1425,7 +1425,7 @@ class > StdExpOptionalPrinter(SingleObjContainerPrinter): > def __init__(self, typename, val): > typename = strip_versioned_namespace(typename) > self._typename = re.sub( > - '^std::(experimental::|)(fundamentals_v\d::|)(.*)', > r'std::\1\3', typename, 1) > + '^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'] > diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py > b/libstdc++-v3/python/libstdcxx/v6/xmethods.py > index 025b1b86ed0..eafecbb148e 100644 > --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py > +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py > @@ -159,7 +159,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?array<.*>$', class_type.tag): > + if not re.match('^std::(__\\d+::)?array<.*>$', class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -284,7 +284,7 @@ class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?deque<.*>$', class_type.tag): > + if not re.match('^std::(__\\d+::)?deque<.*>$', class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -332,7 +332,7 @@ class > ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?forward_list<.*>$', > class_type.tag): > + if not re.match('^std::(__\\d+::)?forward_list<.*>$', > class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -419,7 +419,7 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?(__cxx11::)?list<.*>$', > class_type.tag): > + if not re.match('^std::(__\\d+::)?(__cxx11::)?list<.*>$', > class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -542,7 +542,7 @@ class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?vector<.*>$', class_type.tag): > + if not re.match('^std::(__\\d+::)?vector<.*>$', class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -595,7 +595,7 @@ class > AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?%s<.*>$' % self._name, > class_type.tag): > + if not re.match('^std::(__\\d+::)?%s<.*>$' % self._name, > class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -629,9 +629,9 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): > def __call__(self, obj): > impl_type = obj.dereference().type.fields()[0].type.tag > # Check for new implementations first: > - if re.match('^std::(__\d+::)?__uniq_ptr_(data|impl)<.*>$', > impl_type): > + if re.match('^std::(__\\d+::)?__uniq_ptr_(data|impl)<.*>$', > impl_type): > tuple_member = obj['_M_t']['_M_t'] > - elif re.match('^std::(__\d+::)?tuple<.*>$', impl_type): > + elif re.match('^std::(__\\d+::)?tuple<.*>$', impl_type): > tuple_member = obj['_M_t'] > else: > return None > @@ -696,7 +696,7 @@ class > UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?unique_ptr<.*>$', > class_type.tag): > + if not re.match('^std::(__\\d+::)?unique_ptr<.*>$', > class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > @@ -768,7 +768,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker): > > def __call__(self, obj, index): > # Check bounds if _elem_type is an array of known bound > - m = re.match('.*\[(\d+)]$', str(self._elem_type)) > + m = re.match('.*\\[(\\d+)]$', str(self._elem_type)) > if m and index >= int(m.group(1)): > raise IndexError('shared_ptr<%s> index "%d" should not be >= > %d.' % > (self._elem_type, int(index), > int(m.group(1)))) > @@ -823,7 +823,7 @@ class > SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher): > self.methods = [self._method_dict[m] for m in self._method_dict] > > def match(self, class_type, method_name): > - if not re.match('^std::(__\d+::)?shared_ptr<.*>$', > class_type.tag): > + if not re.match('^std::(__\\d+::)?shared_ptr<.*>$', > class_type.tag): > return None > method = self._method_dict.get(method_name) > if method is None or not method.enabled: > -- > 2.40.1 > > --000000000000b2996506066fccfe--