gdb: add type::index_type / type::set_index_type
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 8 Jun 2020 19:25:50 +0000 (15:25 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 8 Jun 2020 19:25:50 +0000 (15:25 -0400)
Add the `index_type` and `set_index_type` methods on `struct type`, in
order to remove the `TYPE_INDEX_TYPE` macro.  In this patch, the
`TYPE_INDEX_TYPE` macro is changed to use `type::index_type`, so all the
call sites that are used to set the type's index type are changed to use
`type::set_index_type`.  The next patch will remove `TYPE_INDEX_TYPE`
completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <index_type, set_index_type>: New
methods.
(TYPE_INDEX_TYPE): Use type::index_type.
* gdbtypes.c (create_array_type_with_stride): Likewise.

Change-Id: I93bdca9de9f3e143d2ccea59310c63745315e18d

gdb/ChangeLog
gdb/gdbtypes.c
gdb/gdbtypes.h

index 028805365683f0670a39923b85085c9c509fb421..6870b2ca5bf6d18ff615021caf61d15a99649d45 100644 (file)
@@ -1,3 +1,10 @@
+2020-06-08  Simon Marchi  <simon.marchi@efficios.com>
+
+       * gdbtypes.h (struct type) <index_type, set_index_type>: New
+       methods.
+       (TYPE_INDEX_TYPE): Use type::index_type.
+       * gdbtypes.c (create_array_type_with_stride): Likewise.
+
 2020-06-07  Tom Tromey  <tom@tromey.com>
 
        * valprint.c (generic_val_print_float): Remove "embedded_offset"
index fa90bd1c051252636ade5d56bb658fca5db51705..67fd3d20a8f02ae0baf554d54ff4828eeb31e804 100644 (file)
@@ -1293,7 +1293,7 @@ create_array_type_with_stride (struct type *result_type,
   result_type->set_num_fields (1);
   result_type->set_fields
     ((struct field *) TYPE_ZALLOC (result_type, sizeof (struct field)));
-  TYPE_INDEX_TYPE (result_type) = range_type;
+  result_type->set_index_type (range_type);
   if (byte_stride_prop != NULL)
     result_type->add_dyn_prop (DYN_PROP_BYTE_STRIDE, *byte_stride_prop);
   else if (bit_stride > 0)
index 47d79afe2e699ff5ab167086ec9d51b380e755b5..0cca0fdbd1d095eb404ba906f14073a12709f029 100644 (file)
@@ -933,6 +933,16 @@ struct type
     this->main_type->flds_bnds.fields = fields;
   }
 
+  type *index_type () const
+  {
+    return this->field (0).type;
+  }
+
+  void set_index_type (type *index_type)
+  {
+    this->field (0).type = index_type;
+  }
+
   /* * Return the dynamic property of the requested KIND from this type's
      list of dynamic properties.  */
   dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
@@ -1482,7 +1492,7 @@ extern unsigned type_align (struct type *);
    space in struct type.  */
 extern bool set_type_align (struct type *, ULONGEST);
 
-#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
+#define TYPE_INDEX_TYPE(type) ((type)->index_type ())
 #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
 #define TYPE_LOW_BOUND(range_type) \
   TYPE_RANGE_DATA(range_type)->low.data.const_val
This page took 0.030958 seconds and 4 git commands to generate.