[PATCH 4/7] Class-fy partial_die_info
Pedro Alves
palves@redhat.com
Tue Jan 30 15:11:00 GMT 2018
On 01/30/2018 10:49 AM, Yao Qi wrote:
> Simon Marchi <simark@simark.ca> writes:
>> - /* Hash table holding all the loaded partial DIEs
>> - with partial_die->offset.SECT_OFF as hash. */
>> - htab_t partial_dies = nullptr;
>> + /* Hash map holding all the loaded partial DIEs
>> + with their section offset as the key. */
>> + std::unordered_map<sect_offset, partial_die_info *> partial_dies;
>>
> This doesn't compile with my g++ 4.9, as library doesn't provide
> std::hash<T> specialization for enumeration types. It is available
> since C++ 14. http://en.cppreference.com/w/cpp/utility/hash
>
> I can change it to
>
> std::unordered_map<std::underlying_type<sect_offset>::type,
> partial_die_info *> partial_dies;
>
> to fix the compiler errors.
Note: in cases like these, we don't need to forgo using the
(strong) enum as key type. unordered_map's third (defaulted) template
parameter type is the hasher to use. And we have a convenience
hasher for this:
[pushed] Add gdb::hash_enum
https://sourceware.org/ml/gdb-patches/2017-12/msg00210.html
Currently used in dwarf2read.c:
std::unordered_map<sect_offset,
dwarf2_per_cu_data *,
gdb::hash_enum<sect_offset>>
Thanks,
Pedro Alves
More information about the Gdb-patches
mailing list