From 0036d0448ed45af7de7f0f461241040f7d0974f4 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 21 Mar 2019 18:08:59 +0100 Subject: [PATCH] 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 --- include/abg-ir.h | 3 +++ src/abg-ir.cc | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index 55452ec1..f35cde67 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -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; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index f264be15..af6fc815 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -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; }