From 99610d5857e526393695576fb4bcf1e520a0859a Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 8 Jan 2007 22:06:11 -0200 Subject: [PATCH] [CLASSES]: Handle DW_TAG_enumeration_type in cu__process_class In C++ we can have enums defined inside classes. Signed-off-by: Arnaldo Carvalho de Melo --- classes.c | 66 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/classes.c b/classes.c index 96d7d0d..1923ee2 100644 --- a/classes.c +++ b/classes.c @@ -2069,6 +2069,38 @@ out: cu__add_tag(cu, &ftype->tag); } +static void cu__create_new_enumeration(Dwarf_Die *die, struct cu *cu) +{ + Dwarf_Die child; + struct enumeration *enumeration = enumeration__new(die); + + if (enumeration == NULL) + oom("class__new"); + + if (!dwarf_haschildren(die) || dwarf_child(die, &child) != 0) { + fprintf(stderr, "%s: DW_TAG_enumeration_type with no " + "children!\n", __FUNCTION__); + return; + } + + die = &child; + do { + struct enumerator *enumerator; + + if (dwarf_tag(die) != DW_TAG_enumerator) { + cu__tag_not_handled(die); + continue; + } + enumerator = enumerator__new(die); + if (enumerator == NULL) + oom("enumerator__new"); + + enumeration__add(enumeration, enumerator); + } while (dwarf_siblingof(die, die) == 0); + + cu__add_tag(cu, &enumeration->type.tag); +} + static void cu__process_class(Dwarf_Die *die, struct class *class, struct cu *cu) { @@ -2085,6 +2117,8 @@ static void cu__process_class(Dwarf_Die *die, struct class *class, } break; case DW_TAG_enumeration_type: + cu__create_new_enumeration(die, cu); + break; case DW_TAG_structure_type: case DW_TAG_union_type: /* @@ -2133,38 +2167,6 @@ static void cu__create_new_inline_expansion(struct cu *cu, Dwarf_Die *die, lexblock__add_inline_expansion(lexblock, exp); } -static void cu__create_new_enumeration(Dwarf_Die *die, struct cu *cu) -{ - Dwarf_Die child; - struct enumeration *enumeration = enumeration__new(die); - - if (enumeration == NULL) - oom("class__new"); - - if (!dwarf_haschildren(die) || dwarf_child(die, &child) != 0) { - fprintf(stderr, "%s: DW_TAG_enumeration_type with no " - "children!\n", __FUNCTION__); - return; - } - - die = &child; - do { - struct enumerator *enumerator; - - if (dwarf_tag(die) != DW_TAG_enumerator) { - cu__tag_not_handled(die); - continue; - } - enumerator = enumerator__new(die); - if (enumerator == NULL) - oom("enumerator__new"); - - enumeration__add(enumeration, enumerator); - } while (dwarf_siblingof(die, die) == 0); - - cu__add_tag(cu, &enumeration->type.tag); -} - static void cu__process_function(Dwarf_Die *die, struct cu *cu, struct ftype *ftype, struct lexblock *lexblock)