* [PATCH, applied] RHBZ1951496 - ir: Acknowledge that "void type" is not canonicalized
@ 2021-09-08 14:28 Dodji Seketeli
0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-09-08 14:28 UTC (permalink / raw)
To: libabigail
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-08 14:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 14:28 [PATCH, applied] RHBZ1951496 - ir: Acknowledge that "void type" is not canonicalized Dodji Seketeli
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).