public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Don't use virtual destructor in addrmap
Date: Thu, 21 Mar 2024 18:29:23 +0000 (GMT)	[thread overview]
Message-ID: <20240321182923.599403858C35@sourceware.org> (raw)

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;

                 reply	other threads:[~2024-03-21 18:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240321182923.599403858C35@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).