]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use std::unique_ptr in compunit_symtab
authorTom Tromey <tom@tromey.com>
Wed, 17 Sep 2025 20:31:09 +0000 (14:31 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 11 Oct 2025 19:27:36 +0000 (13:27 -0600)
Now that compunit_symtab can have a destructor, it can use
std::unique_ptr rather than an explicit 'delete'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/symtab.c
gdb/symtab.h

index 3d8583cf76f633e27c3fc569a45457b84a6fe377..e24b31c528dc9997791bce16faf754adc1f122c5 100644 (file)
@@ -428,7 +428,8 @@ void
 compunit_symtab::set_call_site_htab (call_site_htab_t &&call_site_htab)
 {
   gdb_assert (m_call_site_htab == nullptr);
-  m_call_site_htab = new call_site_htab_t (std::move (call_site_htab));
+  m_call_site_htab
+    = std::make_unique<call_site_htab_t> (std::move (call_site_htab));
 }
 
 /* See symtab.h.  */
@@ -513,7 +514,6 @@ compunit_symtab::compunit_symtab (struct objfile *objfile,
 compunit_symtab::~compunit_symtab ()
 {
   this->forget_cached_source_info ();
-  delete m_call_site_htab;
 }
 
 /* The relocated address of the minimal symbol, using the section
index 20131ffd9e6ed6c446276e65f9c6f228e28605b9..64028bf271f02bb4edcaed11cdd78bdc5b27b18b 100644 (file)
@@ -2006,7 +2006,7 @@ struct compunit_symtab : intrusive_list_node<compunit_symtab>
   unsigned int m_epilogue_unwind_valid : 1;
 
   /* struct call_site entries for this compilation unit or NULL.  */
-  call_site_htab_t *m_call_site_htab = nullptr;
+  std::unique_ptr<call_site_htab_t> m_call_site_htab;
 
   /* The macro table for this symtab.  Like the blockvector, this
      is shared between different symtabs in a given compilation unit.