[12/27] ir: Fix name setting of a ptr-to-mbr-type
Commit Message
Hello,
The name of a pointer to member type is currently set at the time of
construction of the type.
This can be problematic because at the time of construction of the
type, the member type might not be yet fully constructed. That would
result in a name (for the pointer to member type) that is incorrect
and stays incorrect for the lifetime of the ptr-to-mbr-type.
To be correct, the name of the pointer to member type must always
reflect the current state of the member and containing types.
This patch does just that.
The patch turns decl_base::get_name into a virtual member function.
It then creates a ptr_to_mbr_type::get_name virtual member function
that dynamically overloads decl_base::get_name. Then,
ptr_to_mbr_type::get_name just builds and returns the qualified name
of the pointer to member type.
* include/abg-ir.h (decl_base::{g,s}et_name): Make these member
functions virtual.
(ptr_to_mbr_type::get_name): Add new virtual overload.
* src/abg-ir.cc (ptr_to_mbr_type::ptr_to_mbr_type): Do not set the
name of the type here. Just say that it's not anonymous.
(ptr_to_mbr_type::get_name): Define new (virtual) member function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
include/abg-ir.h | 7 +++++--
src/abg-ir.cc | 16 ++++++++++++----
2 files changed, 17 insertions(+), 6 deletions(-)
@@ -1680,13 +1680,13 @@ public:
void
set_location(const location& l);
- const interned_string&
+ virtual const interned_string&
get_name() const;
const interned_string&
get_qualified_parent_name() const;
- void
+ virtual void
set_name(const string& n);
bool
@@ -2475,6 +2475,9 @@ class ptr_to_mbr_type : public virtual type_base,
size_t alignment_in_bits,
const location& locus);
+ virtual const interned_string&
+ get_name() const;
+
virtual hash_t
hash_value() const;
@@ -18390,10 +18390,18 @@ ptr_to_mbr_type::ptr_to_mbr_type(const environment& env,
runtime_type_instance(this);
ABG_ASSERT(member_type);
ABG_ASSERT(containing_type);
- interned_string name = ptr_to_mbr_declaration_name(this, "",
- /*qualified=*/true,
- /*internal=*/false);
- set_name(name);
+ set_is_anonymous(false);
+}
+
+/// Getter of the name of the current ptr-to-mbr-type.
+///
+/// This just returns the qualified name.
+///
+/// @return the (qualified) name of the the type.
+const interned_string&
+ptr_to_mbr_type::get_name() const
+{
+ return get_qualified_name(/*internal=*/false);
}
/// Return the hash value of the current IR node.