dwarves: Move the common initialization of fields for 'struct type'

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2020-07-27 09:42:05 -03:00
parent aa7ab3e875
commit dd3c0e9eb0
5 changed files with 13 additions and 12 deletions

View File

@ -122,12 +122,9 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs,
static void type__init(struct type *type, uint32_t tag,
strings_t name, size_t size)
{
INIT_LIST_HEAD(&type->node);
__type__init(type);
INIT_LIST_HEAD(&type->namespace.tags);
type->size = size;
type->sizeof_member = NULL;
type->member_prefix = NULL;
type->member_prefix_len = 0;
type->namespace.tag.tag = tag;
type->namespace.name = name;
type->namespace.sname = 0;

View File

@ -170,15 +170,12 @@ static struct base_type *base_type__new(strings_t name, uint32_t attrs,
static void type__init(struct type *type, uint16_t tag,
strings_t name, size_t size)
{
INIT_LIST_HEAD(&type->node);
__type__init(type);
INIT_LIST_HEAD(&type->namespace.tags);
type->size = size;
type->namespace.tag.tag = tag;
type->namespace.name = name;
type->namespace.sname = 0;
type->sizeof_member = NULL;
type->member_prefix = NULL;
type->member_prefix_len = 0;
}
static struct type *type__new(uint16_t tag, strings_t name, size_t size)

View File

@ -496,7 +496,7 @@ static struct namespace *namespace__new(Dwarf_Die *die, struct cu *cu)
static void type__init(struct type *type, Dwarf_Die *die, struct cu *cu)
{
namespace__init(&type->namespace, die, cu);
INIT_LIST_HEAD(&type->node);
__type__init(type);
type->size = attr_numeric(die, DW_AT_byte_size);
type->alignment = attr_numeric(die, DW_AT_alignment);
type->declaration = attr_numeric(die, DW_AT_declaration);
@ -507,9 +507,6 @@ static void type__init(struct type *type, Dwarf_Die *die, struct cu *cu)
type->resized = 0;
type->nr_members = 0;
type->nr_static_members = 0;
type->sizeof_member = NULL;
type->member_prefix = NULL;
type->member_prefix_len = 0;
}
static struct type *type__new(Dwarf_Die *die, struct cu *cu)

View File

@ -324,6 +324,14 @@ void namespace__delete(struct namespace *space, struct cu *cu)
tag__delete(&space->tag, cu);
}
void __type__init(struct type *type)
{
INIT_LIST_HEAD(&type->node);
type->sizeof_member = NULL;
type->member_prefix = NULL;
type->member_prefix_len = 0;
}
struct class_member *
type__find_first_biggest_size_base_type_member(struct type *type,
const struct cu *cu)

View File

@ -970,6 +970,8 @@ struct type {
uint8_t resized:1;
};
void __type__init(struct type *type);
static inline struct class *type__class(const struct type *type)
{
return (struct class *)type;