From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] RHBZ1951496 - ir: Acknowledge that "void type" is not canonicalized
Date: Wed, 08 Sep 2021 16:28:49 +0200 [thread overview]
Message-ID: <87y287dtum.fsf@redhat.com> (raw)
Hello,
In the libabigail type system, the void type is a synthetic type and
is thus not canonicalized.
We forgot to mention this "void type" to
hash_as_canonical_type_or_constant as being one of the types that are
allowed to be non canonicalized in the system. This omission violates
an assert in that function.
The patch introduces a new is_allowed_non_canonicalized_type
subroutine that defines the types that are allowed to be non
canonicalized in the system and make it recognize "void type" as such.
hash_as_canonical_type_or_constant uses the new
is_allowed_non_canonicalized_type.
This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1951496
* src/abg-ir.cc (is_allowed_non_canonicalized_type): Define new
static function.
(hash_as_canonical_type_or_constant): Use it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
src/abg-ir.cc | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 3ce49e76..6ce614a5 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -24932,6 +24932,25 @@ size_t
hash_type_or_decl(const type_or_decl_base_sptr& tod)
{return hash_type_or_decl(tod.get());}
+/// Test if a given type is allowed to be non canonicalized
+///
+/// This is a subroutine of hash_as_canonical_type_or_constant.
+///
+/// For now, the only types allowed to be non canonicalized in the
+/// system are decl-only class/union and the void type.
+///
+/// @return true iff @p t is a one of the only types allowed to be
+/// non-canonicalized in the system.
+static bool
+is_allowed_non_canonicalized_type(const type_base *t)
+{
+ if (!t)
+ return true;
+
+ const environment* env = t->get_environment();
+ return is_declaration_only_class_or_union_type(t) || env->is_void_type(t);
+}
+
/// Hash a type by either returning the pointer value of its canonical
/// type or by returning a constant if the type doesn't have a
/// canonical type.
@@ -24971,10 +24990,10 @@ hash_as_canonical_type_or_constant(const type_base *t)
return reinterpret_cast<size_t>(canonical_type);
// If we reached this point, it means we are seeing a
- // non-canonicalized type. It must be a decl-only class or a
- // typedef type, otherwise it means that for some weird reason, the
- // type hasn't been canonicalized. It should be!
- ABG_ASSERT(is_declaration_only_class_or_union_type(t));
+ // non-canonicalized type. It must be a decl-only class or a void
+ // type, otherwise it means that for some weird reason, the type
+ // hasn't been canonicalized. It should be!
+ ABG_ASSERT(is_allowed_non_canonicalized_type(t));
return 0xDEADBABE;
}
--
2.30.0
--
Dodji
reply other threads:[~2021-09-08 14:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y287dtum.fsf@redhat.com \
--to=dodji@redhat.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).