]> sourceware.org Git - libabigail.git/commitdiff
Better detection of void* to something* change
authorDodji Seketeli <dodji@redhat.com>
Thu, 21 Mar 2019 17:08:59 +0000 (18:08 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 21 Mar 2019 17:13:54 +0000 (18:13 +0100)
Whenever a void* pointer changes to a T* pointer, we already consider
that change to be ABI-compatible.  The issue though is that we don't
detect the case of foo* changing into T* where foo is typedef void
foo.  This patch fixes that.

* include/abg-ir.h (is_void_type): Add a new overload that takes
type_base*.
* src/abg-ir.cc (is_void_type): Define the new overload that takes
type_base*.
(is_void_pointer_type): Look through typedefs in
the pointed-to type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-ir.h
src/abg-ir.cc

index 55452ec18100331014214ed6ef596dacbd3a48af..f35cde675756635d1e4a6951b74ba1c16a527e25 100644 (file)
@@ -175,6 +175,9 @@ public:
   bool
   is_void_type(const type_base_sptr&) const;
 
+  bool
+  is_void_type(const type_base*) const;
+
   bool
   is_variadic_parameter_type(const type_base*) const;
 
index f264be1583ffa3c2b552ddb51d24eb6853b6d9fa..af6fc8159d9f12cd2c19dafc017637d822d04229 100644 (file)
@@ -2590,6 +2590,21 @@ environment::is_void_type(const type_base_sptr& t) const
   return t.get() == get_void_type().get();
 }
 
+/// Test if a given type is a void type as defined in the current
+/// environment.
+///
+/// @param t the type to consider.
+///
+/// @return true iff @p t is a void type as defined in the current
+/// environment.
+bool
+environment::is_void_type(const type_base* t) const
+{
+  if (!t)
+    return false;
+  return t == get_void_type().get();
+}
+
 /// Test if a type is a variadic parameter type as defined in the
 /// current environment.
 ///
@@ -7080,8 +7095,11 @@ is_void_pointer_type(const type_base* type)
   if (!t)
     return 0;
 
-  if (t->get_environment()->is_void_type(t->get_pointed_to_type()))
-    return t;
+  // Look through typedefs in the pointed-to type as well.
+  type_base * ty = t->get_pointed_to_type().get();
+  ty = peel_qualified_or_typedef_type(ty);
+  if (ty->get_environment()->is_void_type(ty))
+    return ty;
 
   return 0;
 }
This page took 0.07066 seconds and 5 git commands to generate.