From: Simon Marchi Date: Sun, 8 Feb 2026 22:04:10 +0000 (-0500) Subject: gdb/registry: make registry::key::emplace return a reference X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea71a4081d98075998e297a6d95683f837889720;p=thirdparty%2Fbinutils-gdb.git gdb/registry: make registry::key::emplace return a reference Since we use C++ and not C, I think that we should gradually move to using references for things that can never be nullptr. One example of this is the return value of the emplace method. Change it to return a reference, and (to keep the patch straightforward) update all callers to take the address. More patches could follow to propagate the use of references further. Change-Id: I725539694cf496f8288918cc29d7aaae9aca2292 Approved-By: Tom Tromey --- diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 4c89776777f..eaac2816880 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -311,7 +311,7 @@ get_ada_inferior_data (struct inferior *inf) data = ada_inferior_data.get (inf); if (data == NULL) - data = ada_inferior_data.emplace (inf); + data = &ada_inferior_data.emplace (inf); return data; } @@ -399,7 +399,7 @@ get_ada_pspace_data (struct program_space *pspace) { cache_entry_set *data = ada_pspace_data_handle.get (pspace); if (data == nullptr) - data = ada_pspace_data_handle.emplace (pspace); + data = &ada_pspace_data_handle.emplace (pspace); return *data; } diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 798d9c4cb32..22ba47c262d 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -300,7 +300,7 @@ get_ada_tasks_pspace_data (struct program_space *pspace) data = ada_tasks_pspace_data_handle.get (pspace); if (data == NULL) - data = ada_tasks_pspace_data_handle.emplace (pspace); + data = &ada_tasks_pspace_data_handle.emplace (pspace); return data; } @@ -324,7 +324,7 @@ get_ada_tasks_inferior_data (struct inferior *inf) data = ada_tasks_inferior_data_handle.get (inf); if (data == NULL) - data = ada_tasks_inferior_data_handle.emplace (inf); + data = &ada_tasks_inferior_data_handle.emplace (inf); return data; } diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 196942f064c..120b032fcf4 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -209,7 +209,7 @@ get_aix_thread_variables_data (struct inferior *inf) data = aix_thread_variables_handle.get (inf); if (data == NULL) - data = aix_thread_variables_handle.emplace (inf); + data = &aix_thread_variables_handle.emplace (inf); return data; } diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index 4e52683dc55..d636f1a39ed 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -372,7 +372,7 @@ get_amd_dbgapi_inferior_info (inferior *inferior) amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (inferior); if (info == nullptr) - info = amd_dbgapi_inferior_data.emplace (inferior, inferior); + info = &amd_dbgapi_inferior_data.emplace (inferior, inferior); return *info; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index e4c8b78de03..7d6aa06f233 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -2571,7 +2571,7 @@ arm_exidx_new_objfile (struct objfile *objfile) } /* Allocate exception table data structure. */ - data = arm_exidx_data_key.emplace (objfile->obfd.get ()); + data = &arm_exidx_data_key.emplace (objfile->obfd.get ()); data->section_maps.resize (objfile->obfd->section_count); /* Fill in exception table. */ @@ -9745,8 +9745,8 @@ arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, data = arm_bfd_data_key.get (objfile->obfd.get ()); if (data == NULL) - data = arm_bfd_data_key.emplace (objfile->obfd.get (), - objfile->obfd->section_count); + data = &arm_bfd_data_key.emplace (objfile->obfd.get (), + objfile->obfd->section_count); arm_mapping_symbol_vec &map = data->section_maps[bfd_asymbol_section (sym)->index]; diff --git a/gdb/auto-load.c b/gdb/auto-load.c index ca9799c3682..b7e62626ab7 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -612,7 +612,7 @@ get_auto_load_pspace_data (struct program_space *pspace) info = auto_load_pspace_data.get (pspace); if (info == NULL) - info = auto_load_pspace_data.emplace (pspace); + info = &auto_load_pspace_data.emplace (pspace); return info; } diff --git a/gdb/auxv.c b/gdb/auxv.c index 59f38d3cf49..1a58fd8c844 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -365,7 +365,7 @@ target_read_auxv () if (info == nullptr) { - info = auxv_inferior_data.emplace (inf); + info = &auxv_inferior_data.emplace (inf); info->data = target_read_auxv_raw (inf->top_target ()); } diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 0cf594e6fdc..43f12862052 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -86,7 +86,7 @@ get_catch_syscall_inferior_data (struct inferior *inf) inf_data = catch_syscall_inferior_data.get (inf); if (inf_data == NULL) - inf_data = catch_syscall_inferior_data.emplace (inf); + inf_data = &catch_syscall_inferior_data.emplace (inf); return inf_data; } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f8fa7bcb142..82514384d98 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3657,7 +3657,7 @@ get_breakpoint_objfile_data (struct objfile *objfile) bp_objfile_data = breakpoint_objfile_key.get (objfile); if (bp_objfile_data == NULL) - bp_objfile_data = breakpoint_objfile_key.emplace (objfile); + bp_objfile_data = &breakpoint_objfile_key.emplace (objfile); return bp_objfile_data; } diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 2da1197ef8b..9d91893c6cf 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -86,7 +86,7 @@ get_bsd_uthread (struct gdbarch *gdbarch) { struct bsd_uthread_ops *ops = bsd_uthread_data.get (gdbarch); if (ops == nullptr) - ops = bsd_uthread_data.emplace (gdbarch); + ops = &bsd_uthread_data.emplace (gdbarch); return ops; } diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index b0eac5c6bf4..a5026e133c9 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -711,7 +711,7 @@ dwarf_expr_context::address_type () const gdbarch *arch = this->m_per_objfile->objfile->arch (); dwarf_gdbarch_types *types = dwarf_arch_cookie.get (arch); if (types == nullptr) - types = dwarf_arch_cookie.emplace (arch); + types = &dwarf_arch_cookie.emplace (arch); int ndx; if (this->m_addr_size == 2) diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index b6d5aac8a76..a4dada8a789 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -610,7 +610,7 @@ get_frame_ops (struct gdbarch *gdbarch) { dwarf2_frame_ops *result = dwarf2_frame_data.get (gdbarch); if (result == nullptr) - result = dwarf2_frame_data.emplace (gdbarch); + result = &dwarf2_frame_data.emplace (gdbarch); return result; } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7a977a97a46..6061df0ecb8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1213,7 +1213,8 @@ dwarf2_has_info (struct objfile *objfile, just_created = true; } - per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd); + per_objfile + = &dwarf2_objfile_data_key.emplace (objfile, objfile, per_bfd); } /* Virtual sections are created from DWP files. It's not clear those diff --git a/gdb/elfread.c b/gdb/elfread.c index 60785ace56d..722f21bf775 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1295,7 +1295,7 @@ elf_get_probes (struct objfile *objfile) if (probes_per_bfd == NULL) { - probes_per_bfd = probe_key.emplace (objfile->obfd.get ()); + probes_per_bfd = &probe_key.emplace (objfile->obfd.get ()); /* Here we try to gather information about all types of probes from the objfile. */ diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index ae11e2e85ee..2ddba1660de 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -498,7 +498,7 @@ get_fbsd_gdbarch_data (struct gdbarch *gdbarch) { struct fbsd_gdbarch_data *result = fbsd_gdbarch_data_handle.get (gdbarch); if (result == nullptr) - result = fbsd_gdbarch_data_handle.emplace (gdbarch); + result = &fbsd_gdbarch_data_handle.emplace (gdbarch); return result; } @@ -528,7 +528,7 @@ get_fbsd_pspace_data (struct program_space *pspace) data = fbsd_pspace_data_handle.get (pspace); if (data == NULL) - data = fbsd_pspace_data_handle.emplace (pspace); + data = &fbsd_pspace_data_handle.emplace (pspace); return data; } diff --git a/gdb/frame-base.c b/gdb/frame-base.c index 905c15e5047..a732e1efc9a 100644 --- a/gdb/frame-base.c +++ b/gdb/frame-base.c @@ -72,7 +72,7 @@ get_frame_base_table (struct gdbarch *gdbarch) { struct frame_base_table *table = frame_base_data.get (gdbarch); if (table == nullptr) - table = frame_base_data.emplace (gdbarch); + table = &frame_base_data.emplace (gdbarch); return table; } diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 16d1fb1d62e..49ade0043a1 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -76,9 +76,9 @@ get_frame_unwind_table (struct gdbarch *gdbarch) { std::vector *table = frame_unwind_data.get (gdbarch); if (table == nullptr) - table = frame_unwind_data.emplace (gdbarch, - standard_unwinders.begin (), - standard_unwinders.end ()); + table = &frame_unwind_data.emplace (gdbarch, + standard_unwinders.begin (), + standard_unwinders.end ()); return *table; } diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 7f4c302b759..cbf8e705479 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -1258,7 +1258,7 @@ get_bfd_inferior_data (struct inferior *inf) data = bfd_inferior_data_key.get (inf); if (data == nullptr) - data = bfd_inferior_data_key.emplace (inf); + data = &bfd_inferior_data_key.emplace (inf); return data; } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f0729bece59..2b6244d6f38 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5574,7 +5574,7 @@ allocate_fixed_point_type_info (struct type *type) fixed_point_type_storage *storage = fixed_point_objfile_key.get (type->objfile_owner ()); if (storage == nullptr) - storage = fixed_point_objfile_key.emplace (type->objfile_owner ()); + storage = &fixed_point_objfile_key.emplace (type->objfile_owner ()); info = up.get (); storage->push_back (std::move (up)); } diff --git a/gdb/guile/scm-arch.c b/gdb/guile/scm-arch.c index db99be81de4..1bd010c023e 100644 --- a/gdb/guile/scm-arch.c +++ b/gdb/guile/scm-arch.c @@ -124,7 +124,7 @@ arscm_scm_from_arch (struct gdbarch *gdbarch) is no call to scm_gc_unprotect_object for it. */ scm_gc_protect_object (arch_scm); - data = arch_object_data.emplace (gdbarch); + data = &arch_object_data.emplace (gdbarch); data->arch_scm = arch_scm; } diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c index f128a45dafd..e70afa820f2 100644 --- a/gdb/guile/scm-symbol.c +++ b/gdb/guile/scm-symbol.c @@ -136,7 +136,7 @@ syscm_get_symbol_map (struct symbol *symbol) struct syscm_gdbarch_data *data = syscm_gdbarch_data_key.get (gdbarch); if (data == nullptr) { - data = syscm_gdbarch_data_key.emplace (gdbarch); + data = &syscm_gdbarch_data_key.emplace (gdbarch); data->htab = gdbscm_create_eqable_gsmob_ptr_map (syscm_hash_symbol_smob, syscm_eq_symbol_smob); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index ae5f5328484..7cd6f2c11b6 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -463,7 +463,7 @@ read_unwind_info (struct objfile *objfile) /* Keep a pointer to the unwind information. */ obj_private = hppa_objfile_priv_data.get (objfile); if (obj_private == NULL) - obj_private = hppa_objfile_priv_data.emplace (objfile); + obj_private = &hppa_objfile_priv_data.emplace (objfile); obj_private->unwind_info = ui; } diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c index 06a9752e443..41c07160cb9 100644 --- a/gdb/ia64-libunwind-tdep.c +++ b/gdb/ia64-libunwind-tdep.c @@ -128,7 +128,7 @@ libunwind_descr (struct gdbarch *gdbarch) { struct libunwind_descr *result = libunwind_descr_handle.get (gdbarch); if (result == nullptr) - result = libunwind_descr_handle.emplace (gdbarch); + result = &libunwind_descr_handle.emplace (gdbarch); return result; } diff --git a/gdb/inflow.c b/gdb/inflow.c index 4c6c70dfee9..d8271f9caa8 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -643,7 +643,7 @@ get_inflow_inferior_data (struct inferior *inf) info = inflow_inferior_data.get (inf); if (info == NULL) - info = inflow_inferior_data.emplace (inf); + info = &inflow_inferior_data.emplace (inf); return info; } diff --git a/gdb/jit.c b/gdb/jit.c index 4add2fa4861..db9d18f1507 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -1153,7 +1153,7 @@ jit_prepend_unwinder (struct gdbarch *gdbarch) { struct jit_gdbarch_data_type *data = jit_gdbarch_data.get (gdbarch); if (data == nullptr) - data = jit_gdbarch_data.emplace (gdbarch); + data = &jit_gdbarch_data.emplace (gdbarch); if (!data->unwinder_registered) { diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index b6429ebb3a1..59d3eea6069 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -117,7 +117,7 @@ get_checkpoint_inferior_data (struct inferior *inf) data = checkpoint_inferior_data_key.get (inf); if (data == nullptr) - data = checkpoint_inferior_data_key.emplace (inf); + data = &checkpoint_inferior_data_key.emplace (inf); return data; } diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index ccc7fa7cf9d..9ce28d53283 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -212,7 +212,7 @@ get_linux_gdbarch_data (struct gdbarch *gdbarch) { struct linux_gdbarch_data *result = linux_gdbarch_data_handle.get (gdbarch); if (result == nullptr) - result = linux_gdbarch_data_handle.emplace (gdbarch); + result = &linux_gdbarch_data_handle.emplace (gdbarch); return result; } @@ -266,7 +266,7 @@ get_linux_inferior_data (inferior *inf) linux_info *info = linux_inferior_data.get (inf); if (info == nullptr) - info = linux_inferior_data.emplace (inf); + info = &linux_inferior_data.emplace (inf); return info; } diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c index 8ad15de0875..1d97a7a8b9a 100644 --- a/gdb/netbsd-tdep.c +++ b/gdb/netbsd-tdep.c @@ -369,7 +369,7 @@ get_nbsd_gdbarch_data (struct gdbarch *gdbarch) { struct nbsd_gdbarch_data *result = nbsd_gdbarch_data_handle.get (gdbarch); if (result == nullptr) - result = nbsd_gdbarch_data_handle.emplace (gdbarch); + result = &nbsd_gdbarch_data_handle.emplace (gdbarch); return result; } diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 9d543005370..f14d7f16d37 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -1085,7 +1085,7 @@ find_methods (char type, const char *theclass, const char *category, } if (objc_csym == NULL) - objc_csym = objc_objfile_data.emplace (&objfile, objfile_csym); + objc_csym = &objc_objfile_data.emplace (&objfile, objfile_csym); else /* Count of ObjC methods in this objfile should be constant. */ gdb_assert (*objc_csym == objfile_csym); diff --git a/gdb/objfiles.c b/gdb/objfiles.c index db96a1761f8..e33368ba19d 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -92,7 +92,7 @@ get_objfile_pspace_data (struct program_space *pspace) info = objfiles_pspace_data.get (pspace); if (info == NULL) - info = objfiles_pspace_data.emplace (pspace); + info = &objfiles_pspace_data.emplace (pspace); return info; } diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c index 0ec708364dd..b345229ea61 100644 --- a/gdb/python/py-registers.c +++ b/gdb/python/py-registers.c @@ -143,7 +143,7 @@ gdbpy_get_register_descriptor (struct gdbarch *gdbarch, { gdbpy_register_type *vecp = gdbpy_register_object_data.get (gdbarch); if (vecp == nullptr) - vecp = gdbpy_register_object_data.emplace (gdbarch); + vecp = &gdbpy_register_object_data.emplace (gdbarch); gdbpy_register_type &vec = *vecp; /* Ensure that we have enough entries in the vector. */ diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 7c0779a8270..c2579f3c35a 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -996,7 +996,7 @@ pyuw_on_new_gdbarch (gdbarch *newarch) { struct pyuw_gdbarch_data_type *data = pyuw_gdbarch_data.get (newarch); if (data == nullptr) - data= pyuw_gdbarch_data.emplace (newarch); + data = &pyuw_gdbarch_data.emplace (newarch); if (!data->unwinder_registered) { diff --git a/gdb/reggroups.c b/gdb/reggroups.c index ad22e4c17d4..2bc8e52cb2e 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -113,7 +113,7 @@ get_reggroups (struct gdbarch *gdbarch) { struct reggroups *groups = reggroups_data.get (gdbarch); if (groups == nullptr) - groups = reggroups_data.emplace (gdbarch); + groups = ®groups_data.emplace (gdbarch); return groups; } diff --git a/gdb/registry.h b/gdb/registry.h index c1aaadce512..3738d4226bb 100644 --- a/gdb/registry.h +++ b/gdb/registry.h @@ -124,7 +124,7 @@ public: available. It emplaces a new instance of the associated data type and attaches it to OBJ using this key. The arguments, if any, are forwarded to the constructor. */ - template + template typename std::enable_if>::value, Dummy>::type @@ -132,7 +132,7 @@ public: { DATA *result = new DATA (std::forward (args)...); set (obj, result); - return result; + return *result; } /* Clear the data attached to OBJ that is associated with this KEY. diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index ee2a1b37370..95ee9841fe0 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -247,7 +247,7 @@ _("Inferior %d and inferior %d would have identical simulator state.\n" if (sim_data == NULL) { - sim_data = sim_inferior_data_key.emplace (inf, sim_desc); + sim_data = &sim_inferior_data_key.emplace (inf, sim_desc); } else if (sim_desc) { diff --git a/gdb/remote.c b/gdb/remote.c index 1358e1c06b9..8bdc4951035 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1729,7 +1729,7 @@ get_remote_progspace_info (program_space *pspace) { remote_per_progspace *info = remote_pspace_data.get (pspace); if (info == nullptr) - info = remote_pspace_data.emplace (pspace); + info = &remote_pspace_data.emplace (pspace); gdb_assert (info != nullptr); return *info; } @@ -13101,7 +13101,7 @@ get_g_packet_data (struct gdbarch *gdbarch) struct remote_g_packet_data *data = remote_g_packet_data_handle.get (gdbarch); if (data == nullptr) - data = remote_g_packet_data_handle.emplace (gdbarch); + data = &remote_g_packet_data_handle.emplace (gdbarch); return data; } diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 1dd8e708009..6c403f9685d 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -165,7 +165,7 @@ get_ppc_per_inferior (inferior *inf) ppc_inferior_data *per_inf = ppc_inferior_data_key.get (inf); if (per_inf == nullptr) - per_inf = ppc_inferior_data_key.emplace (inf); + per_inf = &ppc_inferior_data_key.emplace (inf); return per_inf; } diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index 3c452e0d805..8f210312342 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -100,7 +100,7 @@ get_solib_aix_inferior_data (struct inferior *inf) data = solib_aix_inferior_data_handle.get (inf); if (data == NULL) - data = solib_aix_inferior_data_handle.emplace (inf); + data = &solib_aix_inferior_data_handle.emplace (inf); return data; } diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index c23b8e6eb97..0a6e023128e 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -106,7 +106,7 @@ get_darwin_info (program_space *pspace) if (info != nullptr) return info; - return solib_darwin_pspace_data.emplace (pspace); + return &solib_darwin_pspace_data.emplace (pspace); } /* Return non-zero if the version in dyld_all_image is known. */ diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 17c8e565ee1..aed7e4ea28e 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -202,7 +202,7 @@ get_dsbt_info (program_space *pspace) if (info != nullptr) return info; - return solib_dsbt_pspace_data.emplace (pspace); + return &solib_dsbt_pspace_data.emplace (pspace); } diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index ced7c644999..2ffccb69be2 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -235,7 +235,7 @@ get_solib_info (inferior *inf) solib_info *info = rocm_solib_data.get (inf); if (info == nullptr) - info = rocm_solib_data.emplace (inf, inf); + info = &rocm_solib_data.emplace (inf, inf); return info; } diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 8beb545fd9a..49b005beb1a 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -471,7 +471,7 @@ get_svr4_info (program_space *pspace) struct svr4_info *info = solib_svr4_pspace_data.get (pspace); if (info == NULL) - info = solib_svr4_pspace_data.emplace (pspace); + info = &solib_svr4_pspace_data.emplace (pspace); return info; } diff --git a/gdb/source.c b/gdb/source.c index ade1bb2789f..825f09f5947 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -226,7 +226,7 @@ get_source_location (program_space *pspace) current_source_location *loc = current_source_key.get (pspace); if (loc == nullptr) - loc = current_source_key.emplace (pspace); + loc = ¤t_source_key.emplace (pspace); return loc; } diff --git a/gdb/svr4-tls-tdep.c b/gdb/svr4-tls-tdep.c index eac0357abd5..163985918a6 100644 --- a/gdb/svr4-tls-tdep.c +++ b/gdb/svr4-tls-tdep.c @@ -44,7 +44,7 @@ get_svr4_tls_gdbarch_data (struct gdbarch *gdbarch) { struct svr4_tls_gdbarch_data *result = svr4_tls_gdbarch_data_handle.get (gdbarch); if (result == nullptr) - result = svr4_tls_gdbarch_data_handle.emplace (gdbarch); + result = &svr4_tls_gdbarch_data_handle.emplace (gdbarch); return result; } diff --git a/gdb/symtab.c b/gdb/symtab.c index 35e380980b5..37a9fe62f40 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1318,7 +1318,7 @@ get_symbol_cache (struct program_space *pspace) if (cache == NULL) { - cache = symbol_cache_key.emplace (pspace); + cache = &symbol_cache_key.emplace (pspace); resize_symbol_cache (cache, symbol_cache_size); } @@ -6290,7 +6290,7 @@ get_main_info (program_space *pspace) gdb returned "main" as the name even if no function named "main" was defined the program; and this approach lets us keep compatibility. */ - info = main_progspace_key.emplace (pspace); + info = &main_progspace_key.emplace (pspace); } return info; diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 0096263547a..1c4bbe297c0 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -445,7 +445,7 @@ get_arch_data (struct gdbarch *gdbarch) { tdesc_arch_data *result = tdesc_data.get (gdbarch); if (result == nullptr) - result = tdesc_data.emplace (gdbarch); + result = &tdesc_data.emplace (gdbarch); return result; } diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index ad4c35ff8c6..6a8f26bf3e6 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -192,7 +192,7 @@ get_windows_gdbarch_data (struct gdbarch *gdbarch) { windows_gdbarch_data *result = windows_gdbarch_data_handle.get (gdbarch); if (result == nullptr) - result = windows_gdbarch_data_handle.emplace (gdbarch); + result = &windows_gdbarch_data_handle.emplace (gdbarch); return result; }