From 42aaa3124e42b3ebd81b905527e472177c14f873 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Tue, 11 Mar 2014 13:55:35 +0100 Subject: [PATCH] Do not declare classes before defining them anymore * src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not declare classes before defining them because both the declaration and the definition now compare equal. * tests/data/test-read-dwarf/test1.abi: Update test. * tests/data/test-read-write/test20.xml: Likewise. Signed-off-by: Dodji Seketeli --- src/abg-dwarf-reader.cc | 39 ++++++----------- tests/data/test-read-dwarf/test1.abi | 61 +++++++++++++-------------- tests/data/test-read-write/test20.xml | 43 +++++++++---------- 3 files changed, 62 insertions(+), 81 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index bab23ad0..0e9bce5e 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2228,46 +2228,32 @@ build_class_type_and_add_to_ir(read_context& ctxt, size_t size = 0; die_size_in_bits(die, size); - class_decl_sptr cur_class_decl; - decl_base_sptr cur_class, res; - - if (klass) - { - cur_class_decl = klass; - cur_class = klass; - result = klass; - } - else - { - cur_class_decl.reset(new class_decl(name, is_struct)); - cur_class = add_decl_to_scope(cur_class_decl, scope); - } - Dwarf_Die child; bool has_child = (dwarf_child(die, &child) == 0); bool is_declaration_only = die_is_declaration_only(die); - if (!has_child && is_declaration_only) - // TODO: set the access specifier for the declaration-only class - // here. - return cur_class; - - if (!klass) + decl_base_sptr res; + if (klass) + result = klass; + else { - ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = cur_class; - if (is_declaration_only) result.reset(new class_decl(name, is_struct)); else result.reset(new class_decl(name, size, 0, is_struct, loc, decl_base::VISIBILITY_DEFAULT)); res = add_decl_to_scope(result, scope); - assert(cur_class_decl->is_declaration_only()); - cur_class_decl->set_definition_of_declaration(result); result = dynamic_pointer_cast(as_non_member_type(res)); assert(result); } + if (!has_child) + // TODO: set the access specifier for the declaration-only class + // here. + return res; + + ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = res; + scope_decl_sptr scop = dynamic_pointer_cast (get_type_declaration(as_non_member_type(res))); @@ -2415,7 +2401,7 @@ build_class_type_and_add_to_ir(read_context& ctxt, class_decl_sptr k = dynamic_pointer_cast (this_type->get_pointed_to_type()); - if (k && *k == *cur_class_decl) + if (k && *k == *result) is_static = true; } } @@ -2460,7 +2446,6 @@ build_class_type_and_add_to_ir(read_context& ctxt, ctxt.die_wip_classes_map().find(dwarf_dieoffset(die)); if (i != ctxt.die_wip_classes_map().end()) { - result->set_earlier_declaration(i->second); class_decl::member_type_sptr m = dynamic_pointer_cast(i->second); if (m) diff --git a/tests/data/test-read-dwarf/test1.abi b/tests/data/test-read-dwarf/test1.abi index d87569ba..a37ee8fb 100644 --- a/tests/data/test-read-dwarf/test1.abi +++ b/tests/data/test-read-dwarf/test1.abi @@ -1,71 +1,68 @@ - - - - + + + - + - + - + - + - - + + - - + + - - + + - - + - + - + - - - - + + + - + - + - - - - - - + + + + + + - + - + diff --git a/tests/data/test-read-write/test20.xml b/tests/data/test-read-write/test20.xml index 45de6e68..16a7bd50 100644 --- a/tests/data/test-read-write/test20.xml +++ b/tests/data/test-read-write/test20.xml @@ -23,9 +23,7 @@ - - - + @@ -42,47 +40,48 @@ - - - + + + + - + - + - - - + + + - - + + - + - - - - - - - - + + + + + + + +