From 85feb73bad0783ece888bf625077f1d660f4e378 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 26 Aug 2015 12:06:46 +0200 Subject: [PATCH] Accept base classes which types are compatible with class type Until now, a base class had to be a class itself. It couldn't be a typedef to a class, for instance. Clang's debug info does allow base classes which are compatible with classes (e.g, typedefs of classes), which is correct. We ought to accept that. Hence this patch. * include/abg-fwd.h (is_compatible_with_class_type): Declare a new overload. * src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Rather than requiring that base classes be of class type, just require that they be compatible with class types. * src/abg-ir.cc (is_compatible_with_class_type): Define a new overload. Signed-off-by: Dodji Seketeli --- include/abg-fwd.h | 3 +++ src/abg-dwarf-reader.cc | 2 +- src/abg-ir.cc | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/abg-fwd.h b/include/abg-fwd.h index 0d254473..3bd56009 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -231,6 +231,9 @@ is_class_type(const shared_ptr); shared_ptr is_compatible_with_class_type(const shared_ptr); +shared_ptr +is_compatible_with_class_type(const shared_ptr); + pointer_type_def* is_pointer_type(type_base*); diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index d3e05138..73dbd9bc 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -6646,7 +6646,7 @@ build_class_type_and_add_to_ir(read_context& ctxt, type_die_is_in_alternate_debug_info, called_from_public_decl, where_offset); - class_decl_sptr b = dynamic_pointer_cast(base_type); + class_decl_sptr b = is_compatible_with_class_type(base_type); if (!b) continue; if (lookup_type_in_scope(base_type->get_name(), result)) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index bf815e66..be27b3ce 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -4385,6 +4385,15 @@ is_compatible_with_class_type(const type_base_sptr t) return is_class_type(ty); } +/// Test if 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_compatible_with_class_type(const decl_base_sptr t) +{return is_compatible_with_class_type(is_type(t));} + /// Test whether a type is a class. /// /// @parm t the type to consider. -- 2.43.5