From patchwork Mon Sep 10 15:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 29291 Received: (qmail 86221 invoked by alias); 10 Sep 2018 15:42:26 -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 86112 invoked by uid 89); 10 Sep 2018 15:42:25 -0000 Authentication-Results: sourceware.org; auth=none 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, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Sep 2018 15:42:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9EACC11626B; Mon, 10 Sep 2018 11:42:23 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id LRaH2JqVBEEf; Mon, 10 Sep 2018 11:42:23 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 8EE541161AE; Mon, 10 Sep 2018 11:42:23 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4233) id 8DFFF55F; Mon, 10 Sep 2018 11:42:23 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Xavier Roirand Subject: [PATCH 5/6] (Ada) Cleanup code by using ada_is_access_to_unconstrained_array call. Date: Mon, 10 Sep 2018 11:42:07 -0400 Message-Id: <1536594128-6487-6-git-send-email-brobecker@adacore.com> In-Reply-To: <1536594128-6487-1-git-send-email-brobecker@adacore.com> References: <1536594128-6487-1-git-send-email-brobecker@adacore.com> From: Xavier Roirand This patch just avoids code duplication by using a function we introduced recently (ada_is_access_to_unconstrained_array). gdb/ChangeLog: * ada-lang.c (ada_is_access_to_unconstrained_array): Remove static declaration. * ada-lang.h: add ada_is_access_to_unconstrained_array prototype. * ada-varobj.c (ada_varobj_get_number_of_children, ada_varobj_describe_child, ada_value_is_changeable_p): Cleanup code. Tested on x86_64-linux. No new testcase provided, as this is just a refactoring. --- gdb/ChangeLog | 8 ++++++++ gdb/ada-lang.c | 2 +- gdb/ada-lang.h | 2 ++ gdb/ada-varobj.c | 9 +++------ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 524d218..0c94ad4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2018-09-10 Xavier Roirand + * ada-lang.c (ada_is_access_to_unconstrained_array): Remove static + declaration. + * ada-lang.h: add ada_is_access_to_unconstrained_array prototype. + * ada-varobj.c (ada_varobj_get_number_of_children, + ada_varobj_describe_child, ada_value_is_changeable_p): Cleanup code. + +2018-09-10 Xavier Roirand + * ada-valprint.c (ada_value_print): Use type instead of enclosing type. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 5f39def..d151dde 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2834,7 +2834,7 @@ value_assign_to_component (struct value *container, struct value *component, /* Determine if TYPE is an access to an unconstrained array. */ -static bool +bool ada_is_access_to_unconstrained_array (struct type *type) { return (TYPE_CODE (type) == TYPE_CODE_TYPEDEF diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h index 90bfa0a..ee5394c 100644 --- a/gdb/ada-lang.h +++ b/gdb/ada-lang.h @@ -194,6 +194,8 @@ extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *, struct value *ada_convert_actual (struct value *actual, struct type *formal_type0); +extern bool ada_is_access_to_unconstrained_array (struct type *type); + extern struct value *ada_value_subscript (struct value *, int, struct value **); diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 5baefd9..8a01cb9 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -350,8 +350,7 @@ ada_varobj_get_number_of_children (struct value *parent_value, /* A typedef to an array descriptor in fact represents a pointer to an unconstrained array. These types always have one child (the unconstrained array). */ - if (ada_is_array_descriptor_type (parent_type) - && TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF) + if (ada_is_access_to_unconstrained_array (parent_type)) return 1; if (TYPE_CODE (parent_type) == TYPE_CODE_ARRAY) @@ -680,8 +679,7 @@ ada_varobj_describe_child (struct value *parent_value, if (child_path_expr) *child_path_expr = std::string (); - if (ada_is_array_descriptor_type (parent_type) - && TYPE_CODE (parent_type) == TYPE_CODE_TYPEDEF) + if (ada_is_access_to_unconstrained_array (parent_type)) { ada_varobj_describe_ptr_child (parent_value, parent_type, parent_name, parent_path_expr, @@ -937,8 +935,7 @@ ada_value_is_changeable_p (const struct varobj *var) struct type *type = (var->value != nullptr ? value_type (var->value.get ()) : var->type); - if (ada_is_array_descriptor_type (type) - && TYPE_CODE (type) == TYPE_CODE_TYPEDEF) + if (ada_is_access_to_unconstrained_array (type)) { /* This is in reality a pointer to an unconstrained array. its value is changeable. */