From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/3] Don't use virtual destructor in addrmap
Date: Tue, 27 Feb 2024 14:42:18 -0700 [thread overview]
Message-ID: <20240227-obstac-alloc-v1-2-bd079aad35cd@adacore.com> (raw)
In-Reply-To: <20240227-obstac-alloc-v1-0-bd079aad35cd@adacore.com>
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.
---
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;
--
2.43.0
next prev parent reply other threads:[~2024-02-27 21:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 21:42 [PATCH 0/3] Make allocate_on_obstack a bit safer Tom Tromey
2024-02-27 21:42 ` [PATCH 1/3] Use addrmap_fixed in a few spots Tom Tromey
2024-02-28 12:27 ` Alexandra Petlanova Hajkova
2024-02-27 21:42 ` Tom Tromey [this message]
2024-02-28 15:16 ` [PATCH 2/3] Don't use virtual destructor in addrmap Alexandra Petlanova Hajkova
2024-02-27 21:42 ` [PATCH 3/3] Require trivial destructor in allocate_on_obstack Tom Tromey
2024-02-28 16:55 ` Alexandra Petlanova Hajkova
2024-03-21 18:20 ` [PATCH 0/3] Make allocate_on_obstack a bit safer Tom Tromey
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=20240227-obstac-alloc-v1-2-bd079aad35cd@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@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).