/* Fixed address maps. */
struct addrmap_fixed : public addrmap,
- public allocate_on_obstack
+ public allocate_on_obstack<addrmap_fixed>
{
public:
C++ files, namely using declarations and the current namespace in
scope. */
-struct block_namespace_info : public allocate_on_obstack
+struct block_namespace_info : public allocate_on_obstack<block_namespace_info>
{
const char *scope = nullptr;
struct using_direct *using_decl = nullptr;
This implies that within the body of one function
the blocks appear in the order of a depth-first tree walk. */
-struct block : public allocate_on_obstack
+struct block : public allocate_on_obstack<block>
{
/* Return this block's start address. */
CORE_ADDR start () const
This is an "open" class and the members are all directly
accessible. It is read-only after the index has been fully read
and processed. */
-struct cooked_index_entry : public allocate_on_obstack
+struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
{
cooked_index_entry (sect_offset die_offset_, enum dwarf_tag tag_,
cooked_index_flag flags_,
control other variant parts as well. This struct corresponds to
DW_TAG_variant in DWARF. */
-struct variant : allocate_on_obstack
+struct variant : allocate_on_obstack<variant>
{
/* * The discriminant ranges for this variant. */
gdb::array_view<discriminant_range> discriminants;
and holds an array of variants. This struct corresponds to
DW_TAG_variant_part in DWARF. */
-struct variant_part : allocate_on_obstack
+struct variant_part : allocate_on_obstack<variant_part>
{
/* * The index of the discriminant field in the outer type. This is
an index into the type's array of fields. If this is -1, there
/* This structure is space critical. See space comments at the top. */
-struct symbol : public general_symbol_info, public allocate_on_obstack
+struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
{
symbol ()
/* Class-initialization of bitfields is only allowed in C++20. */
{ obstack_free (this, obstack_base (this)); }
};
-/* Objects are allocated on obstack instead of heap. */
+/* Objects are allocated on obstack instead of heap. This is a mixin
+ that uses CRTP to ensure that the type in question is trivially
+ destructible. */
+template<typename T>
struct allocate_on_obstack
{
allocate_on_obstack () = default;
void* operator new (size_t size, struct obstack *obstack)
{
+ static_assert (IsFreeable<T>::value);
return obstack_alloc (obstack, size);
}