From: Tom Tromey Date: Fri, 1 Nov 2019 22:06:37 +0000 (-0600) Subject: Make the objfile constructor private X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bda13cdcf0db4d9cee648bfa0bfc7f1a4415d2a7;p=binutils-gdb.git Make the objfile constructor private This changes the objfile constructor to be private, changing the callers to use a factory method. This isn't perhaps strictly needed for the goal of this series -- changing the container model of objfiles -- but is a nice symmetry. gdb/ChangeLog 2019-12-12 Tom Tromey * symfile.c (symbol_file_add_with_addrs): Use objfile::make. * objfiles.h (struct objfile): Make constructor private. : New static method. * jit.c (jit_object_close_impl): Update. Change-Id: I42e07bc80a88cf3322ace94ffe869ae5788bcb29 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 165ffda2510..393d43ef316 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-12-12 Tom Tromey + + * symfile.c (symbol_file_add_with_addrs): Use objfile::make. + * objfiles.h (struct objfile): Make constructor private. + : New static method. + * jit.c (jit_object_close_impl): Update. + 2019-12-12 Simon Marchi * jit.c (jit_reader_try_read_symtab): Replace xmalloc/xfree with diff --git a/gdb/jit.c b/gdb/jit.c index b6e51e4f8b4..2018e2c6f0d 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -786,8 +786,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb, priv_data = (jit_dbg_reader_data *) cb->priv_data; - objfile = new struct objfile (NULL, "<< JIT compiled code >>", - OBJF_NOT_FILENAME); + objfile = objfile::make (nullptr, "<< JIT compiled code >>", + OBJF_NOT_FILENAME); objfile->per_bfd->gdbarch = target_gdbarch (); j = NULL; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 1601cfe591f..b5c04eb7cb9 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -394,7 +394,19 @@ private: struct objfile { +private: + + /* The only way to create an objfile is to call objfile::make. */ objfile (bfd *, const char *, objfile_flags); + +public: + + /* Create an objfile. */ + static objfile *make (bfd *bfd_, const char *name_, objfile_flags flags_) + { + return new objfile (bfd_, name_, flags_); + } + ~objfile (); DISABLE_COPY_AND_ASSIGN (objfile); diff --git a/gdb/symfile.c b/gdb/symfile.c index aec07d7a7ab..eef27a8418e 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1093,7 +1093,7 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, if (mainline) flags |= OBJF_MAINLINE; - objfile = new struct objfile (abfd, name, flags); + objfile = objfile::make (abfd, name, flags); if (parent) add_separate_debug_objfile (objfile, parent);