From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129020 invoked by alias); 11 Dec 2017 23:05:09 -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 129007 invoked by uid 89); 11 Dec 2017 23:05: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,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= 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, 11 Dec 2017 23:05:07 +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 053B0356E8; Mon, 11 Dec 2017 23:05:06 +0000 (UTC) Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B382F5D756; Mon, 11 Dec 2017 23:05:05 +0000 (UTC) From: Sergio Durigan Junior To: Simon Marchi Cc: GDB Patches , Tom Tromey , Eli Zaretskii Subject: Re: [PATCH v3 1/2] Reorganize code to handle TYPE_CODE_{STRUCT,UNION} on 'c_type_print_base' References: <20171121160709.23248-1-sergiodj@redhat.com> <20171211195757.18044-1-sergiodj@redhat.com> <20171211195757.18044-2-sergiodj@redhat.com> <9f8ee5f9-6f73-107f-c9d7-d6c31b5be98c@ericsson.com> Date: Mon, 11 Dec 2017 23:05:00 -0000 In-Reply-To: <9f8ee5f9-6f73-107f-c9d7-d6c31b5be98c@ericsson.com> (Simon Marchi's message of "Mon, 11 Dec 2017 15:54:55 -0500") Message-ID: <87po7kc1cu.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00255.txt.bz2 On Monday, December 11 2017, Simon Marchi wrote: > Hi Sergio, > > LGTM, with some nits. Thanks for the review. > On 2017-12-11 02:57 PM, Sergio Durigan Junior wrote: >> diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c >> index f3c3e7d706..46c814fae8 100644 >> --- a/gdb/c-typeprint.c >> +++ b/gdb/c-typeprint.c >> @@ -875,6 +875,458 @@ output_access_specifier (struct ui_file *stream, >> return last_access; >> } >> >> +/* Return true is an access label (i.e., "public:", "private:", >> + "protected:") needs to be printed for TYPE. */ >> + >> +static bool >> +need_access_label_p (struct type *type) >> +{ >> + bool need_access_label = false; >> + int i, j; >> + int len, len2; >> + >> + if (TYPE_DECLARED_CLASS (type)) >> + { >> + QUIT; >> + len = TYPE_NFIELDS (type); >> + for (i = TYPE_N_BASECLASSES (type); i < len; i++) >> + if (!TYPE_FIELD_PRIVATE (type, i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + QUIT; >> + if (!need_access_label) >> + { >> + len2 = TYPE_NFN_FIELDS (type); >> + for (j = 0; j < len2; j++) >> + { >> + len = TYPE_FN_FIELDLIST_LENGTH (type, j); >> + for (i = 0; i < len; i++) >> + if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, >> + j), i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + if (need_access_label) >> + break; >> + } >> + } >> + QUIT; >> + if (!need_access_label) >> + { >> + for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i) >> + { >> + if (!TYPE_TYPEDEF_FIELD_PRIVATE (type, i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + } >> + } >> + } >> + else >> + { >> + QUIT; >> + len = TYPE_NFIELDS (type); >> + for (i = TYPE_N_BASECLASSES (type); i < len; i++) >> + if (TYPE_FIELD_PRIVATE (type, i) >> + || TYPE_FIELD_PROTECTED (type, i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + QUIT; >> + if (!need_access_label) >> + { >> + len2 = TYPE_NFN_FIELDS (type); >> + for (j = 0; j < len2; j++) >> + { >> + QUIT; >> + len = TYPE_FN_FIELDLIST_LENGTH (type, j); >> + for (i = 0; i < len; i++) >> + if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, >> + j), i) >> + || TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, >> + j), >> + i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + if (need_access_label) >> + break; >> + } >> + } >> + QUIT; >> + if (!need_access_label) >> + { >> + for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); ++i) >> + { >> + if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i) >> + || TYPE_TYPEDEF_FIELD_PRIVATE (type, i)) >> + { >> + need_access_label = true; >> + break; >> + } >> + } >> + } >> + } >> + >> + return need_access_label; > > It seems to me that you could return immediately when you detect that a label is > needed. It would allow removing a bunch of if (!need_access_label). Done. >> @@ -898,10 +1350,8 @@ c_type_print_base (struct type *type, struct ui_file *stream, >> int show, int level, const struct type_print_options *flags) >> { >> int i; >> - int len, real_len; >> - enum access_specifier section_type; >> - int need_access_label = 0; >> - int j, len2; >> + int len; >> + int j; > > j is unused. Removed. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/