+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>
{
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,
}
if (unsigned_enum)
- TYPE_UNSIGNED (type) = 1;
+ type->set_is_unsigned (true);
return type;
}
}
if (unsigned_enum)
- TYPE_UNSIGNED (type) = 1;
+ type->set_is_unsigned (true);
+
if (flag_enum)
TYPE_FLAG_ENUM (type) = 1;
}
{
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));
/* 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);
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);
/* Set unsigned indicator if warranted. */
if (*lowp >= 0)
- {
- TYPE_UNSIGNED (type) = 1;
- }
+ type->set_is_unsigned (true);
}
else
{
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);
t = init_type (objfile, TYPE_CODE_INT, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
t = init_type (objfile, TYPE_CODE_CHAR, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
t = init_type (objfile, TYPE_CODE_BOOL, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
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;
}
t = arch_type (gdbarch, TYPE_CODE_INT, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name);
if (unsigned_p)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
return t;
}
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;
}
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
/* * 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
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;
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;
f++;
}
if (unsigned_enum)
- TYPE_UNSIGNED (t) = 1;
+ t->set_is_unsigned (true);
}
/* Make this the current type. */
top_stack->cur_type = t;
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 *)
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;
}
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
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++)
{