emit: Check if disambiguated struct/enum/union name was already emitted in a previous CU
When generating from DWARF we may find the same ambiguous
enum/struct/union name ('struct foo' and 'union foo' on the same .c file), in multiple CUs,
so we need to check again when disambiguating by adding a __N suffix.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/dwarves_emit.c b/dwarves_emit.c
index 910afb9..304d587 100644
--- a/dwarves_emit.c
+++ b/dwarves_emit.c
@@ -357,6 +357,12 @@
} else {
// Will be deleted in type__delete() on noticing ctype->suffix_disambiguation != 0
tag__namespace(tag)->name = disambiguated_name;
+
+ // Now look again if it was emitted in a previous CU with the disambiguated name
+ if (type_emissions__find_definition(emissions, tag->tag, type__name(ctype)) != NULL) {
+ ctype->definition_emitted = 1;
+ return 0;
+ }
}
}