]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/microblaze-tdep.c
Change management of tdesc_arch_data
authorTom Tromey <tromey@adacore.com>
Thu, 17 Sep 2020 20:11:38 +0000 (14:11 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 17 Sep 2020 20:28:06 +0000 (14:28 -0600)
commitc1e1314d00fda5625f1a87b915fd83a61c253993
tree62affcd614124eec0c51db5223b0ea7f797a17d1
parent0363df3db7d3f5edd3a349ab7720eca83f460545
Change management of tdesc_arch_data

While working on something else, I noticed that tdesc_data_cleanup
took a void* parameter.  Looking more into this, I found that
tdesc_use_registers expected a transfer of ownership.

I think it's better to express this sort of thing via the type system,
when possible.  This patch changes tdesc_data_alloc to return a unique
pointer, changes tdesc_use_registers to accept an rvalue reference,
and then adapts all the users.

Note that a deleter structure is introduced to avoid having to move
tdesc_arch_data to the header file.

2020-09-17  Tom Tromey  <tromey@adacore.com>

* tic6x-tdep.c (tic6x_gdbarch_init): Update.
* target-descriptions.h (struct tdesc_arch_data_deleter): New.
(tdesc_arch_data_up): New typedef.
(tdesc_use_registers, tdesc_data_alloc): Update.
(tdesc_data_cleanup): Don't declare.
* target-descriptions.c (tdesc_data_alloc): Return a
tdesc_arch_data_up.
(tdesc_arch_data_deleter::operator()): Rename from
tdesc_data_cleanup.  Change argument type.
(tdesc_use_registers): Change early_data to an rvalue reference.
(tdesc_use_registers): Don't use delete.
* sparc-tdep.c (sparc32_gdbarch_init): Update.
* s390-tdep.c (s390_gdbarch_init): Update.
* rx-tdep.c (rx_gdbarch_init): Update.
* rs6000-tdep.c (rs6000_gdbarch_init): Update.
* riscv-tdep.c (riscv_gdbarch_init): Update.
* or1k-tdep.c (or1k_gdbarch_init): Update.
* nios2-tdep.c (nios2_gdbarch_init): Update.
* nds32-tdep.c (nds32_gdbarch_init): Update.
* mips-tdep.c (mips_gdbarch_init): Update.
* microblaze-tdep.c (microblaze_gdbarch_init): Update.
* m68k-tdep.c (m68k_gdbarch_init): Update.
* i386-tdep.c (i386_gdbarch_init): Update.
* arm-tdep.c (arm_gdbarch_init): Update.
* arc-tdep.c (arc_tdesc_init): Update.
(arc_gdbarch_init): Update.
* aarch64-tdep.c (aarch64_gdbarch_init): Update.
19 files changed:
gdb/ChangeLog
gdb/aarch64-tdep.c
gdb/arc-tdep.c
gdb/arm-tdep.c
gdb/i386-tdep.c
gdb/m68k-tdep.c
gdb/microblaze-tdep.c
gdb/mips-tdep.c
gdb/nds32-tdep.c
gdb/nios2-tdep.c
gdb/or1k-tdep.c
gdb/riscv-tdep.c
gdb/rs6000-tdep.c
gdb/rx-tdep.c
gdb/s390-tdep.c
gdb/sparc-tdep.c
gdb/target-descriptions.c
gdb/target-descriptions.h
gdb/tic6x-tdep.c