diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-01-27 14:46:50 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-01-30 10:22:42 -0500 |
commit | 5867ab870b8aa36ae490ec6e4e8e4c55be11ccf1 (patch) | |
tree | c5049320fa15c17055ef6bf20935118170545080 /gdb/dwarf2/index-write.c | |
parent | 8d31d08fe61059fb94c02ae30c2b7cd0ea738df0 (diff) | |
download | binutils-5867ab870b8aa36ae490ec6e4e8e4c55be11ccf1.zip binutils-5867ab870b8aa36ae490ec6e4e8e4c55be11ccf1.tar.gz binutils-5867ab870b8aa36ae490ec6e4e8e4c55be11ccf1.tar.bz2 |
gdb: provide const-correct versions of addrmap::find and addrmap::foreach
Users of addrmap::find and addrmap::foreach that have a const addrmap
should ideally receive const pointers to objects, to indicate they
should not be modified. However, users that have a non-const addrmap
should still receive a non-const pointer.
To achieve this, without adding more virtual methods, make the existing
find and foreach virtual methods private and prefix them with "do_".
Add small non-const and const wrappers for find and foreach.
Obviously, the const can be cast away, but if using static_cast
instead of C-style casts, then the compiler won't let you cast
the const away. I changed all the callers of addrmap::find and
addrmap::foreach I could find to make them use static_cast.
Change-Id: Ia8e69d022564f80d961413658fe6068edc71a094
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r-- | gdb/dwarf2/index-write.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index ced58ea..7b1b2d6 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -474,7 +474,7 @@ add_address_entry (data_buf &addr_vec, int addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) { - dwarf2_per_cu_data *per_cu = (dwarf2_per_cu_data *) obj; + dwarf2_per_cu_data *per_cu = static_cast<dwarf2_per_cu_data *> (obj); if (previous_valid) add_address_entry (addr_vec, |