From patchwork Mon Mar 27 14:35:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 19736 Received: (qmail 57663 invoked by alias); 27 Mar 2017 14:36:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 56869 invoked by uid 89); 27 Mar 2017 14:36:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=34, 3.4, supposedly, Eliminate X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Mar 2017 14:36:06 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D92BF75EA0; Mon, 27 Mar 2017 14:36:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D92BF75EA0 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D92BF75EA0 Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34B6A1716C; Mon, 27 Mar 2017 14:35:57 +0000 (UTC) Subject: [pushed] gdb/cp-name-parser.y: Eliminate make_empty, use cplus_demangle_fill_component (Re: [PATCH] libiberty: Initialize d_printing in all cplus_demangle_* functions.) To: Mark Wielaard References: <1489356354-27648-1-git-send-email-mark@klomp.org> <20170313181150.GA287@x4> <20170313182959.GC2167@stream> <1489437334.21350.72.camel@klomp.org> Cc: Markus Trippelsdorf , gdb-patches@sourceware.org, Nathan Sidwell , Ian Lance Taylor , Nick Clifton From: Pedro Alves Message-ID: <827cdbe4-cdcb-19af-0141-9b971054e2ba@redhat.com> Date: Mon, 27 Mar 2017 15:35:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: On 03/14/2017 01:26 AM, Pedro Alves wrote: > From e55453c67bbe772ce001ea15b152f8dc44b8945e Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Mon, 13 Mar 2017 22:54:09 +0000 > Subject: [PATCH] gdb/cp-name-parser.y: Eliminate make_empty, use > cplus_demangle_fill_component > > The demangler exports the cplus_demangle_fill_component function that > clients should use to initialize demangle_component components that > use the "s_binary" union member. cp-name-parser.y uses it in some > places, via the fill_comp wrapper, but not all. Several places > instead use a GDB-specific "make_empty" function. Because this > function does not call any of the demangler "fill" functions, we had > to patch it recently to clear the allocated demangle_component's > "d_printing" field, which is supposedly a "private" demangler field. > To avoid such problems in the future, this commit switches those > places to use "fill_comp" instead, and eliminates the "make_empty" > function. > > gdb/ChangeLog: > 2017-03-13 Pedro Alves > > * cp-name-parser.y (make_empty): Delete. > (demangler_special, nested_name, ptr_operator, array_indicator) > (direct_declarator, declarator_1): Use fill_comp instead of > make_empty. Now pushed, as below. Same patch, but rebased on current master, which had gained a new call to make_empty, for DEMANGLE_COMPONENT_RVALUE_REFERENCE. That's what exposed the need for: https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01392.html From a7e80b9e21eb907ac5c90de7452588c059db0cec Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 27 Mar 2017 13:56:49 +0100 Subject: [PATCH] gdb/cp-name-parser.y: Eliminate make_empty, use cplus_demangle_fill_component The demangler exports the cplus_demangle_fill_component function that clients should use to initialize demangle_component components that use the "s_binary" union member. cp-name-parser.y uses it in some places, via the fill_comp wrapper, but not all. Several places instead use a GDB-specific "make_empty" function. Because this function does not call any of the demangler "fill" functions, we had to patch it recently to clear the allocated demangle_component's "d_printing" field, which is supposedly a "private" demangler field. To avoid such problems in the future, this commit switches those places to use "fill_comp" instead, and eliminates the "make_empty" function. gdb/ChangeLog: 2017-03-27 Pedro Alves * cp-name-parser.y (make_empty): Delete. (demangler_special, nested_name, ptr_operator, array_indicator) (direct_declarator, declarator_1): Use fill_comp instead of make_empty. --- gdb/ChangeLog | 7 ++++++ gdb/cp-name-parser.y | 60 ++++++++++++---------------------------------------- 2 files changed, 21 insertions(+), 46 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b4d995a..517aa3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2017-03-27 Pedro Alves + * cp-name-parser.y (make_empty): Delete. + (demangler_special, nested_name, ptr_operator, array_indicator) + (direct_declarator, declarator_1): Use fill_comp instead of + make_empty. + +2017-03-27 Pedro Alves + * xml-support.h (gdb_xml_debug): Pass a "first-to-check" argument to ATTRIBUTE_PRINTF. * solib-target.c (library_list_start_list): Print "string" not diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index b51c5e2..73a4d90 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -197,15 +197,6 @@ fill_comp (enum demangle_component_type d_type, struct demangle_component *lhs, } static struct demangle_component * -make_empty (enum demangle_component_type d_type) -{ - struct demangle_component *ret = d_grab (); - ret->type = d_type; - ret->d_printing = 0; - return ret; -} - -static struct demangle_component * make_operator (const char *name, int args) { struct demangle_component *ret = d_grab (); @@ -433,9 +424,7 @@ function demangler_special : DEMANGLER_SPECIAL start - { $$ = make_empty ((enum demangle_component_type) $1); - d_left ($$) = $2; - d_right ($$) = NULL; } + { $$ = fill_comp ((enum demangle_component_type) $1, $2, NULL); } | CONSTRUCTION_VTABLE start CONSTRUCTION_IN start { $$ = fill_comp (DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, $2, $4); } ; @@ -600,30 +589,22 @@ ext_only_name : nested_name unqualified_name ; nested_name : NAME COLONCOLON - { $$.comp = make_empty (DEMANGLE_COMPONENT_QUAL_NAME); - d_left ($$.comp) = $1; - d_right ($$.comp) = NULL; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL); $$.last = $$.comp; } | nested_name NAME COLONCOLON { $$.comp = $1.comp; - d_right ($1.last) = make_empty (DEMANGLE_COMPONENT_QUAL_NAME); + d_right ($1.last) = fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL); $$.last = d_right ($1.last); - d_left ($$.last) = $2; - d_right ($$.last) = NULL; } | templ COLONCOLON - { $$.comp = make_empty (DEMANGLE_COMPONENT_QUAL_NAME); - d_left ($$.comp) = $1; - d_right ($$.comp) = NULL; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $1, NULL); $$.last = $$.comp; } | nested_name templ COLONCOLON { $$.comp = $1.comp; - d_right ($1.last) = make_empty (DEMANGLE_COMPONENT_QUAL_NAME); + d_right ($1.last) = fill_comp (DEMANGLE_COMPONENT_QUAL_NAME, $2, NULL); $$.last = d_right ($1.last); - d_left ($$.last) = $2; - d_right ($$.last) = NULL; } ; @@ -761,45 +742,34 @@ builtin_type : int_seq ; ptr_operator : '*' qualifiers_opt - { $$.comp = make_empty (DEMANGLE_COMPONENT_POINTER); - $$.comp->u.s_binary.left = $$.comp->u.s_binary.right = NULL; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_POINTER, NULL, NULL); $$.last = &d_left ($$.comp); $$.comp = d_qualify ($$.comp, $2, 0); } /* g++ seems to allow qualifiers after the reference? */ | '&' - { $$.comp = make_empty (DEMANGLE_COMPONENT_REFERENCE); - $$.comp->u.s_binary.left = $$.comp->u.s_binary.right = NULL; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_REFERENCE, NULL, NULL); $$.last = &d_left ($$.comp); } | ANDAND - { $$.comp = make_empty (DEMANGLE_COMPONENT_RVALUE_REFERENCE); - $$.comp->u.s_binary.left = $$.comp->u.s_binary.right = NULL; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_RVALUE_REFERENCE, NULL, NULL); $$.last = &d_left ($$.comp); } | nested_name '*' qualifiers_opt - { $$.comp = make_empty (DEMANGLE_COMPONENT_PTRMEM_TYPE); - $$.comp->u.s_binary.left = $1.comp; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_PTRMEM_TYPE, $1.comp, NULL); /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME. */ *$1.last = *d_left ($1.last); - $$.comp->u.s_binary.right = NULL; $$.last = &d_right ($$.comp); $$.comp = d_qualify ($$.comp, $3, 0); } | COLONCOLON nested_name '*' qualifiers_opt - { $$.comp = make_empty (DEMANGLE_COMPONENT_PTRMEM_TYPE); - $$.comp->u.s_binary.left = $2.comp; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_PTRMEM_TYPE, $2.comp, NULL); /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME. */ *$2.last = *d_left ($2.last); - $$.comp->u.s_binary.right = NULL; $$.last = &d_right ($$.comp); $$.comp = d_qualify ($$.comp, $4, 0); } ; array_indicator : '[' ']' - { $$ = make_empty (DEMANGLE_COMPONENT_ARRAY_TYPE); - d_left ($$) = NULL; - } + { $$ = fill_comp (DEMANGLE_COMPONENT_ARRAY_TYPE, NULL, NULL); } | '[' INT ']' - { $$ = make_empty (DEMANGLE_COMPONENT_ARRAY_TYPE); - d_left ($$) = $2; - } + { $$ = fill_comp (DEMANGLE_COMPONENT_ARRAY_TYPE, $2, NULL); } ; /* Details of this approach inspired by the G++ < 3.4 parser. */ @@ -952,8 +922,7 @@ direct_declarator $$.last = &d_right ($2); } | colon_ext_name - { $$.comp = make_empty (DEMANGLE_COMPONENT_TYPED_NAME); - d_left ($$.comp) = $1; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL); $$.last = &d_right ($$.comp); } ; @@ -969,8 +938,7 @@ declarator_1 : ptr_operator declarator_1 $$.last = $1.last; *$2.last = $1.comp; } | colon_ext_name - { $$.comp = make_empty (DEMANGLE_COMPONENT_TYPED_NAME); - d_left ($$.comp) = $1; + { $$.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, NULL); $$.last = &d_right ($$.comp); } | direct_declarator_1