From: Tom de Vries Date: Mon, 13 Jul 2026 13:06:35 +0000 (+0200) Subject: [gdb] Use using instead of typedef some more (part 1) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e670147b63e4cae2bf78bca414610a1f2ae736d;p=thirdparty%2Fbinutils-gdb.git [gdb] Use using instead of typedef some more (part 1) Result of: ... $ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \ | egrep -v /testsuite/ \ | xargs sed -i \ 's/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.() ]*\) \([a-zA-Z_0-9]*\)\(\[.*\]\);/\1using \3 = \2\4;/' $ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \ | egrep -v /testsuite/ \ | xargs sed -i \ 's/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) \([a-zA-Z_0-9]*\);/\1using \3 = \2;/' ... and manually reverting to changes in comments. Approved-By: Tom Tromey --- diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 441032971cb..507f06e0aac 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -3750,14 +3750,14 @@ cris_gdb_func (struct gdbarch *gdbarch, enum cris_op_type op_type, } /* Originally from . */ -typedef unsigned char cris_elf_greg_t[4]; +using cris_elf_greg_t = unsigned char[4]; /* Same as user_regs_struct struct in . */ #define CRISV10_ELF_NGREG 35 -typedef cris_elf_greg_t cris_elf_gregset_t[CRISV10_ELF_NGREG]; +using cris_elf_gregset_t = cris_elf_greg_t[CRISV10_ELF_NGREG]; #define CRISV32_ELF_NGREG 32 -typedef cris_elf_greg_t crisv32_elf_gregset_t[CRISV32_ELF_NGREG]; +using crisv32_elf_gregset_t = cris_elf_greg_t[CRISV32_ELF_NGREG]; /* Unpack a cris_elf_gregset_t into GDB's register cache. */ diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 5b9f41cd53a..6f0601a0146 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -136,7 +136,7 @@ struct dwarf2_fde unsigned char eh_frame_p; }; -typedef std::vector dwarf2_fde_table; +using dwarf2_fde_table = std::vector; /* A minimal decoding of DWARF2 compilation units. We only decode what's needed to get to the call frame information. */ diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c index 3c68921136e..cd9d21c2f14 100644 --- a/gdb/frv-linux-tdep.c +++ b/gdb/frv-linux-tdep.c @@ -346,10 +346,10 @@ static const struct frame_unwind_legacy frv_linux_sigtramp_frame_unwind ( /* The FRV kernel defines ELF_NGREG as 46. We add 2 in order to include the loadmap addresses in the register set. (See below for more info.) */ #define FRV_ELF_NGREG (46 + 2) -typedef unsigned char frv_elf_greg_t[4]; +using frv_elf_greg_t = unsigned char[4]; typedef struct { frv_elf_greg_t reg[FRV_ELF_NGREG]; } frv_elf_gregset_t; -typedef unsigned char frv_elf_fpreg_t[4]; +using frv_elf_fpreg_t = unsigned char[4]; typedef struct { frv_elf_fpreg_t fr[64]; diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h index 8ac1423fb3c..2ba961fde66 100644 --- a/gdb/mips-linux-tdep.h +++ b/gdb/mips-linux-tdep.h @@ -26,11 +26,11 @@ #define ELF_NGREG 45 #define ELF_NFPREG 33 -typedef unsigned char mips_elf_greg_t[4]; -typedef mips_elf_greg_t mips_elf_gregset_t[ELF_NGREG]; +using mips_elf_greg_t = unsigned char[4]; +using mips_elf_gregset_t = mips_elf_greg_t[ELF_NGREG]; -typedef unsigned char mips_elf_fpreg_t[8]; -typedef mips_elf_fpreg_t mips_elf_fpregset_t[ELF_NFPREG]; +using mips_elf_fpreg_t = unsigned char[8]; +using mips_elf_fpregset_t = mips_elf_fpreg_t[ELF_NFPREG]; /* 0 - 31 are integer registers, 32 - 63 are fp registers. */ #define FPR_BASE 32 @@ -64,11 +64,11 @@ void mips_fill_gregset (const struct regcache *, mips_elf_gregset_t *, int); #define MIPS64_ELF_NGREG 45 #define MIPS64_ELF_NFPREG 33 -typedef unsigned char mips64_elf_greg_t[8]; -typedef mips64_elf_greg_t mips64_elf_gregset_t[MIPS64_ELF_NGREG]; +using mips64_elf_greg_t = unsigned char[8]; +using mips64_elf_gregset_t = mips64_elf_greg_t[MIPS64_ELF_NGREG]; -typedef unsigned char mips64_elf_fpreg_t[8]; -typedef mips64_elf_fpreg_t mips64_elf_fpregset_t[MIPS64_ELF_NFPREG]; +using mips64_elf_fpreg_t = unsigned char[8]; +using mips64_elf_fpregset_t = mips64_elf_fpreg_t[MIPS64_ELF_NFPREG]; /* 0 - 31 are integer registers, 32 - 63 are fp registers. */ #define MIPS64_FPR_BASE 32 diff --git a/gdb/mn10300-linux-tdep.c b/gdb/mn10300-linux-tdep.c index cb795999e1f..95e3b123ce3 100644 --- a/gdb/mn10300-linux-tdep.c +++ b/gdb/mn10300-linux-tdep.c @@ -36,10 +36,10 @@ #define MN10300_ELF_NGREG 28 #define MN10300_ELF_NFPREG 32 -typedef gdb_byte mn10300_elf_greg_t[4]; -typedef mn10300_elf_greg_t mn10300_elf_gregset_t[MN10300_ELF_NGREG]; +using mn10300_elf_greg_t = gdb_byte [4]; +using mn10300_elf_gregset_t = mn10300_elf_greg_t[MN10300_ELF_NGREG]; -typedef gdb_byte mn10300_elf_fpreg_t[4]; +using mn10300_elf_fpreg_t = gdb_byte [4]; typedef struct { mn10300_elf_fpreg_t fpregs[MN10300_ELF_NFPREG]; diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 48fde142d62..413e0e0ab97 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -189,7 +189,7 @@ Little-Endian: VR0 VR31 VSCR VRSAVE */ -typedef char gdb_vrregset_t[PPC_LINUX_SIZEOF_VRREGSET]; +using gdb_vrregset_t = char[PPC_LINUX_SIZEOF_VRREGSET]; /* This is the layout of the POWER7 VSX registers and the way they overlap with the existing FPR and VMX registers. @@ -223,7 +223,7 @@ typedef char gdb_vrregset_t[PPC_LINUX_SIZEOF_VRREGSET]; the FP registers (doubleword 0) and hence extend them with additional 64 bits (doubleword 1). The other 32 regs overlap with the VMX registers. */ -typedef char gdb_vsxregset_t[PPC_LINUX_SIZEOF_VSXREGSET]; +using gdb_vsxregset_t = char[PPC_LINUX_SIZEOF_VSXREGSET]; /* On PPC processors that support the Signal Processing Extension (SPE) APU, the general-purpose registers are 64 bits long. diff --git a/gdb/remote.c b/gdb/remote.c index 33222346d06..d66c15186ec 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -99,7 +99,7 @@ bool remote_debug = false; #define OPAQUETHREADBYTES 8 /* a 64 bit opaque identifier */ -typedef unsigned char threadref[OPAQUETHREADBYTES]; +using threadref = unsigned char[OPAQUETHREADBYTES]; struct gdb_ext_thread_info; struct threads_listing_context; diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 052b170fd9a..d3a0cca5cb7 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -42,9 +42,9 @@ enum { TIC6X_PTR_SIZE = 4 }; /* External versions; the size and alignment of the fields should be the same as those on the target. When loaded, the placement of the bits in each field will be the same as on the target. */ -typedef gdb_byte ext_Elf32_Half[2]; -typedef gdb_byte ext_Elf32_Addr[4]; -typedef gdb_byte ext_Elf32_Word[4]; +using ext_Elf32_Half = gdb_byte[2]; +using ext_Elf32_Addr = gdb_byte[4]; +using ext_Elf32_Word = gdb_byte[4]; struct ext_elf32_dsbt_loadseg { @@ -99,7 +99,7 @@ struct int_elf32_dsbt_loadmap /* External link_map and elf32_dsbt_loadaddr struct definitions. */ -typedef gdb_byte ext_ptr[4]; +using ext_ptr = gdb_byte[4]; struct ext_elf32_dsbt_loadaddr { diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 4f0aac31e73..08ee0a9578f 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -57,9 +57,9 @@ enum { FRV_PTR_SIZE = 4 }; /* External versions; the size and alignment of the fields should be the same as those on the target. When loaded, the placement of the bits in each field will be the same as on the target. */ -typedef gdb_byte ext_Elf32_Half[2]; -typedef gdb_byte ext_Elf32_Addr[4]; -typedef gdb_byte ext_Elf32_Word[4]; +using ext_Elf32_Half = gdb_byte[2]; +using ext_Elf32_Addr = gdb_byte[4]; +using ext_Elf32_Word = gdb_byte[4]; struct ext_elf32_fdpic_loadseg { @@ -196,7 +196,7 @@ fetch_loadmap (CORE_ADDR ldmaddr) /* External link_map and elf32_fdpic_loadaddr struct definitions. */ -typedef gdb_byte ext_ptr[4]; +using ext_ptr = gdb_byte[4]; struct ext_elf32_fdpic_loadaddr { diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index 0d39e0ffa48..06ded0dcca8 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -363,7 +363,7 @@ extern void tui_adjust_window_width (struct tui_win_info *win, /* The type of a function that is used to create a TUI window. */ -typedef std::function window_factory; +using window_factory = std::function; /* The type for a data structure that maps a window name to that window's factory function. */ diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 9f94a453749..3e6ad110d28 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -268,7 +268,7 @@ struct tui_source_window_iterator { public: - typedef std::vector::iterator inner_iterator; + using inner_iterator = std::vector::iterator; using self_type = tui_source_window_iterator; using value_type = struct tui_source_window_base *; diff --git a/gdbsupport/fileio.h b/gdbsupport/fileio.h index bb70e404bba..c2592cf8c15 100644 --- a/gdbsupport/fileio.h +++ b/gdbsupport/fileio.h @@ -113,12 +113,12 @@ enum fileio_error #define FIO_LONG_LEN 8 #define FIO_ULONG_LEN 8 -typedef char fio_int_t[FIO_INT_LEN]; -typedef char fio_uint_t[FIO_UINT_LEN]; -typedef char fio_mode_t[FIO_MODE_LEN]; -typedef char fio_time_t[FIO_TIME_LEN]; -typedef char fio_long_t[FIO_LONG_LEN]; -typedef char fio_ulong_t[FIO_ULONG_LEN]; +using fio_int_t = char[FIO_INT_LEN]; +using fio_uint_t = char[FIO_UINT_LEN]; +using fio_mode_t = char[FIO_MODE_LEN]; +using fio_time_t = char[FIO_TIME_LEN]; +using fio_long_t = char[FIO_LONG_LEN]; +using fio_ulong_t = char[FIO_ULONG_LEN]; /* Struct stat as used in protocol. For complete independence of host/target systems, it's defined as an array with offsets