aboutsummaryrefslogtreecommitdiff
path: root/gdb/addrmap.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-01-14 11:51:38 -0700
committerTom Tromey <tom@tromey.com>2024-04-16 11:54:46 -0600
commit79ddf4a51a789c823d024409aec8712595701a23 (patch)
tree4ec64ad9589fa4173a79dea01496249f30875915 /gdb/addrmap.h
parent4e417d7bb1c7d8b8a73b73b0b7c051f0a6e1b6b6 (diff)
downloadbinutils-79ddf4a51a789c823d024409aec8712595701a23.zip
binutils-79ddf4a51a789c823d024409aec8712595701a23.tar.gz
binutils-79ddf4a51a789c823d024409aec8712595701a23.tar.bz2
Add move operators for addrmap
A subsequent patch needs to move an addrmap. This patch adds the necessary support. It also changes addrmap_fixed to take a 'const' addrmap_mutable. This is fine according to the contract of addrmap_mutable; but it did require a compensating const_cast in the implementation.
Diffstat (limited to 'gdb/addrmap.h')
-rw-r--r--gdb/addrmap.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index ed52e3c..5378b75 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -85,9 +85,14 @@ struct addrmap_fixed final : public addrmap,
{
public:
- addrmap_fixed (struct obstack *obstack, addrmap_mutable *mut);
+ addrmap_fixed (struct obstack *obstack, const addrmap_mutable *mut);
DISABLE_COPY_AND_ASSIGN (addrmap_fixed);
+ /* It's fine to use the default move operators, because this addrmap
+ does not own the storage for the elements. */
+ addrmap_fixed (addrmap_fixed &&other) = default;
+ addrmap_fixed &operator= (addrmap_fixed &&) = default;
+
void relocate (CORE_ADDR offset) override;
private:
@@ -124,6 +129,18 @@ public:
~addrmap_mutable ();
DISABLE_COPY_AND_ASSIGN (addrmap_mutable);
+ addrmap_mutable (addrmap_mutable &&other)
+ : tree (other.tree)
+ {
+ other.tree = nullptr;
+ }
+
+ addrmap_mutable &operator= (addrmap_mutable &&other)
+ {
+ std::swap (tree, other.tree);
+ return *this;
+ }
+
/* In the mutable address map MAP, associate the addresses from START
to END_INCLUSIVE that are currently associated with NULL with OBJ
instead. Addresses mapped to an object other than NULL are left