Reuse existing builtin types
authorTom Tromey <tom@tromey.com>
Mon, 13 Mar 2023 15:31:13 +0000 (09:31 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 18 Mar 2023 17:12:37 +0000 (11:12 -0600)
This changes a few spots to reuse the existing builting "void" type,
rather than construct a new one.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/jit.c
gdb/opencl-lang.c

index 8286c5be64629453e906a3d373e5509d27bd3378..457e367fd511acac490c32a17ce4ee1f2cafd24a 100644 (file)
@@ -201,8 +201,7 @@ build_d_types (struct gdbarch *gdbarch)
   struct builtin_d_type *builtin_d_type = new struct builtin_d_type;
 
   /* Basic types.  */
-  builtin_d_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+  builtin_d_type->builtin_void = builtin_type (gdbarch)->builtin_void;
   builtin_d_type->builtin_bool
     = arch_boolean_type (gdbarch, 8, 1, "bool");
   builtin_d_type->builtin_byte
index 0d7863e4fd1987e6a4473e1846ec07c276b8d780..e1eb47577d6cb3f16bd006322c3544489ed86256 100644 (file)
@@ -1725,8 +1725,7 @@ build_fortran_types (struct gdbarch *gdbarch)
 {
   struct builtin_f_type *builtin_f_type = new struct builtin_f_type;
 
-  builtin_f_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+  builtin_f_type->builtin_void = builtin_type (gdbarch)->builtin_void;
 
   builtin_f_type->builtin_character
     = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
index bbf80af1f5c361a86fd4ae6ca0c58866c15e6fac..456b74d80df4839b9bdb12068321b1ac310805a4 100644 (file)
@@ -483,8 +483,7 @@ build_go_types (struct gdbarch *gdbarch)
 {
   struct builtin_go_type *builtin_go_type = new struct builtin_go_type;
 
-  builtin_go_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+  builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void;
   builtin_go_type->builtin_char
     = arch_character_type (gdbarch, 8, 1, "char");
   builtin_go_type->builtin_bool
index 52b65746f112c3db0e3972273b73bc35ec666860..e276b3417a04c5b8571f03ded70202adc2fdb285 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -571,10 +571,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
     {
       struct block *new_block = new (&objfile->objfile_obstack) block;
       struct symbol *block_name = new (&objfile->objfile_obstack) symbol;
-      struct type *block_type = arch_type (objfile->arch (),
-                                          TYPE_CODE_VOID,
-                                          TARGET_CHAR_BIT,
-                                          "void");
+      struct type *block_type = builtin_type (objfile->arch ())->builtin_void;
 
       new_block->set_multidict
        (mdict_create_linear (&objfile->objfile_obstack, NULL));
index ae1a6d4446d6440297b05c8511d27ce6fadcfe1a..9b5304f588f41b73e95eaaff79a061d951337f23 100644 (file)
@@ -941,7 +941,7 @@ public:
     add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "ptrdiff_t"));
     add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 0, "intptr_t"));
     add (arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr_t"));
-    add (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"));
+    add (builtin_type (gdbarch)->builtin_void);
 
     /* Type of elements of strings.  */
     lai->set_string_char_type (char_type);