public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Don't use virtual destructor in addrmap
@ 2024-03-21 18:29 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-03-21 18:29 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9069d69398649cd9a54e4dcac8548b10ece8a304

commit 9069d69398649cd9a54e4dcac8548b10ece8a304
Author: Tom Tromey <tromey@adacore.com>
Date:   Mon Feb 26 11:39:49 2024 -0700

    Don't use virtual destructor in addrmap
    
    The addrmap polymorphism is sort of "phony" in that there isn't really
    code in the tree that can be presented with either type.  I haven't
    tried to fix this (though perhaps I may); but meanwhile it's handy for
    the next patch if addrmap_fixed has a trivial destructor.  This patch
    achieves this by making the addrmap destructor non-virtual, and also
    making it protected so that objects of any of these types cannot be
    destroyed when only the base class is known.

Diff:
---
 gdb/addrmap.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index ba83607ad8c..0d61046cebd 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -44,8 +44,6 @@ using addrmap_foreach_const_fn
 /* The base class for addrmaps.  */
 struct addrmap
 {
-  virtual ~addrmap () = default;
-
   /* Return the object associated with ADDR in MAP.  */
   const void *find (CORE_ADDR addr) const
   { return this->do_find (addr); }
@@ -68,6 +66,9 @@ struct addrmap
   { return this->do_foreach (fn); }
 
 
+protected:
+  ~addrmap () = default;
+
 private:
   /* Worker for find, implemented by sub-classes.  */
   virtual void *do_find (CORE_ADDR addr) const = 0;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-21 18:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 18:29 [binutils-gdb] Don't use virtual destructor in addrmap Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).