[CLASSES]: Handle cases where fwd decls and definitions can happen
If a definition is being emitted and there was already a forward declaration, remove the class from the fwd_decl list before adding it to the declarations list, in the reverse case just don't add it to the fwd_decl list. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
2d7ec7cd35
commit
297d7b3f8f
|
@ -340,13 +340,16 @@ struct class *cus__find_fwd_decl(const struct cus *self, const char *name)
|
|||
static void cus__add_definition(struct cus *self, struct class *class)
|
||||
{
|
||||
class->visited = 1;
|
||||
if (!list_empty(&class->node))
|
||||
list_del(&class->node);
|
||||
list_add_tail(&class->node, &self->definitions);
|
||||
}
|
||||
|
||||
static void cus__add_fwd_decl(struct cus *self, struct class *class)
|
||||
{
|
||||
class->fwd_decl_emitted = 1;
|
||||
list_add_tail(&class->node, &self->fwd_decls);
|
||||
if (list_empty(&class->node))
|
||||
list_add_tail(&class->node, &self->fwd_decls);
|
||||
}
|
||||
|
||||
struct class *cu__find_class_by_id(const struct cu *self, const uint64_t id)
|
||||
|
@ -784,6 +787,7 @@ static struct class *class__new(const unsigned int tag,
|
|||
if (self != NULL) {
|
||||
tag__init(&self->tag, tag, id, type, decl_file, decl_line);
|
||||
INIT_LIST_HEAD(&self->members);
|
||||
INIT_LIST_HEAD(&self->node);
|
||||
self->size = size;
|
||||
self->name = strings__add(name);
|
||||
self->declaration = declaration;
|
||||
|
|
Loading…
Reference in New Issue