From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51868 invoked by alias); 3 Nov 2017 01:09:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 51851 invoked by uid 89); 3 Nov 2017 01:09:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 01:09:31 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id vA319OLl007059 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 2 Nov 2017 21:09:29 -0400 Received: by simark.ca (Postfix, from userid 112) id BE0B61E526; Thu, 2 Nov 2017 21:09:24 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 0679B1E4C4; Thu, 2 Nov 2017 21:09:14 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 03 Nov 2017 01:09:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA 05/13] Remove directive-searched cleanups In-Reply-To: <20171102223612.3642-6-tom@tromey.com> References: <20171102223612.3642-1-tom@tromey.com> <20171102223612.3642-6-tom@tromey.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.2 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 3 Nov 2017 01:09:24 +0000 X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg00057.txt.bz2 On 2017-11-02 18:36, Tom Tromey wrote: > This removes a few cleanups related to the "searched" field in > struct using_direct, replacing these with scoped_restore. > > gdb/ChangeLog > 2017-11-02 Tom Tromey > > * cp-namespace.c (reset_directive_searched): Remove. > (cp_lookup_symbol_via_imports): Use scoped_restore. > * cp-support.c (reset_directive_searched): Remove. > (make_symbol_overload_list_using): Use scoped_restore. > * d-namespace.c (d_lookup_symbol_imports): Use scoped_restore. > (reset_directive_searched): Remove. > --- > gdb/ChangeLog | 9 +++++++++ > gdb/cp-namespace.c | 25 +++---------------------- > gdb/cp-support.c | 19 ++----------------- > gdb/d-namespace.c | 26 +++----------------------- > 4 files changed, 17 insertions(+), 62 deletions(-) > > diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c > index 214b7e1cf4..d8817c0372 100644 > --- a/gdb/cp-namespace.c > +++ b/gdb/cp-namespace.c > @@ -338,15 +338,6 @@ cp_lookup_symbol_in_namespace (const char > *the_namespace, const char *name, > return sym; > } > > -/* Used for cleanups to reset the "searched" flag in case of an error. > */ > - > -static void > -reset_directive_searched (void *data) > -{ > - struct using_direct *direct = (struct using_direct *) data; > - direct->searched = 0; > -} > - > /* Search for NAME by applying all import statements belonging to > BLOCK which are applicable in SCOPE. If DECLARATION_ONLY the > search is restricted to using declarations. > @@ -388,7 +379,6 @@ cp_lookup_symbol_via_imports (const char *scope, > struct block_symbol sym; > int len; > int directive_match; > - struct cleanup *searched_cleanup; > > sym.symbol = NULL; > sym.block = NULL; > @@ -425,9 +415,8 @@ cp_lookup_symbol_via_imports (const char *scope, > { > /* Mark this import as searched so that the recursive call > does not search it again. */ > - current->searched = 1; > - searched_cleanup = make_cleanup (reset_directive_searched, > - current); > + scoped_restore reset_directive_searched > + = make_scoped_restore (¤t->searched, 1); > > /* If there is an import of a single declaration, compare the > imported declaration (after optional renaming by its alias) > @@ -446,9 +435,6 @@ cp_lookup_symbol_via_imports (const char *scope, > search of this import is complete. */ > if (declaration_only || sym.symbol != NULL || current->declaration) > { > - current->searched = 0; > - discard_cleanups (searched_cleanup); > - > if (sym.symbol != NULL) > return sym; > > @@ -460,10 +446,7 @@ cp_lookup_symbol_via_imports (const char *scope, > if (strcmp (name, *excludep) == 0) > break; > if (*excludep) > - { > - discard_cleanups (searched_cleanup); > - continue; > - } > + continue; In this case, the cleanup is discarded. Shouldn't the same thing happen with the scoped_restore? Or was it an error in the original code, and we always want to reset searched? There's the same case in d-namespace.c. Simon