From ce1df6ff330611bd2cf1fb406eef09081864f769 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Mon, 7 Apr 2014 09:54:52 +0200 Subject: [PATCH] Look through typedefs when setting SIZE_OR_OFFSET_CHANGE_CATEGORY * include/abg-fwd.h (is_class_type): Declare new functions. * src/abg-comp-filter.cc (harmful_filter::visit): Use the above to convert a type into a class. * src/abg-ir.cc (is_class_type): Define the new function. Signed-off-by: Dodji Seketeli --- include/abg-fwd.h | 6 ++++++ src/abg-comp-filter.cc | 4 ++-- src/abg-ir.cc | 27 +++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/abg-fwd.h b/include/abg-fwd.h index 9b75876e..b0eea971 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -158,6 +158,12 @@ is_typedef(const shared_ptr); shared_ptr is_typedef(const shared_ptr); +shared_ptr +is_class_type(const shared_ptr); + +shared_ptr +is_class_type(const shared_ptr); + shared_ptr look_through_decl_only_class(shared_ptr); diff --git a/src/abg-comp-filter.cc b/src/abg-comp-filter.cc index 8cce8f20..6fa572e8 100644 --- a/src/abg-comp-filter.cc +++ b/src/abg-comp-filter.cc @@ -233,8 +233,8 @@ harmful_filter::visit(diff* d, bool pre) if (type_size_changed(f, s) || data_member_offset_changed(f, s)) { - class_decl_sptr cl1 = dynamic_pointer_cast(f), - cl2 = dynamic_pointer_cast(s); + class_decl_sptr cl1 = is_class_type(f), + cl2 = is_class_type(s); if ((cl1 && cl1->get_is_declaration_only()) || (cl2 && cl2->get_is_declaration_only())) // But do not compare a declaration-only class to another diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 68c3dbcf..82b8bd57 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1648,6 +1648,33 @@ typedef_decl_sptr is_typedef(const decl_base_sptr d) {return is_typedef(is_type(d));} +/// Test whether a type is a class. +/// +/// This function looks through typedefs. +/// +/// @parm t the type to consider. +/// +/// @return the class_decl if @p t is a class_decl or null otherwise. +class_decl_sptr +is_class_type(const type_base_sptr t) +{ + if (!t) + return class_decl_sptr(); + type_base_sptr ty = strip_typedef(t); + return dynamic_pointer_cast(ty); +} + +/// Test whether a type is a class. +/// +/// This function looks through typedefs. +/// +/// @parm d the declaration of the type to consider. +/// +/// @return the class_decl if @p d is a class_decl or null otherwise. +class_decl_sptr +is_class_type(const decl_base_sptr d) +{return is_class_type(is_type(d));} + /// If a class is a decl-only class, get its definition. Otherwise, /// just return the initial class. ///