diff mbox series

[applied] Peel array types when peeling pointers from a type

Message ID 874ker5dol.fsf@redhat.com
State Committed
Headers show
Series [applied] Peel array types when peeling pointers from a type | expand

Commit Message

Dodji Seketeli May 25, 2021, 10:07 a.m. UTC
Hello,

In peel_typedef_pointer_or_reference_type, we want to peel typedefs
and pointer types (in general) from a given type.  We need to peel
array types as well, as those are conceptually a pointer-like type as
well.

This patch does that.

	* src/abg-ir.cc (peel_typedef_pointer_or_reference_type): In the
	overloads for type_base_sptr and type_base*, peel array type off
	as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.

---
 src/abg-ir.cc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 85766edf..d0f8c6b8 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -6073,7 +6073,8 @@  peel_typedef_pointer_or_reference_type(const type_base_sptr type)
   type_base_sptr typ = type;
   while (is_typedef(typ)
 	 || is_pointer_type(typ)
-	 || is_reference_type(typ))
+	 || is_reference_type(typ)
+	 || is_array_type(typ))
     {
       if (typedef_decl_sptr t = is_typedef(typ))
 	typ = peel_typedef_type(t);
@@ -6083,6 +6084,9 @@  peel_typedef_pointer_or_reference_type(const type_base_sptr type)
 
       if (reference_type_def_sptr t = is_reference_type(typ))
 	typ = peel_reference_type(t);
+
+      if (const array_type_def_sptr t = is_array_type(typ))
+	typ = peel_array_type(t);
     }
 
   return typ;
@@ -6100,7 +6104,8 @@  peel_typedef_pointer_or_reference_type(const type_base* type)
 {
   while (is_typedef(type)
 	 || is_pointer_type(type)
-	 || is_reference_type(type))
+	 || is_reference_type(type)
+	 || is_array_type(type))
     {
       if (const typedef_decl* t = is_typedef(type))
 	type = peel_typedef_type(t);
@@ -6110,6 +6115,9 @@  peel_typedef_pointer_or_reference_type(const type_base* type)
 
       if (const reference_type_def* t = is_reference_type(type))
 	type = peel_reference_type(t);
+
+      if (const array_type_def* t = is_array_type(type))
+	type = peel_array_type(t);
     }
 
   return const_cast<type_base*>(type);
@@ -6130,6 +6138,7 @@  peel_pointer_or_reference_type(const type_base *type,
 {
   while (is_pointer_type(type)
 	 || is_reference_type(type)
+	 || is_array_type(type)
 	 || (peel_qual_type && is_qualified_type(type)))
     {
       if (const pointer_type_def* t = is_pointer_type(type))