From: Douglas Raillard <douglas.raillard@xxxxxxx> This reverts commit 7c5e35b63bd26f1de0a22acb6319bf2b1a4166c1. Signed-off-by: Douglas Raillard <douglas.raillard@xxxxxxx> --- dwarves.h | 4 +--- dwarves_emit.c | 2 +- dwarves_fprintf.c | 52 +++++++++++++++++------------------------------ 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/dwarves.h b/dwarves.h index 2fbeac3..52d162d 100644 --- a/dwarves.h +++ b/dwarves.h @@ -105,7 +105,6 @@ struct conf_fprintf { uint8_t indent; uint8_t expand_types:1; uint8_t expand_pointers:1; - uint8_t inner_anonymous:1; uint8_t rel_offset:1; uint8_t emit_stats:1; uint8_t suppress_comments:1; @@ -1372,8 +1371,7 @@ static inline const char *enumerator__name(const struct enumerator *enumerator) void enumeration__delete(struct type *type); void enumeration__add(struct type *type, struct enumerator *enumerator); size_t enumeration__fprintf(const struct tag *tag_enum, - const struct conf_fprintf *conf, FILE *fp, - bool anonymous); + const struct conf_fprintf *conf, FILE *fp); int dwarves__init(void); void dwarves__exit(void); diff --git a/dwarves_emit.c b/dwarves_emit.c index 5c67559..5bf7946 100644 --- a/dwarves_emit.c +++ b/dwarves_emit.c @@ -91,7 +91,7 @@ static int enumeration__emit_definitions(struct tag *tag, return 0; } - enumeration__fprintf(tag, conf, fp, false); + enumeration__fprintf(tag, conf, fp); fputs(";\n", fp); type_emissions__add_definition(emissions, etype); return 1; diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index ecb6c7f..c5921d7 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -198,8 +198,7 @@ size_t tag__fprintf_decl_info(const struct tag *tag, } static size_t __class__fprintf(struct class *class, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp, - bool anonymous); + const struct conf_fprintf *conf, FILE *fp); static size_t type__fprintf(struct tag *type, const struct cu *cu, const char *name, const struct conf_fprintf *conf, FILE *fp); @@ -331,7 +330,7 @@ size_t typedef__fprintf(const struct tag *tag, const struct cu *cu, struct conf_fprintf tconf = *pconf; tconf.suffix = type__name(type); - return fprintf(fp, "typedef ") + __class__fprintf(tag__class(tag_type), cu, &tconf, fp, false); + return fprintf(fp, "typedef ") + __class__fprintf(tag__class(tag_type), cu, &tconf, fp); } case DW_TAG_enumeration_type: { struct type *ctype = tag__type(tag_type); @@ -342,7 +341,7 @@ size_t typedef__fprintf(const struct tag *tag, const struct cu *cu, struct conf_fprintf tconf = *pconf; tconf.suffix = type__name(type); - return fprintf(fp, "typedef ") + enumeration__fprintf(tag_type, &tconf, fp, false); + return fprintf(fp, "typedef ") + enumeration__fprintf(tag_type, &tconf, fp); } } @@ -395,16 +394,12 @@ out: return type->max_tag_name_len; } -size_t enumeration__fprintf(const struct tag *tag, const struct conf_fprintf *conf, FILE *fp, bool anonymous) +size_t enumeration__fprintf(const struct tag *tag, const struct conf_fprintf *conf, FILE *fp) { struct type *type = tag__type(tag); struct enumerator *pos; int max_entry_name_len = enumeration__max_entry_name_len(type); - size_t printed = fprintf(fp, "enum%s%s%s%s {\n", - type__name(type) ? " " : "", - type__name(type) && anonymous ? "/* " : "", - type__name(type) ? type__name(type) : "", - type__name(type) && anonymous ? " */" : ""); + size_t printed = fprintf(fp, "enum%s%s {\n", type__name(type) ? " " : "", type__name(type) ?: ""); int indent = conf->indent; if (indent >= (int)sizeof(tabs)) @@ -639,8 +634,7 @@ static size_t type__fprintf_stats(struct type *type, const struct cu *cu, } static size_t union__fprintf(struct type *type, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp, - bool anonymous); + const struct conf_fprintf *conf, FILE *fp); static size_t type__fprintf(struct tag *type, const struct cu *cu, const char *name, const struct conf_fprintf *conf, @@ -656,7 +650,6 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu, }; size_t printed = 0; int expand_types = conf->expand_types; - int inner_anonymous = conf->inner_anonymous; int suppress_offset_comment = conf->suppress_offset_comment; if (type == NULL) @@ -814,7 +807,7 @@ print_default: class__find_holes(cclass); tconf.type_spacing -= 8; - printed += __class__fprintf(cclass, cu, &tconf, fp, inner_anonymous); + printed += __class__fprintf(cclass, cu, &tconf, fp); } break; case DW_TAG_union_type: @@ -824,7 +817,7 @@ print_default: printed += fprintf(fp, "union %-*s %s", tconf.type_spacing - 6, type__name(ctype), name ?: ""); } else { tconf.type_spacing -= 8; - printed += union__fprintf(ctype, cu, &tconf, fp, inner_anonymous); + printed += union__fprintf(ctype, cu, &tconf, fp); } break; case DW_TAG_enumeration_type: @@ -833,7 +826,7 @@ print_default: if (type__name(ctype) != NULL) printed += fprintf(fp, "enum %-*s %s", tconf.type_spacing - 5, type__name(ctype), name ?: ""); else - printed += enumeration__fprintf(type, &tconf, fp, inner_anonymous); + printed += enumeration__fprintf(type, &tconf, fp); break; } out: @@ -998,8 +991,7 @@ static size_t union_member__fprintf(struct class_member *member, } static size_t union__fprintf(struct type *type, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp, - bool anonymous) + const struct conf_fprintf *conf, FILE *fp) { struct class_member *pos; size_t printed = 0; @@ -1013,11 +1005,8 @@ static size_t union__fprintf(struct type *type, const struct cu *cu, if (conf->prefix != NULL) printed += fprintf(fp, "%s ", conf->prefix); - printed += fprintf(fp, "union%s%s%s%s {\n", - type__name(type) ? " " : "", - type__name(type) && anonymous ? "/* " : "", - type__name(type) ?: "", - type__name(type) && anonymous ? " */" : ""); + printed += fprintf(fp, "union%s%s {\n", type__name(type) ? " " : "", + type__name(type) ?: ""); uconf = *conf; uconf.indent = indent + 1; @@ -1375,8 +1364,7 @@ out: } static size_t __class__fprintf(struct class *class, const struct cu *cu, - const struct conf_fprintf *conf, FILE *fp, - bool anonymous) + const struct conf_fprintf *conf, FILE *fp) { struct type *type = &class->type; size_t last_size = 0, size; @@ -1396,16 +1384,14 @@ static size_t __class__fprintf(struct class *class, const struct cu *cu, const char *current_accessibility = NULL; struct conf_fprintf cconf = conf ? *conf : conf_fprintf__defaults; const uint16_t t = type->namespace.tag.tag; - size_t printed = fprintf(fp, "%s%s%s%s%s%s%s", + size_t printed = fprintf(fp, "%s%s%s%s%s", cconf.prefix ?: "", cconf.prefix ? " " : "", ((cconf.classes_as_structs || t == DW_TAG_structure_type) ? "struct" : t == DW_TAG_class_type ? "class" : "interface"), type__name(type) ? " " : "", - anonymous && type__name(type) ? "/* " : "", - type__name(type) ?: "", - anonymous && type__name(type) ? " */" : ""); + type__name(type) ?: ""); int indent = cconf.indent; if (indent >= (int)sizeof(tabs)) @@ -1822,7 +1808,7 @@ out: size_t class__fprintf(struct class *class, const struct cu *cu, FILE *fp) { - return __class__fprintf(class, cu, NULL, fp, false); + return __class__fprintf(class, cu, NULL, fp); } static size_t variable__fprintf(const struct tag *tag, const struct cu *cu, @@ -1909,7 +1895,7 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu, printed += array_type__fprintf(tag, cu, "array", pconf, fp); break; case DW_TAG_enumeration_type: - printed += enumeration__fprintf(tag, pconf, fp, false); + printed += enumeration__fprintf(tag, pconf, fp); break; case DW_TAG_typedef: printed += typedef__fprintf(tag, cu, pconf, fp); @@ -1917,7 +1903,7 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu, case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: - printed += __class__fprintf(tag__class(tag), cu, pconf, fp, false); + printed += __class__fprintf(tag__class(tag), cu, pconf, fp); break; case DW_TAG_subroutine_type: printed += ftype__fprintf(tag__ftype(tag), cu, NULL, false, false, 0, true, pconf, fp); @@ -1929,7 +1915,7 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu, printed += function__fprintf(tag, cu, pconf, fp); break; case DW_TAG_union_type: - printed += union__fprintf(tag__type(tag), cu, pconf, fp, false); + printed += union__fprintf(tag__type(tag), cu, pconf, fp); break; case DW_TAG_variable: printed += variable__fprintf(tag, cu, pconf, fp); -- 2.25.1