diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-09-14 11:07:57 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-09-14 11:07:57 -0400 |
commit | 15152a54aebbd4eba6151b20333ba48ccfd703c5 (patch) | |
tree | 454753d02fe51d8c5f0e714aa82fbf14b9ae8efe | |
parent | c6d940a9569deb4a89a5628caa78b1ccfcfd2bdf (diff) | |
download | gdb-15152a54aebbd4eba6151b20333ba48ccfd703c5.zip gdb-15152a54aebbd4eba6151b20333ba48ccfd703c5.tar.gz gdb-15152a54aebbd4eba6151b20333ba48ccfd703c5.tar.bz2 |
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
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/ctfread.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 2 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 4 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 14 | ||||
-rw-r--r-- | gdb/mdebugread.c | 2 | ||||
-rw-r--r-- | gdb/stabsread.c | 4 |
7 files changed, 26 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4772433..a761ebe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 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 type::is_unsigned. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 5b6d731..14f6404 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -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); } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index b461bd1..299b04b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 5649937..88d9f7e 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -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"); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index bd03df4..623b8cc 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -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; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 376101e..4fd3de1 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -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: diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 054b67e..5f654e7 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -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. */ |