]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use type allocator for set types
authorTom Tromey <tom@tromey.com>
Mon, 13 Mar 2023 19:25:41 +0000 (13:25 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 18 Mar 2023 17:12:38 +0000 (11:12 -0600)
This changes the set type creation function to accept a type
allocator, and updates all the callers.  Note that symbol readers
should generally allocate on the relevant objfile, regardless of the
underlying type of the set, which is what this patch implements.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/read.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/stabsread.c

index 3019bbd78b077d014159de23119d2d3d493c604c..e1ae98fe91022fe58a1a051d8c357ec30bae1984 100644 (file)
@@ -13825,7 +13825,8 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu)
   if (set_type)
     return set_type;
 
-  set_type = create_set_type (NULL, domain_type);
+  type_allocator alloc (cu->per_objfile->objfile);
+  set_type = create_set_type (alloc, domain_type);
 
   attr = dwarf2_attr (die, DW_AT_byte_size, cu);
   if (attr != nullptr && attr->form_is_unsigned ())
index 3c2fdc625e4b1b178bc361081f0a779f05c91ebf..1b0adbdbe05d7d656202782e06a128d5e0e95ba9 100644 (file)
@@ -1445,10 +1445,9 @@ lookup_string_range_type (struct type *string_char_type,
 }
 
 struct type *
-create_set_type (struct type *result_type, struct type *domain_type)
+create_set_type (type_allocator &alloc, struct type *domain_type)
 {
-  if (result_type == NULL)
-    result_type = type_allocator (domain_type).new_type ();
+  struct type *result_type = alloc.new_type ();
 
   result_type->set_code (TYPE_CODE_SET);
   result_type->set_num_fields (1);
index e664c2c35efc0b0f68fed08f17a46b76a8a1f509..f26eff4770ec3a146691c48f2ec5ee23ad0b82c5 100644 (file)
@@ -2547,7 +2547,8 @@ extern struct type *create_string_type (type_allocator &alloc,
 
 extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
 
-extern struct type *create_set_type (struct type *, struct type *);
+extern struct type *create_set_type (type_allocator &alloc,
+                                    struct type *domain_type);
 
 extern struct type *lookup_unsigned_typename (const struct language_defn *,
                                              const char *);
index c8c49e154039fd3386128d6959daff515f1b6a14..89d778db1c26141da7f91b4eb1a93bdd6ad2b75f 100644 (file)
@@ -2016,10 +2016,13 @@ again:
       break;
 
     case 'S':                  /* Set type */
-      type1 = read_type (pp, objfile);
-      type = create_set_type (NULL, type1);
-      if (typenums[0] != -1)
-       *dbx_lookup_type (typenums, objfile) = type;
+      {
+       type1 = read_type (pp, objfile);
+       type_allocator alloc (objfile);
+       type = create_set_type (alloc, type1);
+       if (typenums[0] != -1)
+         *dbx_lookup_type (typenums, objfile) = type;
+      }
       break;
 
     default: