From: Roland McGrath Date: Tue, 27 Jan 2009 13:21:02 +0000 (-0800) Subject: Support operator-> where possible. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5efe24e8c0e4b0f2ca35a7044344d112b20f65dc;p=thirdparty%2Felfutils.git Support operator-> where possible. --- diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index 9b171a9e8..8fa911553 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -477,6 +477,7 @@ namespace elfutils : public std::iterator { friend class debug_info_entry; + friend class attr_value; private: debug_info_entry _m_die; @@ -487,6 +488,12 @@ namespace elfutils xif (result < 0); } + // Construct from a reference attribute. + inline const_iterator (Dwarf_Attribute *attr) + { + xif (::dwarf_formref_die (attr, &_m_die._m_die) == NULL); + } + public: inline const_iterator (const const_iterator &i) : _m_die (i._m_die) {} @@ -494,6 +501,10 @@ namespace elfutils { return _m_die; } + inline const debug_info_entry *operator-> () const + { + return &(operator* ()); + } inline const_iterator &operator= (const const_iterator &other) { @@ -702,10 +713,10 @@ namespace elfutils continue; } - if ((*i).tag () == ::DW_TAG_imported_unit) + if (i->tag () == ::DW_TAG_imported_unit) // We have an imported unit. Look at its referent. - _m_stack.push ((*i).attributes ().at (::DW_AT_import) - .reference ().raw_children ().begin ()); + _m_stack.push (i->attributes ().at (::DW_AT_import) + .reference ()->raw_children ().begin ()); else // This is some other DIE. Iterate on it. break; @@ -744,6 +755,10 @@ namespace elfutils { return *_m_stack.top (); } + inline const debug_info_entry *operator-> () const + { + return &(operator* ()); + } inline const_iterator &operator++ () // prefix { @@ -980,15 +995,10 @@ namespace elfutils std::string to_string () const; - inline debug_info_entry reference () const - { - debug_info_entry result; - xif (::dwarf_formref_die (thisattr (), result.thisdie ()) == NULL); - return result; - } - inline compile_unit unit_reference () const + // Return an iterator on which * will yield the referent debug_info_entry. + inline debug_info_entry::raw_children::const_iterator reference () const { - return reference (); + return debug_info_entry::raw_children::const_iterator (thisattr ()); } // XXX reloc, dwfl @@ -1032,7 +1042,7 @@ namespace elfutils case VS_reference: case VS_unit_reference: // XXX Reference identity check (?) - return reference ().offset () == other.reference ().offset (); + return reference ()->offset () == other.reference ()->offset (); case VS_flag: return flag () == other.flag (); @@ -1476,6 +1486,10 @@ namespace elfutils { return _m_die; } + inline const debug_info_entry *operator-> () const + { + return &(operator* ()); + } inline const_iterator &operator= (const const_iterator &other) { @@ -1658,7 +1672,7 @@ namespace elfutils std::set::iterator k = ++j; while (++k != set.end () && adjacency (*j, *k)) ++j; - const arange_list::key_type joined ((*i).first, (*j).second); + const arange_list::key_type joined (i->first, j->second); set.erase (i, k); i = set.insert (joined).first; } diff --git a/libdw/c++/values.cc b/libdw/c++/values.cc index 337c70f5a..0da123375 100644 --- a/libdw/c++/values.cc +++ b/libdw/c++/values.cc @@ -202,7 +202,7 @@ dwarf::attr_value::to_string () const case VS_reference: case VS_unit_reference: - return hex_string (reference ().offset (), "[", "]"); + return hex_string (reference ()->offset (), "[", "]"); case VS_source_file: return source_file ().to_string ();