+2020-09-14 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (TYPE_UNSIGNED): Remove, replace all uses with
+ type::is_unsigned.
+
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <is_unsigned, set_is_unsigned>: New
if (len < 4)
{
/* Promote to 32 bit integer. */
- if (TYPE_UNSIGNED (arg_type))
+ if (arg_type->is_unsigned ())
arg_type = builtin_type (gdbarch)->builtin_uint32;
else
arg_type = builtin_type (gdbarch)->builtin_int32;
static LONGEST
max_of_type (struct type *t)
{
- if (TYPE_UNSIGNED (t))
+ if (t->is_unsigned ())
return (LONGEST) umax_of_size (TYPE_LENGTH (t));
else
return max_of_size (TYPE_LENGTH (t));
static LONGEST
min_of_type (struct type *t)
{
- if (TYPE_UNSIGNED (t))
+ if (t->is_unsigned ())
return 0;
else
return min_of_size (TYPE_LENGTH (t));
default:
return 0;
case TYPE_CODE_INT:
- return !TYPE_UNSIGNED (type);
+ return !type->is_unsigned ();
case TYPE_CODE_RANGE:
return type->bounds ()->low.const_val () - type->bounds ()->bias < 0;
}
if (v2 == 0)
error (_("second operand of %s must not be zero."), op_string (op));
- if (TYPE_UNSIGNED (type1) || op == BINOP_MOD)
+ if (type1->is_unsigned () || op == BINOP_MOD)
return value_binop (arg1, arg2, op);
v1 = value_as_long (arg1);
return (subranged_type != NULL && type->code () == TYPE_CODE_RANGE
&& subranged_type->code () == TYPE_CODE_INT
- && TYPE_UNSIGNED (subranged_type));
+ && subranged_type->is_unsigned ());
}
/* Assuming ada_is_modular_type (TYPE), the modulus of TYPE. */
break;
case TYPE_CODE_INT:
- print_longest (stream, TYPE_UNSIGNED (type) ? 'u' : 'd', 0, val);
+ print_longest (stream, type->is_unsigned () ? 'u' : 'd', 0, val);
break;
case TYPE_CODE_CHAR:
type is indicated by the quoted string anyway. */
if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) != sizeof (char)
|| TYPE_TARGET_TYPE (type)->code () != TYPE_CODE_INT
- || TYPE_UNSIGNED (TYPE_TARGET_TYPE (type)))
+ || TYPE_TARGET_TYPE (type)->is_unsigned ())
{
fprintf_filtered (stream, "(");
type_print (type, "", stream, -1);
gen_sign_extend (struct agent_expr *ax, struct type *type)
{
/* Do we need to sign-extend this? */
- if (!TYPE_UNSIGNED (type))
+ if (!type->is_unsigned ())
ax_ext (ax, TYPE_LENGTH (type) * TARGET_CHAR_BIT);
}
int bits = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
/* I just had to. */
- ((TYPE_UNSIGNED (type) ? ax_zero_ext : ax_ext) (ax, bits));
+ ((type->is_unsigned () ? ax_zero_ext : ax_ext) (ax, bits));
}
{
return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)
|| (TYPE_LENGTH (type1) == TYPE_LENGTH (type2)
- && TYPE_UNSIGNED (type1)
- && !TYPE_UNSIGNED (type2)));
+ && type1->is_unsigned ()
+ && !type2->is_unsigned ()));
}
then we need to extend. */
else if (TYPE_LENGTH (to) == TYPE_LENGTH (from))
{
- if (TYPE_UNSIGNED (from) != TYPE_UNSIGNED (to))
+ if (from->is_unsigned () != to->is_unsigned ())
gen_extend (ax, to);
}
we need to zero out any possible sign bits. */
else if (TYPE_LENGTH (to) > TYPE_LENGTH (from))
{
- if (TYPE_UNSIGNED (to))
+ if (to->is_unsigned ())
gen_extend (ax, to);
}
}
|| (value2->type->code () != TYPE_CODE_INT))
error (_("Invalid combination of types in %s."), name);
- ax_simple (ax,
- TYPE_UNSIGNED (value1->type) ? op_unsigned : op);
+ ax_simple (ax, value1->type->is_unsigned () ? op_unsigned : op);
if (may_carry)
gen_extend (ax, value1->type); /* catch overflow */
value->type = value1->type;
ax_simple (ax, aop_bit_or);
/* Sign- or zero-extend the value as appropriate. */
- ((TYPE_UNSIGNED (type) ? ax_zero_ext : ax_ext) (ax, end - start));
+ ((type->is_unsigned () ? ax_zero_ext : ax_ext) (ax, end - start));
/* This is *not* an lvalue. Ugh. */
value->kind = axs_rvalue;
if (mode != NULL)
{
- if (TYPE_UNSIGNED (regtype))
+ if (regtype->is_unsigned ())
fputs_unfiltered ("unsigned ", stream);
fprintf_unfiltered (stream,
"int %s"
gcc_type int_type, result;
int i;
- int_type = context->plugin ().int_type_v0 (TYPE_UNSIGNED (type),
+ int_type = context->plugin ().int_type_v0 (type->is_unsigned (),
TYPE_LENGTH (type));
result = context->plugin ().build_enum_type (int_type);
gdb_assert (TYPE_LENGTH (type) == 1);
return context->plugin ().char_type ();
}
- return context->plugin ().int_type (TYPE_UNSIGNED (type),
+ return context->plugin ().int_type (type->is_unsigned (),
TYPE_LENGTH (type),
type->name ());
}
else
- return context->plugin ().int_type_v0 (TYPE_UNSIGNED (type),
+ return context->plugin ().int_type_v0 (type->is_unsigned (),
TYPE_LENGTH (type));
}
instance->enter_scope (std::move (scope));
gcc_type int_type
- = instance->plugin ().get_int_type (TYPE_UNSIGNED (type),
+ = instance->plugin ().get_int_type (type->is_unsigned (),
TYPE_LENGTH (type), nullptr);
gcc_type result
= instance->plugin ().start_enum_type (name.get (), int_type,
}
return instance->plugin ().get_int_type
- (TYPE_UNSIGNED (type), TYPE_LENGTH (type), type->name ());
+ (type->is_unsigned (), TYPE_LENGTH (type), type->name ());
}
/* Convert a floating-point type to its gcc representation. */
{
if (t1->code () != t2->code ())
return 0;
- if (TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2))
+ if (t1->is_unsigned () != t2->is_unsigned ())
return 0;
return TYPE_LENGTH (t1) == TYPE_LENGTH (t2);
}
case DW_OP_shr:
dwarf_require_integral (value_type (first));
dwarf_require_integral (value_type (second));
- if (!TYPE_UNSIGNED (value_type (first)))
+ if (!value_type (first)->is_unsigned ())
{
struct type *utype
= get_unsigned_type (this->gdbarch, value_type (first));
case DW_OP_shra:
dwarf_require_integral (value_type (first));
dwarf_require_integral (value_type (second));
- if (TYPE_UNSIGNED (value_type (first)))
+ if (value_type (first)->is_unsigned ())
{
struct type *stype
= get_signed_type (this->gdbarch, value_type (first));
struct type *type = check_typedef (baton->property_type);
if (TYPE_LENGTH (type) < sizeof (CORE_ADDR)
- && !TYPE_UNSIGNED (type))
+ && !type->is_unsigned ())
{
/* If we have a valid return candidate and it's value
is signed, we have to sign-extend the value because
part->is_unsigned
= (discriminant_index == -1
? false
- : TYPE_UNSIGNED (type->field (discriminant_index).type ()));
+ : type->field (discriminant_index).type ()->is_unsigned ());
part->variants = gdb::array_view<variant> (variants, n_variants);
void *storage = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>));
{
result.discriminant_index = iter->second;
result.is_unsigned
- = TYPE_UNSIGNED (fi->fields[result.discriminant_index].field.type ());
+ = fi->fields[result.discriminant_index].field.type ()->is_unsigned ();
}
size_t n = builder.variants.size ();
negative_mask =
-((ULONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1));
if (low.kind () == PROP_CONST
- && !TYPE_UNSIGNED (base_type) && (low.const_val () & negative_mask))
+ && !base_type->is_unsigned () && (low.const_val () & negative_mask))
low.set_const_val (low.const_val () | negative_mask);
if (high.kind () == PROP_CONST
- && !TYPE_UNSIGNED (base_type) && (high.const_val () & negative_mask))
+ && !base_type->is_unsigned () && (high.const_val () & negative_mask))
high.set_const_val (high.const_val () | negative_mask);
/* Check for bit and byte strides. */
if (TYPE_LENGTH (addr_type) == addr_size)
return addr_type;
- addr_type = addr_sized_int_type (TYPE_UNSIGNED (addr_type));
+ addr_type = addr_sized_int_type (addr_type->is_unsigned ());
return addr_type;
}
const struct builtin_type *builtin = builtin_type (gdbarch);
unsigned int promoted_len1 = TYPE_LENGTH (type1);
unsigned int promoted_len2 = TYPE_LENGTH (type2);
- int is_unsigned1 = TYPE_UNSIGNED (type1);
- int is_unsigned2 = TYPE_UNSIGNED (type2);
+ int is_unsigned1 = type1->is_unsigned ();
+ int is_unsigned2 = type2->is_unsigned ();
unsigned int result_len;
int unsigned_operation;
{
int ival;
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
{
ULONGEST uval = static_cast <ULONGEST> (val);
if (uval > INT_MAX)
case TYPE_CODE_INT:
if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */
return -1;
- if (!TYPE_UNSIGNED (type))
+ if (!type->is_unsigned ())
{
*lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
*highp = -*lowp - 1;
unsigned int n;
type = check_typedef (type);
- gdb_assert (type->code () == TYPE_CODE_INT && TYPE_UNSIGNED (type));
+ gdb_assert (type->code () == TYPE_CODE_INT && type->is_unsigned ());
gdb_assert (TYPE_LENGTH (type) <= sizeof (ULONGEST));
/* Written this way to avoid overflow. */
unsigned int n;
type = check_typedef (type);
- gdb_assert (type->code () == TYPE_CODE_INT && !TYPE_UNSIGNED (type));
+ gdb_assert (type->code () == TYPE_CODE_INT && !type->is_unsigned ());
gdb_assert (TYPE_LENGTH (type) <= sizeof (LONGEST));
n = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
if (type1->code () != type2->code ()
|| TYPE_LENGTH (type1) != TYPE_LENGTH (type2)
- || TYPE_UNSIGNED (type1) != TYPE_UNSIGNED (type2)
+ || type1->is_unsigned () != type2->is_unsigned ()
|| TYPE_NOSIGN (type1) != TYPE_NOSIGN (type2)
|| TYPE_ENDIANITY_NOT_DEFAULT (type1) != TYPE_ENDIANITY_NOT_DEFAULT (type2)
|| TYPE_VARARGS (type1) != TYPE_VARARGS (type2)
else /* signed/unsigned char -> plain char */
return INTEGER_CONVERSION_BADNESS;
}
- else if (TYPE_UNSIGNED (parm))
+ else if (parm->is_unsigned ())
{
- if (TYPE_UNSIGNED (arg))
+ if (arg->is_unsigned ())
{
/* unsigned int -> unsigned int, or
unsigned long -> unsigned long */
return INTEGER_CONVERSION_BADNESS;
}
}
- else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
+ else if (!TYPE_NOSIGN (arg) && !arg->is_unsigned ())
{
if (integer_types_same_name_p (parm->name (),
arg->name ()))
else
return INTEGER_CONVERSION_BADNESS;
}
- else if (TYPE_UNSIGNED (parm))
+ else if (parm->is_unsigned ())
{
- if (TYPE_UNSIGNED (arg))
+ if (arg->is_unsigned ())
return EXACT_MATCH_BADNESS;
else
return INTEGER_PROMOTION_BADNESS;
}
- else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
+ else if (!TYPE_NOSIGN (arg) && !arg->is_unsigned ())
return EXACT_MATCH_BADNESS;
else
return INTEGER_CONVERSION_BADNESS;
puts_filtered ("\n");
printfi_filtered (spaces, "flags");
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
{
puts_filtered (" TYPE_UNSIGNED");
}
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) ((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
indicate the absence of a sign! */
return this->bounds ()->bit_stride ();
}
+ /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
+ the type is signed (unless TYPE_NOSIGN is set). */
+
bool is_unsigned () const
{
return this->main_type->m_flag_unsigned;
if (is_integral_type (type)
|| type->code () == TYPE_CODE_PTR)
{
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
{
ULONGEST max;
static int
vlscm_integer_fits_p (SCM obj, struct type *type)
{
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
{
ULONGEST max;
}
GDBSCM_HANDLE_GDB_EXCEPTION (exc);
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
return gdbscm_scm_from_ulongest (l);
else
return gdbscm_scm_from_longest (l);
d = target_float_to_host_double (value_contents (value), type);
check = value_from_host_double (type, d);
}
- else if (TYPE_UNSIGNED (type))
+ else if (type->is_unsigned ())
{
d = (ULONGEST) value_as_long (value);
check = value_from_ulongest (type, (ULONGEST) d);
case TYPE_CODE_CHAR:
if (TYPE_LENGTH (type) < sizeof (LONGEST))
{
- if (!TYPE_UNSIGNED (type))
+ if (!type->is_unsigned ())
{
*lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
*highp = -*lowp - 1;
|| typecode == TYPE_CODE_INT))
|| (partial_len < 4
&& typecode == TYPE_CODE_INT
- && !TYPE_UNSIGNED (arg_type)))
+ && !arg_type->is_unsigned ()))
regval = extract_signed_integer (val, partial_len,
byte_order);
else
if (types[i]->code () == TYPE_CODE_ARRAY && TYPE_VECTOR (types[i])
&& get_array_bounds (types[i], &lowb, &highb)
&& TYPE_TARGET_TYPE (types[i])->code () == code
- && TYPE_UNSIGNED (TYPE_TARGET_TYPE (types[i])) == flag_unsigned
+ && TYPE_TARGET_TYPE (types[i])->is_unsigned () == flag_unsigned
&& TYPE_LENGTH (TYPE_TARGET_TYPE (types[i])) == el_length
&& TYPE_LENGTH (types[i]) == length
&& highb - lowb + 1 == n)
struct type *dst_type =
lookup_opencl_vector_type (gdbarch, elm_type->code (),
TYPE_LENGTH (elm_type),
- TYPE_UNSIGNED (elm_type), n);
+ elm_type->is_unsigned (), n);
if (dst_type == NULL)
dst_type = init_vector_type (elm_type, n);
/* Check whether the vector types are compatible. */
if (eltype1->code () != eltype2->code ()
|| TYPE_LENGTH (eltype1) != TYPE_LENGTH (eltype2)
- || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+ || eltype1->is_unsigned () != eltype2->is_unsigned ()
|| lowb1 != lowb2 || highb1 != highb2)
error (_("Cannot perform operation on vectors with different types"));
/* Throw an error if the types of arg2 or arg3 are incompatible. */
if (eltype2->code () != eltype3->code ()
|| TYPE_LENGTH (eltype2) != TYPE_LENGTH (eltype3)
- || TYPE_UNSIGNED (eltype2) != TYPE_UNSIGNED (eltype3)
+ || eltype2->is_unsigned () != eltype3->is_unsigned ()
|| lowb2 != lowb3 || highb2 != highb3)
error (_("\
Cannot perform operation on vectors with different types"));
a negative signed value (e.g. "print/u (short)-1" should print 65535
(if shorts are 16 bits) instead of 4294967295). */
if (options->format != 'c'
- && (options->format != 'd' || TYPE_UNSIGNED (type)))
+ && (options->format != 'd' || type->is_unsigned ()))
{
if (len < TYPE_LENGTH (type) && byte_order == BFD_ENDIAN_BIG)
valaddr += TYPE_LENGTH (type) - len;
case 0:
if (type->code () != TYPE_CODE_FLT)
{
- print_decimal_chars (stream, valaddr, len, !TYPE_UNSIGNED (type),
+ print_decimal_chars (stream, valaddr, len, !type->is_unsigned (),
byte_order);
break;
}
val_long.emplace (unpack_long (type, valaddr));
opts.format = 0;
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
type = builtin_type (gdbarch)->builtin_true_unsigned_char;
else
type = builtin_type (gdbarch)->builtin_true_char;
GDB_PY_HANDLE_EXCEPTION (except);
}
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
return gdb_py_object_from_ulongest (l).release ();
else
return gdb_py_object_from_longest (l).release ();
GDB_PY_HANDLE_EXCEPTION (except);
}
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
return gdb_py_long_from_ulongest (l);
else
return gdb_py_long_from_longest (l);
rust_u8_type_p (struct type *type)
{
return (type->code () == TYPE_CODE_INT
- && TYPE_UNSIGNED (type)
+ && type->is_unsigned ()
&& TYPE_LENGTH (type) == 1);
}
{
return (type->code () == TYPE_CODE_CHAR
&& TYPE_LENGTH (type) == 4
- && TYPE_UNSIGNED (type));
+ && type->is_unsigned ());
}
/* If VALUE represents a trait object pointer, return the underlying
case TYPE_CODE_INT:
/* Recognize the unit type. */
- if (TYPE_UNSIGNED (type) && TYPE_LENGTH (type) == 0
+ if (type->is_unsigned () && TYPE_LENGTH (type) == 0
&& type->name () != NULL && strcmp (type->name (), "()") == 0)
{
fputs_filtered ("()", stream);
/* Place value in least significant bits of the register or
memory word and sign- or zero-extend to full word size.
This also applies to a struct or union. */
- val = TYPE_UNSIGNED (type)
+ val = type->is_unsigned ()
? extract_unsigned_integer (value_contents (arg),
length, byte_order)
: extract_signed_integer (value_contents (arg),
if (out != NULL)
regcache->cooked_read_part (S390_R2_REGNUM, word_size - length, length,
out);
- else if (TYPE_UNSIGNED (type))
+ else if (type->is_unsigned ())
regcache_cooked_write_unsigned
(regcache, S390_R2_REGNUM,
extract_unsigned_integer (in, length, byte_order));
&& SYMBOL_TYPE (sym)->code () == TYPE_CODE_INT)
{
SYMBOL_TYPE (sym) =
- TYPE_UNSIGNED (SYMBOL_TYPE (sym))
- ? objfile_type (objfile)->builtin_unsigned_int
- : objfile_type (objfile)->builtin_int;
+ (SYMBOL_TYPE (sym)->is_unsigned ()
+ ? objfile_type (objfile)->builtin_unsigned_int
+ : objfile_type (objfile)->builtin_int);
}
break;
}
break;
case TYPE_CODE_INT:
- print_longest (stream, TYPE_UNSIGNED (type) ? 'u' : 'd', 0, val);
+ print_longest (stream, type->is_unsigned () ? 'u' : 'd', 0, val);
break;
case TYPE_CODE_CHAR:
else if (is_integral_type (type1))
{
*eff_type_x = type2;
- if (TYPE_UNSIGNED (type1))
+ if (type1->is_unsigned ())
target_float_from_ulongest (x, *eff_type_x, value_as_long (arg1));
else
target_float_from_longest (x, *eff_type_x, value_as_long (arg1));
else if (is_integral_type (type2))
{
*eff_type_y = type1;
- if (TYPE_UNSIGNED (type2))
+ if (type2->is_unsigned ())
target_float_from_ulongest (y, *eff_type_y, value_as_long (arg2));
else
target_float_from_longest (y, *eff_type_y, value_as_long (arg2));
result_type = type1;
else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
result_type = type2;
- else if (TYPE_UNSIGNED (type1))
+ else if (type1->is_unsigned ())
result_type = type1;
- else if (TYPE_UNSIGNED (type2))
+ else if (type2->is_unsigned ())
result_type = type2;
else
result_type = type1;
else
result_type = promotion_type (type1, type2);
- if (TYPE_UNSIGNED (result_type))
+ if (result_type->is_unsigned ())
{
LONGEST v2_signed = value_as_long (arg2);
ULONGEST v1, v2, v = 0;
if (eltype1->code () != eltype2->code ()
|| elsize != TYPE_LENGTH (eltype2)
- || TYPE_UNSIGNED (eltype1) != TYPE_UNSIGNED (eltype2)
+ || eltype1->is_unsigned () != eltype2->is_unsigned ()
|| low_bound1 != low_bound2 || high_bound1 != high_bound2)
error (_("Cannot perform operation on vectors with different types"));
}
/* The only option left is an integral type. */
- if (TYPE_UNSIGNED (type2))
+ if (type2->is_unsigned ())
return value_from_ulongest (to_type, value_as_long (arg2));
else
return value_from_longest (to_type, value_as_long (arg2));
LONGEST valmask = (((ULONGEST) 1) << value_bitsize (toval)) - 1;
fieldval &= valmask;
- if (!TYPE_UNSIGNED (type)
+ if (!type->is_unsigned ()
&& (fieldval & (valmask ^ (valmask >> 1))))
fieldval |= ~valmask;
const gdb_byte *valaddr = value_contents_for_printing (value);
LONGEST val = unpack_long (type, valaddr);
- if (TYPE_UNSIGNED (type))
+ if (type->is_unsigned ())
fprintf_filtered (stream, "%u", (unsigned int) val);
else
fprintf_filtered (stream, "%d", (int) val);
enum bfd_endian byte_order = type_byte_order (type);
enum type_code code = type->code ();
int len = TYPE_LENGTH (type);
- int nosign = TYPE_UNSIGNED (type);
+ int nosign = type->is_unsigned ();
switch (code)
{
{
valmask = (((ULONGEST) 1) << bitsize) - 1;
val &= valmask;
- if (!TYPE_UNSIGNED (field_type))
+ if (!field_type->is_unsigned ())
{
if (val & (valmask ^ (valmask >> 1)))
{