Better detection of void* to something* change

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>
This commit is contained in:
Dodji Seketeli 2019-03-21 18:08:59 +01:00
parent fc02416b28
commit 0036d0448e
2 changed files with 23 additions and 2 deletions

View 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;

View 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;
}