]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Use using instead of typedef some more (part 1)
authorTom de Vries <tdevries@suse.de>
Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)
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 <tom@tromey.com>
12 files changed:
gdb/cris-tdep.c
gdb/dwarf2/frame.c
gdb/frv-linux-tdep.c
gdb/mips-linux-tdep.h
gdb/mn10300-linux-tdep.c
gdb/ppc-linux-nat.c
gdb/remote.c
gdb/solib-dsbt.c
gdb/solib-frv.c
gdb/tui/tui-layout.h
gdb/tui/tui-winsource.h
gdbsupport/fileio.h

index 441032971cb13bf8c6712b98e29611e93242d8d4..507f06e0aac46779cfd8954f69a6ebe374bf5632 100644 (file)
@@ -3750,14 +3750,14 @@ cris_gdb_func (struct gdbarch *gdbarch, enum cris_op_type op_type,
 }
 
 /* Originally from <asm/elf.h>.  */
-typedef unsigned char cris_elf_greg_t[4];
+using cris_elf_greg_t = unsigned char[4];
 
 /* Same as user_regs_struct struct in <asm/user.h>.  */
 #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.  */
 
index 5b9f41cd53a48e5e16dec441ad656b06e9b9f149..6f0601a0146e380bab950644afd161917fc68fed 100644 (file)
@@ -136,7 +136,7 @@ struct dwarf2_fde
   unsigned char eh_frame_p;
 };
 
-typedef std::vector<dwarf2_fde *> dwarf2_fde_table;
+using dwarf2_fde_table = std::vector<dwarf2_fde *>;
 
 /* A minimal decoding of DWARF2 compilation units.  We only decode
    what's needed to get to the call frame information.  */
index 3c68921136e5124c18614f086cf738cf16f34bd1..cd9d21c2f14a7fa0594c59c1a5bedc204639b7c1 100644 (file)
@@ -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];
index 8ac1423fb3cf8cde536293e7717d5a5a00e63da2..2ba961fde66c36fdb8ebf1b0ba6e53571f9a8e25 100644 (file)
 #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
index cb795999e1f1eae461f6790e87eed8e4eada6d7c..95e3b123ce34a7968edcdd541dbf8b43dd215413 100644 (file)
 #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];
index 48fde142d6241a0aef0ef1c9157c7a8810be1e06..413e0e0ab97f34dc9e2ab5acf3b5455ca5d0fcf0 100644 (file)
@@ -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.
index 33222346d063ce6be7ea98284a1eb250d5f8beb2..d66c15186ec53639bf1cd29717c36b90c752df10 100644 (file)
@@ -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;
index 052b170fd9a684928ebcc41b21e0bda3f172b602..d3a0cca5cb78d04545686d2bd740a9f47e6acc3f 100644 (file)
@@ -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
 {
index 4f0aac31e7332b28e17f9f6287fc92fb198bc702..08ee0a9578fced97fd94b179703e340738c345e7 100644 (file)
@@ -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
 {
index 0d39e0ffa48c25d50dc7b26d306d86ee54190b3b..06ded0dcca891d042b916e432adb8fbf9df252b3 100644 (file)
@@ -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<tui_win_info * (const char *name)> window_factory;
+using window_factory = std::function<tui_win_info * (const char *name)>;
 
 /* The type for a data structure that maps a window name to that window's
    factory function.  */
index 9f94a45374980e0258aef770921ce3fd3a4c1d33..3e6ad110d284c75c72784ae03244d5b90dadf10a 100644 (file)
@@ -268,7 +268,7 @@ struct tui_source_window_iterator
 {
 public:
 
-  typedef std::vector<tui_win_info *>::iterator inner_iterator;
+  using inner_iterator = std::vector<tui_win_info *>::iterator;
 
   using self_type = tui_source_window_iterator;
   using value_type = struct tui_source_window_base *;
index bb70e404bbaca913397ae33b82b564b374269f73..c2592cf8c15973de6ed25e8f122b5d64d5df7595 100644 (file)
@@ -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