From: Dodji Seketeli Date: Fri, 13 Sep 2024 07:07:01 +0000 (+0200) Subject: WIP: ir: Fix real type name setting X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=784155a910a9dfb55e0039ad6503aafef45db158;p=libabigail.git WIP: ir: Fix real type name setting Signed-off-by: Dodji Seketeli --- diff --git a/src/abg-ir.cc b/src/abg-ir.cc index a30b77c2..8040301b 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -214,6 +214,9 @@ get_generic_anonymous_internal_type_name(const decl_base *d); static string get_internal_real_type_name(const type_base*); +static string +get_real_type_name(const type_base* t); + static void update_qualified_name(decl_base * d); @@ -8739,6 +8742,22 @@ get_internal_real_type_name(const type_base* t) return name; } +static string +get_real_type_name(const type_base* t) +{ + string name; + type_decl *type = is_real_type(t); + + if (!type) + return name; + + real_type int_type; + if (parse_real_type(type->get_name(), int_type)) + name = int_type.to_string(/*internal=*/false); + + return name; +} + /// Get the name of a given type and return a copy of it. /// /// @param t the type to consider. @@ -16741,26 +16760,43 @@ type_decl::get_qualified_name(bool internal) const { const environment& env = get_environment(); - - if (internal) - if (is_real_type(this)) - { - if (get_naked_canonical_type()) - { - if (decl_base::priv_->internal_qualified_name_.empty()) - decl_base::priv_->internal_qualified_name_ = + if (is_real_type(this)) + { + if (get_naked_canonical_type()) + { + if (internal) + { + if (decl_base::priv_->internal_qualified_name_.empty()) + decl_base::priv_->internal_qualified_name_ = + env.intern(get_internal_real_type_name(this)); + return decl_base::priv_->internal_qualified_name_; + } + else + { + if (decl_base::priv_->qualified_name_.empty()) + decl_base::priv_->qualified_name_ = + env.intern(get_real_type_name(this)); + return decl_base::priv_->qualified_name_; + } + } + else + { + if (internal) + { + decl_base::priv_->temporary_internal_qualified_name_ = env.intern(get_internal_real_type_name(this)); - return decl_base::priv_->internal_qualified_name_; - } - else - { - decl_base::priv_->temporary_internal_qualified_name_ = - env.intern(get_internal_real_type_name(this)); - return decl_base::priv_->temporary_internal_qualified_name_; - } - } + return decl_base::priv_->temporary_internal_qualified_name_; + } + else + { + decl_base::priv_->temporary_qualified_name_ = + env.intern(get_real_type_name(this)); + return decl_base::priv_->temporary_qualified_name_; + } + } + } - return decl_base::get_qualified_name(/*internal=*/false); + return decl_base::get_qualified_name(internal); } /// Get the pretty representation of the current instance of @ref @@ -29965,15 +30001,24 @@ qualified_name_setter::do_update(abigail::ir::decl_base* d) d->priv_->qualified_name_ = abigail::interned_string(); else { - d->priv_->qualified_name_ = - env.intern(d->priv_->qualified_parent_name_ + "::" + d->get_name()); - d->priv_->internal_qualified_name_ = env.intern(d->get_name()); + if (abigail::ir::type_decl* t = is_real_type(d)) + { + d->priv_->qualified_name_ = env.intern(get_real_type_name(t)); + d->priv_->internal_qualified_name_ = + env.intern(get_internal_real_type_name(t)); + } + else + { + d->priv_->qualified_name_ = + env.intern(d->priv_->qualified_parent_name_ + "::" + d->get_name()); + d->priv_->internal_qualified_name_ = env.intern(d->get_name()); + } } } // Make sure the internal qualified name (used for type - // canonicalization puroses) is always the qualified name. For + // canonicalization purposes) is always the qualified name. For // integral/real types however, only the non qualified type is used. - if (!is_integral_type(d)) + if (!is_real_type(d)) d->priv_->internal_qualified_name_ = d->priv_->qualified_name_; if (d->priv_->scoped_name_.empty())