From: Roland McGrath Date: Mon, 6 Jul 2009 22:04:24 +0000 (-0700) Subject: Pass attribute name down to value constructors. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61a59b9af4b5ae247822f57cb4f7101e5ceba487;p=thirdparty%2Felfutils.git Pass attribute name down to value constructors. --- diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index dc98e6d7d..38f2afe45 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -780,7 +780,7 @@ namespace elfutils template static inline value_dispatch * - make (flavor *&result, const input &x, arg_type &arg) + make (flavor *&result, int /*whatattr*/, const input &x, arg_type &arg) { assert (alloc_values); return result = new flavor (x, arg); @@ -1077,17 +1077,17 @@ namespace elfutils template struct init { - inline init (attr_value *av, + inline init (attr_value *av, int whatattr, const value &other, arg_type &arg = arg_type ()) { switch (other.what_space ()) { -#define _DWARF_DATA_AV_MAKE(flavor, fetch) \ - case dwarf::VS_##flavor: \ - { \ - typename vw::value_##flavor *p; \ - av->_m_value = vw::make (p, other.fetch (), arg); \ - } \ +#define _DWARF_DATA_AV_MAKE(flavor, fetch) \ + case dwarf::VS_##flavor: \ + { \ + typename vw::value_##flavor *p; \ + av->_m_value = vw::make (p, whatattr, other.fetch (), arg); \ + } \ break _DWARF_DATA_AV_MAKE (identifier, identifier); @@ -1107,12 +1107,13 @@ namespace elfutils if (other.constant_is_integer ()) { typename vw::value_constant *p; - av->_m_value = vw::make (p, other.constant (), arg); + av->_m_value = vw::make (p, whatattr, other.constant (), arg); } else { typename vw::value_constant_block *p; - av->_m_value = vw::make (p, other.constant_block (), arg); + av->_m_value = vw::make (p, whatattr, + other.constant_block (), arg); } break; @@ -1125,12 +1126,12 @@ namespace elfutils } }; - // This kosher only when freshly default-constructed. + // This is kosher only when freshly default-constructed. template - inline void set (const value &other, arg_type &arg) + inline void set (int whatattr, const value &other, arg_type &arg) { assert (_m_value == NULL); - init me (this, other, arg); + init me (this, whatattr, other, arg); } template @@ -1162,14 +1163,7 @@ namespace elfutils : _m_value (NULL) { if (other._m_value != NULL) - init me (this, other); - } - - template - attr_value (const value &other, arg_type &arg) - : _m_value (NULL) - { - set (this, other, arg); + init me (this, 0, other); } inline attr_value () @@ -1189,7 +1183,7 @@ namespace elfutils delete _m_value; _m_value = NULL; } - init me (this, other); + init me (this, 0, other); return *this; } template @@ -1200,7 +1194,7 @@ namespace elfutils delete _m_value; _m_value = NULL; } - init me (this, other); + init me (this, 0, other); return *this; } @@ -1462,7 +1456,7 @@ namespace elfutils for (typename input::const_iterator attr = other.begin (); attr != other.end (); ++attr) - (*this)[(*attr).first].set ((*attr).second, c); + (*this)[(*attr).first].set ((*attr).first, (*attr).second, c); } #if 0 diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 832a1075a..c0f638fe3 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -303,6 +303,8 @@ namespace elfutils return subr::argifier (c) (in); } + /* Every kind of value is made by calling into the copier, which + returns a const pointer into a value_set living in the collector. */ struct value : public dwarf_data::value { @@ -312,98 +314,98 @@ namespace elfutils template static inline value_dispatch * - make (flavor *&, const input &, const subr::nothing &) + make (flavor *&, int, const input &, const subr::nothing &) { throw std::logic_error ("dwarf_output cannot be default-constructed"); } template static inline const value_dispatch * - make (value_string *&, const input &x, copier &c) + make (value_string *&, int, const input &x, copier &c) { return c.add_string (x); } template static inline const value_dispatch * - make (value_identifier *&, const input &x, copier &c) + make (value_identifier *&, int, const input &x, copier &c) { return c.add_identifier (x); } template static inline const value_dispatch * - make (value_reference *&, const input &x, copier &c) + make (value_reference *&, int, const input &x, copier &c) { return c.add_reference (x); } template static inline const value_dispatch * - make (value_flag *&, const input &x, copier &c) + make (value_flag *&, int, const input &x, copier &c) { return c.add_flag (x); } template static inline const value_dispatch * - make (value_address *&, const input &x, copier &c) + make (value_address *&, int, const input &x, copier &c) { return c.add_address (x); } template static inline const value_dispatch * - make (value_rangelistptr *&, const input &x, copier &c) + make (value_rangelistptr *&, int, const input &x, copier &c) { return c.add_ranges (x); } template static inline const value_dispatch * - make (value_lineptr *&, const input &x, copier &c) + make (value_lineptr *&, int, const input &x, copier &c) { return c.add_line_info (x); } template static inline const value_dispatch * - make (value_constant *&, const input &x, copier &c) + make (value_constant *&, int, const input &x, copier &c) { return c.add_constant (x); } template static inline const value_dispatch * - make (value_constant_block *&, const input &x, copier &c) + make (value_constant_block *&, int, const input &x, copier &c) { return c.add_constant_block (x); } template static inline const value_dispatch * - make (value_dwarf_constant *&, const input &x, copier &c) + make (value_dwarf_constant *&, int, const input &x, copier &c) { return c.add_dwarf_constant (x); } template static inline const value_dispatch * - make (value_source_file *&, const input &x, copier &c) + make (value_source_file *&, int attr, const input &x, copier &c) { - return c.add_source_file (x); + return c.add_source_file (attr, x); } template static inline const value_dispatch * - make (value_source_line *&, const input &x, copier &c) + make (value_source_line *&, int, const input &x, copier &c) { return c.add_source_line (x); } template static inline const value_dispatch * - make (value_source_column *&, const input &x, copier &c) + make (value_source_column *&, int, const input &x, copier &c) { return c.add_source_column (x); } @@ -412,11 +414,10 @@ namespace elfutils template static inline const value_dispatch * - make (value_location *&, const input &x, copier &c) + make (value_location *&, int, const input &x, copier &c) { return c.add_location (x); } - }; public: @@ -452,16 +453,6 @@ namespace elfutils public: typedef debug_info_entry value_type; - - inline iterator add_entry (int tag, const iterator &pos) - { - return insert (pos, debug_info_entry (tag)); - } - - inline iterator add_entry (int tag) - { - return add_entry (tag, end ()); - } }; typedef children_type::iterator pointer; @@ -703,7 +694,7 @@ namespace elfutils template inline const value::value_reference *add_reference (const input &x) { - // XXX temporary kludge + // XXX temporary kludge (leak!) return new value::value_reference (x, *this); } @@ -752,7 +743,8 @@ namespace elfutils } template - inline const value::value_source_file *add_source_file (const input &x) + inline const value::value_source_file *add_source_file (int /*whatattr*/, + const input &x) { return _m_collector->_m_source_file.add (x); }