From: Mark Wielaard Date: Thu, 7 Apr 2011 16:03:19 +0000 (+0200) Subject: Turn check_dups_abstract_origin into a die_check class. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b49c88a178c58f14973a470b280e1fb1be013764;p=thirdparty%2Felfutils.git Turn check_dups_abstract_origin into a die_check class. --- diff --git a/dwarflint/check_dups_abstract_origin.cc b/dwarflint/check_dups_abstract_origin.cc index 26d9811bc..080d2f189 100644 --- a/dwarflint/check_dups_abstract_origin.cc +++ b/dwarflint/check_dups_abstract_origin.cc @@ -27,8 +27,7 @@ # include #endif -#include "highlevel_check.hh" -#include "all-dies-it.hh" +#include "check_die_tree.hh" #include "pri.hh" #include "messages.hh" #include @@ -38,7 +37,7 @@ using elfutils::dwarf; namespace { class check_dups_abstract_origin - : public highlevel_check + : public die_check { public: static checkdescriptor const *descriptor () @@ -79,13 +78,13 @@ namespace } void - check_die_attr (dwarf::debug_info_entry const &die, + check_die_attr (dwarf::debug_info_entry const &entry, dwarf::attribute const &attr) { std::map m; for (dwarf::debug_info_entry::attributes_type::const_iterator - at = die.attributes ().begin (); - at != die.attributes ().end (); ++at) + at = entry.attributes ().begin (); + at != entry.attributes ().end (); ++at) m.insert (std::make_pair ((*at).first, (*at).second)); dwarf::attr_value const &val = attr.second; @@ -97,9 +96,9 @@ namespace at = referree.attributes ().begin (); at != referree.attributes ().end (); ++at) if ((at2 = m.find ((*at).first)) != m.end () - && ! duplicate_ok (die.tag (), at2->first, attr.first, + && ! duplicate_ok (entry.tag (), at2->first, attr.first, at2->second == (*at).second)) - wr_message (to_where (die), mc_impact_3 | mc_acc_bloat | mc_die_rel) + wr_message (to_where (entry), mc_impact_3 | mc_acc_bloat | mc_die_rel) << "Attribute " << dwarf::attributes::name (at2->first) << " is duplicated at " << dwarf::attributes::name (attr.first) << " (" << pri::ref (referree) << ")" @@ -108,26 +107,28 @@ namespace << std::endl; } - explicit check_dups_abstract_origin (checkstack &stack, dwarflint &lint) - : highlevel_check (stack, lint) + explicit + check_dups_abstract_origin (highlevel_check_i *, checkstack &, dwarflint &) { - for (all_dies_iterator it = all_dies_iterator (dw); - it != all_dies_iterator (); ++it) - { - // Do we have DW_AT_abstract_origin or DW_AT_specification? - dwarf::debug_info_entry const &die = *it; - for (dwarf::debug_info_entry::attributes_type::const_iterator - at = die.attributes ().begin (); - at != die.attributes ().end (); ++at) - if ((*at).first == DW_AT_abstract_origin - || (*at).first == DW_AT_specification) - { - assert ((*at).second.what_space () == dwarf::VS_reference); - check_die_attr (die, *at); - } - } + // No state necessary. + } + + virtual void + die (all_dies_iterator const &it) + { + // Do we have DW_AT_abstract_origin or DW_AT_specification? + dwarf::debug_info_entry const &entry = *it; + for (dwarf::debug_info_entry::attributes_type::const_iterator + at = entry.attributes ().begin (); + at != entry.attributes ().end (); ++at) + if ((*at).first == DW_AT_abstract_origin + || (*at).first == DW_AT_specification) + { + assert ((*at).second.what_space () == dwarf::VS_reference); + check_die_attr (entry, *at); + } } }; - reg reg; + reg_die_check reg; }