[v2,31/31] Convert gdbtypes.c to type-safe registry API

Message ID 20190503231231.8954-32-tom@tromey.com
State New
Headers show
Series
  • Add a type-safe API to registries
Related show

Commit Message

Tom Tromey May 3, 2019, 11:12 p.m.
This changes gdbtypes.c to use the type-safe registry API.

2019-05-02  Tom Tromey  <tom@tromey.com>

	* gdbtypes.c (objfile_type_data): Change type.
	(objfile_type, _initialize_gdbtypes): Update.
---
 gdb/ChangeLog  |  5 +++++
 gdb/gdbtypes.c | 10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b3424d81be4..59456f9f3a4 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5458,14 +5458,15 @@  gdbtypes_post_init (struct gdbarch *gdbarch)
 /* This set of objfile-based types is intended to be used by symbol
    readers as basic types.  */
 
-static const struct objfile_data *objfile_type_data;
+static const struct objfile_key<struct objfile_type,
+				gdb::noop_deleter<struct objfile_type>>
+  objfile_type_data;
 
 const struct objfile_type *
 objfile_type (struct objfile *objfile)
 {
   struct gdbarch *gdbarch;
-  struct objfile_type *objfile_type
-    = (struct objfile_type *) objfile_data (objfile, objfile_type_data);
+  struct objfile_type *objfile_type = objfile_type_data.get (objfile);
 
   if (objfile_type)
     return objfile_type;
@@ -5570,7 +5571,7 @@  objfile_type (struct objfile *objfile)
     = init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1,
 			 "__CORE_ADDR");
 
-  set_objfile_data (objfile, objfile_type_data, objfile_type);
+  objfile_type_data.set (objfile, objfile_type);
   return objfile_type;
 }
 
@@ -5578,7 +5579,6 @@  void
 _initialize_gdbtypes (void)
 {
   gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
-  objfile_type_data = register_objfile_data ();
 
   add_setshow_zuinteger_cmd ("overload", no_class, &overload_debug,
 			     _("Set debugging of C++ overloading."),