gdb: add type::has_no_signedness / type::set_has_no_signedness

Add the `has_no_signedness` and `set_has_no_signednes` methods on `struct
type`, in order to remove the `TYPE_NOSIGN` macro.  In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are used as
a setter are changed to use the setter method directly.  The next patch will
remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <has_no_signedness,
	set_has_no_signedness>: New methods.
	(TYPE_NOSIGN): Use type::has_no_signedness, change all write
	call sites to use type::set_has_no_signedness.

Change-Id: I80d8e774316d146fbd814b2928ad5392bada39d5
This commit is contained in:
Simon Marchi 2020-09-14 11:07:57 -04:00
parent c6d940a956
commit 15152a54ae
7 changed files with 26 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <has_no_signedness,
set_has_no_signedness>: New methods.
(TYPE_NOSIGN): Use type::has_no_signedness, change all write
call sites to use type::set_has_no_signedness.
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (TYPE_UNSIGNED): Remove, replace all uses with

View file

@ -566,7 +566,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid)
}
if (name != NULL && strcmp (name, "char") == 0)
TYPE_NOSIGN (type) = 1;
type->set_has_no_signedness (true);
return set_tid_type (of, tid, type);
}

View file

@ -18058,7 +18058,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
}
if (name && strcmp (name, "char") == 0)
TYPE_NOSIGN (type) = 1;
type->set_has_no_signedness (true);
maybe_set_alignment (cu, die, type);

View file

@ -5725,7 +5725,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
builtin_type->builtin_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char");
TYPE_NOSIGN (builtin_type->builtin_char) = 1;
builtin_type->builtin_char->set_has_no_signedness (true);
builtin_type->builtin_signed_char
= arch_integer_type (gdbarch, TARGET_CHAR_BIT,
0, "signed char");
@ -5884,7 +5884,7 @@ objfile_type (struct objfile *objfile)
objfile_type->builtin_char
= init_integer_type (objfile, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char");
TYPE_NOSIGN (objfile_type->builtin_char) = 1;
objfile_type->builtin_char->set_has_no_signedness (true);
objfile_type->builtin_signed_char
= init_integer_type (objfile, TARGET_CHAR_BIT,
0, "signed char");

View file

@ -214,7 +214,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
"unsigned char" are distinct types; so we need an extra flag to
indicate the absence of a sign! */
#define TYPE_NOSIGN(t) (TYPE_MAIN_TYPE (t)->flag_nosign)
#define TYPE_NOSIGN(t) ((t)->has_no_signedness ())
/* * A compiler may supply dwarf instrumentation
that indicates the desired endian interpretation of the variable
@ -851,7 +851,7 @@ struct main_type
documentation about these fields. */
unsigned int m_flag_unsigned : 1;
unsigned int flag_nosign : 1;
unsigned int m_flag_nosign : 1;
unsigned int flag_stub : 1;
unsigned int flag_target_stub : 1;
unsigned int flag_prototyped : 1;
@ -1076,6 +1076,16 @@ struct type
this->main_type->m_flag_unsigned = is_unsigned;
}
bool has_no_signedness () const
{
return this->main_type->m_flag_nosign;
}
void set_has_no_signedness (bool has_no_signedness)
{
this->main_type->m_flag_nosign = has_no_signedness;
}
/* * 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;

View file

@ -1387,7 +1387,7 @@ basic_type (int bt, struct objfile *objfile)
case btChar:
tp = init_integer_type (objfile, 8, 0, "char");
TYPE_NOSIGN (tp) = 1;
tp->set_has_no_signedness (true);
break;
case btUChar:

View file

@ -2066,7 +2066,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
break;
case 2:
rettype = init_integer_type (objfile, 8, 0, "char");
TYPE_NOSIGN (rettype) = 1;
rettype->set_has_no_signedness (true);
break;
case 3:
rettype = init_integer_type (objfile, 16, 0, "short");
@ -4090,7 +4090,7 @@ read_range_type (const char **pp, int typenums[2], int type_size,
{
struct type *type = init_integer_type (objfile, TARGET_CHAR_BIT,
0, NULL);
TYPE_NOSIGN (type) = 1;
type->set_has_no_signedness (true);
return type;
}
/* We used to do this only for subrange of self or subrange of int. */