(Ada) Cleanup code by using ada_is_access_to_unconstrained_array call.
authorXavier Roirand <roirand@adacore.com>
Mon, 10 Sep 2018 15:35:58 +0000 (10:35 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 10 Sep 2018 15:35:58 +0000 (11:35 -0400)
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
gdb/ada-lang.c
gdb/ada-lang.h
gdb/ada-varobj.c

index 524d218d9613f5ebe2201e43d044317465d72d74..0c94ad4a2122031c0343d230499a9e7d8dcd44d7 100644 (file)
@@ -1,3 +1,11 @@
+2018-09-10  Xavier Roirand  <roirand@adacore.com>
+
+       * 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  <roirand@adacore.com>
 
        * ada-valprint.c (ada_value_print): Use type instead of
index 5f39def20929240758f403ae11ae27d80ebf138e..d151dde3a29afcd6dcf3a2f2fd7ba87bb38cb77d 100644 (file)
@@ -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
index 90bfa0a7be89e0225d78e686e6737823c11e63cd..ee5394c21bde6083f483216b5d8190bb0cff94c8 100644 (file)
@@ -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 **);
 
index 5baefd997b340066d780448557990bbdda43264d..8a01cb978972dd2434b3b62997f52301961a9f24 100644 (file)
@@ -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.  */
This page took 0.037428 seconds and 4 git commands to generate.