diff --git a/include/abg-ir.h b/include/abg-ir.h index ab4e556e..82b400d4 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -1609,7 +1609,7 @@ public: private: mutable bool hashing_started_; - class_decl_sptr declaration_; + decl_base_sptr declaration_; bool is_declaration_only_; class_decl_sptr definition_of_declaration_; base_specs bases_; @@ -1664,12 +1664,9 @@ public: get_definition_of_declaration() const; void - set_earlier_declaration(class_decl_sptr declaration); + set_earlier_declaration(decl_base_sptr declaration); - void - set_earlier_declaration(type_base_sptr declaration); - - class_decl_sptr + decl_base_sptr get_earlier_declaration() const {return declaration_;} diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 4d58a713..037a3ea9 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -70,7 +70,7 @@ typedef unordered_map die_decl_map_type; /// Convenience typedef for a map which key is the offset of a dwarf /// die, (given by dwarf_dieoffset()) and which value is the /// corresponding class_decl. -typedef unordered_map die_class_map_type; +typedef unordered_map die_class_map_type; /// Convenience typedef for a map which key is the offset of a /// DW_TAG_compile_unit and the key is the corresponding @ref @@ -2174,8 +2174,9 @@ build_class_type_and_add_to_ir(read_context& ctxt, die_size_in_bits(die, size); class_decl_sptr cur_class_decl (new class_decl(name)); - insert_decl_into_ir_under_scope(ctxt, cur_class_decl, scope); - ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = cur_class_decl; + decl_base_sptr cur_class = + insert_decl_into_ir_under_scope(ctxt, cur_class_decl, scope); + ctxt.die_wip_classes_map()[dwarf_dieoffset(die)] = cur_class; result.reset(new class_decl(name, size, 0, loc, decl_base::VISIBILITY_DEFAULT)); @@ -2208,7 +2209,6 @@ build_class_type_and_add_to_ir(read_context& ctxt, decl_base_sptr base_type = build_ir_node_from_die(ctxt, &type_die, called_from_public_decl); - base_type = get_type_declaration(as_non_member_type(base_type)); class_decl_sptr b = dynamic_pointer_cast(base_type); if (!b) continue; @@ -2246,7 +2246,7 @@ build_class_type_and_add_to_ir(read_context& ctxt, decl_base_sptr ty = build_ir_node_from_die(ctxt, &type_die, called_from_public_decl); - type_base_sptr t = as_non_member_type(ty); + type_base_sptr t = is_type(ty); if (!t) continue; @@ -2361,6 +2361,15 @@ build_class_type_and_add_to_ir(read_context& ctxt, 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) + { + class_decl::member_type_sptr m2 = + dynamic_pointer_cast(res); + if (m2) + m2->set_access_specifier(m->get_access_specifier()); + } ctxt.die_wip_classes_map().erase(i); } } @@ -2402,7 +2411,6 @@ build_qualified_type(read_context& ctxt, decl_base_sptr utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die, called_from_public_decl); - utype_decl = get_type_declaration(as_non_member_type(utype_decl)); if (!utype_decl) return result; @@ -2452,7 +2460,6 @@ build_pointer_type_def(read_context& ctxt, decl_base_sptr utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die, called_from_public_decl); - utype_decl = get_type_declaration(as_non_member_type(utype_decl)); if (!utype_decl) return result; @@ -2502,7 +2509,6 @@ build_reference_type(read_context& ctxt, decl_base_sptr utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die, called_from_public_decl); - utype_decl = get_type_declaration(as_non_member_type(utype_decl)); if (!utype_decl) return result; @@ -2553,7 +2559,6 @@ build_typedef_type(read_context& ctxt, decl_base_sptr utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die, called_from_public_decl); - utype_decl = get_type_declaration(as_non_member_type(utype_decl)); if (!utype_decl) return result; @@ -2599,7 +2604,7 @@ build_var_decl(read_context& ctxt, /*called_from_public_decl=*/true); if (!ty) return result; - type = as_non_member_type(ty); + type = is_type(ty); assert(type); } @@ -2664,7 +2669,6 @@ build_function_decl(read_context& ctxt, return_type_decl = build_ir_node_from_die(ctxt, &ret_type_die, /*called_from_public_decl=*/true); - return_type_decl = get_type_declaration(as_non_member_type(return_type_decl)); class_decl_sptr is_method = dynamic_pointer_cast(get_scope_for_die(ctxt, die)); @@ -2691,8 +2695,6 @@ build_function_decl(read_context& ctxt, /*called_from_public_decl=*/true); if (!parm_type_decl) continue; - parm_type_decl = - get_type_declaration(as_non_member_type(parm_type_decl)); function_decl::parameter_sptr p (new function_decl::parameter(is_type(parm_type_decl), name, loc, /*variadic_marker=*/false, diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 15db6ab1..2f7b6651 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -2342,25 +2342,13 @@ class_decl::get_definition_of_declaration() const /// @param declaration the earlier declaration to set. Note that it's /// set only if it's a pure declaration. void -class_decl::set_earlier_declaration(class_decl_sptr declaration) +class_decl::set_earlier_declaration(decl_base_sptr declaration) { - if (declaration && declaration->is_declaration_only()) + class_decl_sptr cl = as_non_member_class_decl(declaration); + if (cl && cl->is_declaration_only()) declaration_ = declaration; } -/// Set the earlier declaration of this class definition. -/// -/// @param declaration the earlier declaration to set. Note that it's -/// set only if it's a pure declaration. It's dynamic type must be -/// pointer to class_decl. -void -class_decl::set_earlier_declaration(type_base_sptr declaration) -{ - class_decl_sptr d = dynamic_pointer_cast(declaration); - if (d) - set_earlier_declaration(d); -} - decl_base_sptr class_decl::insert_member_decl(decl_base_sptr d, declarations::iterator before)