]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: add type::is_unsigned / type::set_is_unsigned
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 14 Sep 2020 15:07:56 +0000 (11:07 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 14 Sep 2020 15:07:56 +0000 (11:07 -0400)
Add the `is_unsigned` and `set_is_unsigned` methods on `struct type`, in
order to remove the `TYPE_UNSIGNED` macro.  In this patch, the
`TYPE_UNSIGNED` macro is changed to use `type::is_unsigned`, so all the
call sites that are used to set this property on a type are changed to
use the new method.  The next patch will remove the macro completely.

gdb/ChangeLog:

* gdbtypes.h (struct type) <is_unsigned, set_is_unsigned>: New
methods.
(TYPE_UNSIGNED): Use type::is_unsigned.  Change all write call
sites to use type::set_is_unsigned.

Change-Id: Ib09ddce84eda160a801a8f288cccf61c8ef136bc

gdb/ChangeLog
gdb/ada-valprint.c
gdb/coffread.c
gdb/dwarf2/read.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/mdebugread.c
gdb/stabsread.c
gdb/target-descriptions.c
gdb/windows-tdep.c

index dd31d707c8c1f0cb9491c6eee75e19bbca936613..a10bef5ba143f90cf44c63fe64e0ddc2d315011b 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-14  Simon Marchi  <simon.marchi@efficios.com>
+
+       * gdbtypes.h (struct type) <is_unsigned, set_is_unsigned>: New
+       methods.
+       (TYPE_UNSIGNED): Use type::is_unsigned.  Change all write call
+       sites to use type::set_is_unsigned.
+
 2020-09-14  Fredrik Hederstierna  <fredrik.hederstierna@verisure.com>
             Adam Renquinha <arenquinha@cimeq.qc.ca>
 
index 6a5b7d3f37aac30d7e3fed5a3def0b818bee8763..c61688db2b153aeee85194ca638deb159782fa22 100644 (file)
@@ -43,7 +43,7 @@ adjust_type_signedness (struct type *type)
 {
   if (type != NULL && type->code () == TYPE_CODE_RANGE
       && type->bounds ()->low.const_val () >= 0)
-    TYPE_UNSIGNED (type) = 1;
+    type->set_is_unsigned (true);
 }
 
 /* Assuming TYPE is a simple array type, prints its lower bound on STREAM,
index 1592dc645cdb7e07dc64b2f285f43d9ef86fe711..a43d9e2679ee7f3faa14737c55af25a58ce21e10 100644 (file)
@@ -2152,7 +2152,7 @@ coff_read_enum_type (int index, int length, int lastsym,
     }
 
   if (unsigned_enum)
-    TYPE_UNSIGNED (type) = 1;
+    type->set_is_unsigned (true);
 
   return type;
 }
index 865f9e2118ba26075479eafb1f8bfe24a327c924..1219bb9ae72f219dc644e5403063535a64d913a9 100644 (file)
@@ -16568,7 +16568,8 @@ update_enumeration_type_from_children (struct die_info *die,
     }
 
   if (unsigned_enum)
-    TYPE_UNSIGNED (type) = 1;
+    type->set_is_unsigned (true);
+
   if (flag_enum)
     TYPE_FLAG_ENUM (type) = 1;
 }
@@ -16643,9 +16644,12 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
     {
       struct type *underlying_type = TYPE_TARGET_TYPE (type);
       underlying_type = check_typedef (underlying_type);
-      TYPE_UNSIGNED (type) = TYPE_UNSIGNED (underlying_type);
+
+      type->set_is_unsigned (underlying_type->is_unsigned ());
+
       if (TYPE_LENGTH (type) == 0)
        TYPE_LENGTH (type) = TYPE_LENGTH (underlying_type);
+
       if (TYPE_RAW_ALIGN (type) == 0
          && TYPE_RAW_ALIGN (underlying_type) != 0)
        set_type_align (type, TYPE_RAW_ALIGN (underlying_type));
index b7c8ec8e6432bccccbe27f8c24f885e5a349e0a6..89a310f0ce39298fff661095dcb3691d7ce0736c 100644 (file)
@@ -375,7 +375,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
   /* Mark pointers as unsigned.  The target converts between pointers
      and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
      gdbarch_address_to_pointer.  */
-  TYPE_UNSIGNED (ntype) = 1;
+  ntype->set_is_unsigned (true);
 
   /* Update the length of all the other variants of this type.  */
   chain = TYPE_CHAIN (ntype);
@@ -949,14 +949,14 @@ create_range_type (struct type *result_type, struct type *index_type,
   result_type->set_bounds (bounds);
 
   if (low_bound->kind () == PROP_CONST && low_bound->const_val () >= 0)
-    TYPE_UNSIGNED (result_type) = 1;
+    result_type->set_is_unsigned (true);
 
   /* Ada allows the declaration of range types whose upper bound is
      less than the lower bound, so checking the lower bound is not
      enough.  Make sure we do not mark a range type whose upper bound
      is negative as unsigned.  */
   if (high_bound->kind () == PROP_CONST && high_bound->const_val () < 0)
-    TYPE_UNSIGNED (result_type) = 0;
+    result_type->set_is_unsigned (false);
 
   TYPE_ENDIANITY_NOT_DEFAULT (result_type)
     = TYPE_ENDIANITY_NOT_DEFAULT (index_type);
@@ -1073,9 +1073,7 @@ get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
 
          /* Set unsigned indicator if warranted.  */
          if (*lowp >= 0)
-           {
-             TYPE_UNSIGNED (type) = 1;
-           }
+           type->set_is_unsigned (true);
        }
       else
        {
@@ -1400,7 +1398,7 @@ create_set_type (struct type *result_type, struct type *domain_type)
       TYPE_LENGTH (result_type)
        = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
       if (low_bound >= 0)
-       TYPE_UNSIGNED (result_type) = 1;
+       result_type->set_is_unsigned (true);
     }
   result_type->field (0).set_type (domain_type);
 
@@ -3191,7 +3189,7 @@ init_integer_type (struct objfile *objfile,
 
   t = init_type (objfile, TYPE_CODE_INT, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -3208,7 +3206,7 @@ init_character_type (struct objfile *objfile,
 
   t = init_type (objfile, TYPE_CODE_CHAR, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -3225,7 +3223,7 @@ init_boolean_type (struct objfile *objfile,
 
   t = init_type (objfile, TYPE_CODE_BOOL, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -3319,7 +3317,7 @@ init_pointer_type (struct objfile *objfile,
 
   t = init_type (objfile, TYPE_CODE_PTR, bit, name);
   TYPE_TARGET_TYPE (t) = target_type;
-  TYPE_UNSIGNED (t) = 1;
+  t->set_is_unsigned (true);
   return t;
 }
 
@@ -5477,7 +5475,7 @@ arch_integer_type (struct gdbarch *gdbarch,
 
   t = arch_type (gdbarch, TYPE_CODE_INT, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -5494,7 +5492,7 @@ arch_character_type (struct gdbarch *gdbarch,
 
   t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -5511,7 +5509,7 @@ arch_boolean_type (struct gdbarch *gdbarch,
 
   t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name);
   if (unsigned_p)
-    TYPE_UNSIGNED (t) = 1;
+    t->set_is_unsigned (true);
 
   return t;
 }
@@ -5561,7 +5559,7 @@ arch_pointer_type (struct gdbarch *gdbarch,
 
   t = arch_type (gdbarch, TYPE_CODE_PTR, bit, name);
   TYPE_TARGET_TYPE (t) = target_type;
-  TYPE_UNSIGNED (t) = 1;
+  t->set_is_unsigned (true);
   return t;
 }
 
@@ -5574,7 +5572,7 @@ arch_flags_type (struct gdbarch *gdbarch, const char *name, int bit)
   struct type *type;
 
   type = arch_type (gdbarch, TYPE_CODE_FLAGS, bit, name);
-  TYPE_UNSIGNED (type) = 1;
+  type->set_is_unsigned (true);
   type->set_num_fields (0);
   /* Pre-allocate enough space assuming every field is one bit.  */
   type->set_fields
index 9c2059d40c05385b91b521485ce9faea7c848314..cdd19b434923e9b3fbbe4043c68c7ed7efad538f 100644 (file)
@@ -213,7 +213,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
 /* * Unsigned integer type.  If this is not set for a TYPE_CODE_INT,
    the type is signed (unless TYPE_NOSIGN (below) is set).  */
 
-#define TYPE_UNSIGNED(t)       (TYPE_MAIN_TYPE (t)->flag_unsigned)
+#define TYPE_UNSIGNED(t)       ((t)->is_unsigned ())
 
 /* * No sign for this type.  In C++, "char", "signed char", and
    "unsigned char" are distinct types; so we need an extra flag to
@@ -855,7 +855,7 @@ struct main_type
      because they packs nicely here.  See the TYPE_* macros for
      documentation about these fields.  */
 
-  unsigned int flag_unsigned : 1;
+  unsigned int m_flag_unsigned : 1;
   unsigned int flag_nosign : 1;
   unsigned int flag_stub : 1;
   unsigned int flag_target_stub : 1;
@@ -1068,6 +1068,16 @@ struct type
     return this->bounds ()->bit_stride ();
   }
 
+  bool is_unsigned () const
+  {
+    return this->main_type->m_flag_unsigned;
+  }
+
+  void set_is_unsigned (bool is_unsigned)
+  {
+    this->main_type->m_flag_unsigned = is_unsigned;
+  }
+
   /* * 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;
index d38372041d752e4c188c15de168c10ce6b8162f0..376101e95cbb2e05f9711c247d9832c7bf3b2f70 100644 (file)
@@ -1072,7 +1072,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
                f++;
              }
            if (unsigned_enum)
-             TYPE_UNSIGNED (t) = 1;
+             t->set_is_unsigned (true);
          }
        /* Make this the current type.  */
        top_stack->cur_type = t;
index d2ff54a47bdf5291690d118684cc62b89482cddf..b30b0750f36f5c8039659bd709fbfb9839f42fe8 100644 (file)
@@ -3616,7 +3616,7 @@ read_enum_type (const char **pp, struct type *type,
   type->set_code (TYPE_CODE_ENUM);
   TYPE_STUB (type) = 0;
   if (unsigned_enum)
-    TYPE_UNSIGNED (type) = 1;
+    type->set_is_unsigned (true);
   type->set_num_fields (nsyms);
   type->set_fields
     ((struct field *)
@@ -3731,7 +3731,8 @@ read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile
       struct type *type = init_type (objfile, TYPE_CODE_VOID,
                                     TARGET_CHAR_BIT, NULL);
       if (unsigned_type)
-        TYPE_UNSIGNED (type) = 1;
+       type->set_is_unsigned (true);
+
       return type;
     }
 
index 6778b93400b80eb63a1168a2ce47ef0ce411cb6f..611cb9c05b19afdaa1682aad62d39fadfa9ad7a7 100644 (file)
@@ -289,7 +289,8 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
       m_type = arch_type (m_gdbarch, TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
                          e->name.c_str ());
 
-      TYPE_UNSIGNED (m_type) = 1;
+      m_type->set_is_unsigned (true);
+
       for (const tdesc_type_field &f : e->fields)
        {
          struct field *fld
index aa0adeba99b7a9358ba09e3a5a0db32e8a6ce8e8..0dee73a7bbae8a6384c4b0b578fda98e6993a7f8 100644 (file)
@@ -754,7 +754,7 @@ create_enum (struct gdbarch *gdbarch, int bit, const char *name,
   type->set_num_fields (count);
   type->set_fields
     ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * count));
-  TYPE_UNSIGNED (type) = 1;
+  type->set_is_unsigned (true);
 
   for (i = 0; i < count; i++)
   {