From 39b2e8b7d58681fde3ce6d845c7447a547e1c7a1 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 19 Aug 2015 12:06:24 +0200 Subject: [PATCH] Make decl_base::get_qualified_name() work when decl context changes decl_base::get_qualified_name() caches its result. So when it's first called on a decl that is not added to a scope, what is returned is a non-qualified name. Which is all right. But then when the decl is later added to a scope, the cached result of decl_base::get_qualified_name() is not longer correct. This patch resets the cache of decl_base::get_qualified_name() when the decl gets added to a new scope. * include/abg-ir.h (class decl_base): Make class scope_decl a friend of decl_base. (type_base::priv_): Make this protected, rather than private. * src/abg-ir.cc (scope_decl::add_member_decl) (scope_decl::insert_member_decl): Reset the cache of the result of decl_base::get_qualified_name(). * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. Signed-off-by: Dodji Seketeli --- include/abg-ir.h | 4 + src/abg-ir.cc | 3 + .../test-abidiff/test-PR18791-report0.txt | 174 +++++++++--------- 3 files changed, 94 insertions(+), 87 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index 39e09389..9b9f63a4 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -907,6 +907,8 @@ public: set_member_function_is_virtual(function_decl&, bool); friend class class_decl; + + friend class scope_decl; };// end class decl_base bool @@ -1064,8 +1066,10 @@ class type_base : public virtual type_or_decl_base struct priv; typedef shared_ptr priv_sptr; +protected: priv_sptr priv_; +private: // Forbid this. type_base(); diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 7f319490..80e95d14 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -3029,6 +3029,7 @@ scope_decl::add_member_decl(const shared_ptr member) if (scope_decl_sptr m = dynamic_pointer_cast(member)) member_scopes_.push_back(m); + member->priv_->qualified_name_.clear(); return member; } @@ -3048,6 +3049,8 @@ scope_decl::insert_member_decl(const decl_base_sptr member, if (scope_decl_sptr m = dynamic_pointer_cast(member)) member_scopes_.push_back(m); + + member->priv_->qualified_name_.clear(); return member; } diff --git a/tests/data/test-abidiff/test-PR18791-report0.txt b/tests/data/test-abidiff/test-PR18791-report0.txt index 1116da9c..1cb9a9b0 100644 --- a/tests/data/test-abidiff/test-PR18791-report0.txt +++ b/tests/data/test-abidiff/test-PR18791-report0.txt @@ -11,65 +11,95 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 19 functions with some indirect sub-type change: - [C]'method sigc::internal::trackable_callback_list* sigc::trackable::callback_list()' has some indirect sub-type changes: + [C]'method sigc::connection::connection(const sigc::connection&)' has some indirect sub-type changes: + parameter 1 of type 'const sigc::connection&' has sub-type changes: + in referenced type 'const sigc::connection': + in unqualified underlying type 'struct sigc::connection': + 1 data member change: + type of 'sigc::slot_base* sigc::connection::slot_' changed: + in pointed to type 'class sigc::slot_base': + 1 data member change: + type of 'sigc::slot_base::rep_type* sigc::slot_base::rep_' changed: + in pointed to type 'typedef sigc::slot_base::rep_type': + underlying type 'struct sigc::internal::slot_rep' changed: + 1 base class change: + 'struct sigc::trackable' changed: + 1 data member change: + type of 'sigc::internal::trackable_callback_list* sigc::trackable::callback_list_' changed: + in pointed to type 'struct sigc::internal::trackable_callback_list': + type size changed from 192 to 256 bits + 2 data member changes: + type of 'sigc::internal::trackable_callback_list::callback_list sigc::internal::trackable_callback_list::callbacks_' changed: + underlying type 'class std::list >' changed: + type name changed from 'std::list >' to 'std::__cxx11::list >' + type size changed from 128 to 192 bits + 1 base class deletion: + class std::_List_base > + 1 base class insertion: + class std::__cxx11::_List_base > + + 'bool sigc::internal::trackable_callback_list::clearing_' offset changed from 128 to 192 (in bits) + + + + + + [C]'method sigc::connection::connection(sigc::slot_base&)' has some indirect sub-type changes: + parameter 1 of type 'sigc::slot_base&' has sub-type changes: + referenced type 'class sigc::slot_base' changed, as reported earlier + + [C]'method sigc::connection& sigc::connection::operator=(const sigc::connection&)' has some indirect sub-type changes: return type changed: - in pointed to type 'struct sigc::internal::trackable_callback_list': - type size changed from 192 to 256 bits - 2 data member changes: - type of 'sigc::internal::trackable_callback_list::callback_list sigc::internal::trackable_callback_list::callbacks_' changed: - underlying type 'class std::list >' changed: - type name changed from 'std::list >' to 'std::__cxx11::list >' - type size changed from 128 to 192 bits - 1 base class deletion: - class std::_List_base > - 1 base class insertion: - class std::__cxx11::_List_base > - - 'bool sigc::internal::trackable_callback_list::clearing_' offset changed from 128 to 192 (in bits) + referenced type 'struct sigc::connection' changed, as reported earlier + parameter 1 of type 'const sigc::connection&' has sub-type changes: + in referenced type 'const sigc::connection': + unqualified underlying type 'struct sigc::connection' changed, as reported earlier - [C]'method sigc::signal_base::iterator_type sigc::signal_base::connect(const sigc::slot_base&)' has some indirect sub-type changes: + [C]'method void sigc::connection::set_slot(sigc::slot_base*)' has some indirect sub-type changes: + parameter 1 of type 'sigc::slot_base*' has sub-type changes: + pointed to type 'class sigc::slot_base' changed, as reported earlier + + [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::connect(const sigc::slot_base&)' has some indirect sub-type changes: return type changed: - underlying type 'typedef sigc::internal::signal_impl::iterator_type' changed: - underlying type 'typedef std::list >::iterator' changed: - typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator + underlying type 'typedef std::list >::iterator' changed: + typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator parameter 1 of type 'const sigc::slot_base&' has sub-type changes: in referenced type 'const sigc::slot_base': - in unqualified underlying type 'class sigc::slot_base': - 1 data member change: - type of 'sigc::slot_base::rep_type* sigc::slot_base::rep_' changed: - in pointed to type 'typedef sigc::slot_base::rep_type': - underlying type 'struct sigc::internal::slot_rep' changed: - 1 base class change: - 'struct sigc::trackable' changed: - 1 data member change: - type of 'sigc::internal::trackable_callback_list* sigc::trackable::callback_list_' changed: - pointed to type 'struct sigc::internal::trackable_callback_list' changed, as reported earlier + unqualified underlying type 'class sigc::slot_base' changed, as reported earlier + [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::erase(sigc::internal::signal_impl::iterator_type)' has some indirect sub-type changes: + return type changed: + underlying type 'typedef std::list >::iterator' changed: + typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator + parameter 1 of type 'typedef sigc::internal::signal_impl::iterator_type' changed: + underlying type 'typedef std::list >::iterator' changed: + typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::connect(const sigc::slot_base&)' has some indirect sub-type changes: + [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::insert(sigc::internal::signal_impl::iterator_type, const sigc::slot_base&)' has some indirect sub-type changes: return type changed: underlying type 'typedef std::list >::iterator' changed: typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - parameter 1 of type 'const sigc::slot_base&' has sub-type changes: + parameter 1 of type 'typedef sigc::internal::signal_impl::iterator_type' changed: + underlying type 'typedef std::list >::iterator' changed: + typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator + + parameter 2 of type 'const sigc::slot_base&' has sub-type changes: in referenced type 'const sigc::slot_base': unqualified underlying type 'class sigc::slot_base' changed, as reported earlier - [C]'method sigc::connection::connection(const sigc::connection&)' has some indirect sub-type changes: - parameter 1 of type 'const sigc::connection&' has sub-type changes: - in referenced type 'const sigc::connection': - in unqualified underlying type 'struct sigc::connection': - 1 data member change: - type of 'sigc::slot_base* sigc::connection::slot_' changed: - pointed to type 'class sigc::slot_base' changed, as reported earlier - + [C]'method sigc::signal_base::iterator_type sigc::signal_base::connect(const sigc::slot_base&)' has some indirect sub-type changes: + return type changed: + underlying type 'typedef sigc::internal::signal_impl::iterator_type' changed: + underlying type 'typedef std::list >::iterator' changed: + typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - [C]'method sigc::connection::connection(sigc::slot_base&)' has some indirect sub-type changes: - parameter 1 of type 'sigc::slot_base&' has sub-type changes: - referenced type 'class sigc::slot_base' changed, as reported earlier + parameter 1 of type 'const sigc::slot_base&' has sub-type changes: + in referenced type 'const sigc::slot_base': + unqualified underlying type 'class sigc::slot_base' changed, as reported earlier [C]'method sigc::signal_base::iterator_type sigc::signal_base::erase(sigc::signal_base::iterator_type)' has some indirect sub-type changes: return type changed: @@ -83,16 +113,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::erase(sigc::internal::signal_impl::iterator_type)' has some indirect sub-type changes: - return type changed: - underlying type 'typedef std::list >::iterator' changed: - typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - - parameter 1 of type 'typedef sigc::internal::signal_impl::iterator_type' changed: - underlying type 'typedef std::list >::iterator' changed: - typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - - [C]'method sigc::internal::signal_impl* sigc::signal_base::impl()' has some indirect sub-type changes: return type changed: in pointed to type 'struct sigc::internal::signal_impl': @@ -122,26 +142,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable in referenced type 'const sigc::slot_base': unqualified underlying type 'class sigc::slot_base' changed, as reported earlier - [C]'method sigc::internal::signal_impl::iterator_type sigc::internal::signal_impl::insert(sigc::internal::signal_impl::iterator_type, const sigc::slot_base&)' has some indirect sub-type changes: - return type changed: - underlying type 'typedef std::list >::iterator' changed: - typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - - parameter 1 of type 'typedef sigc::internal::signal_impl::iterator_type' changed: - underlying type 'typedef std::list >::iterator' changed: - typedef name changed from std::list >::iterator to std::__cxx11::list >::iterator - - parameter 2 of type 'const sigc::slot_base&' has sub-type changes: - in referenced type 'const sigc::slot_base': - unqualified underlying type 'class sigc::slot_base' changed, as reported earlier - - [C]'method sigc::connection& sigc::connection::operator=(const sigc::connection&)' has some indirect sub-type changes: - return type changed: - referenced type 'struct sigc::connection' changed, as reported earlier - parameter 1 of type 'const sigc::connection&' has sub-type changes: - in referenced type 'const sigc::connection': - unqualified underlying type 'struct sigc::connection' changed, as reported earlier - [C]'method sigc::signal_base& sigc::signal_base::operator=(const sigc::signal_base&)' has some indirect sub-type changes: return type changed: in referenced type 'struct sigc::signal_base': @@ -157,6 +157,11 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable in referenced type 'const sigc::signal_base': unqualified underlying type 'struct sigc::signal_base' changed, as reported earlier + [C]'method sigc::signal_base::signal_base(const sigc::signal_base&)' has some indirect sub-type changes: + parameter 1 of type 'const sigc::signal_base&' has sub-type changes: + in referenced type 'const sigc::signal_base': + unqualified underlying type 'struct sigc::signal_base' changed, as reported earlier + [C]'method sigc::slot_base& sigc::slot_base::operator=(const sigc::slot_base&)' has some indirect sub-type changes: return type changed: referenced type 'class sigc::slot_base' changed, as reported earlier @@ -164,22 +169,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable in referenced type 'const sigc::slot_base': unqualified underlying type 'class sigc::slot_base' changed, as reported earlier - [C]'method sigc::trackable& sigc::trackable::operator=(const sigc::trackable&)' has some indirect sub-type changes: - return type changed: - referenced type 'struct sigc::trackable' changed, as reported earlier - parameter 1 of type 'const sigc::trackable&' has sub-type changes: - in referenced type 'const sigc::trackable': - unqualified underlying type 'struct sigc::trackable' changed, as reported earlier - - [C]'method void sigc::connection::set_slot(sigc::slot_base*)' has some indirect sub-type changes: - parameter 1 of type 'sigc::slot_base*' has sub-type changes: - pointed to type 'class sigc::slot_base' changed, as reported earlier - - [C]'method sigc::signal_base::signal_base(const sigc::signal_base&)' has some indirect sub-type changes: - parameter 1 of type 'const sigc::signal_base&' has sub-type changes: - in referenced type 'const sigc::signal_base': - unqualified underlying type 'struct sigc::signal_base' changed, as reported earlier - [C]'method sigc::slot_base::slot_base(sigc::slot_base::rep_type*)' has some indirect sub-type changes: parameter 1 of type 'sigc::slot_base::rep_type*' has sub-type changes: in pointed to type 'typedef sigc::slot_base::rep_type': @@ -190,6 +179,17 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable in referenced type 'const sigc::slot_base': unqualified underlying type 'class sigc::slot_base' changed, as reported earlier + [C]'method sigc::internal::trackable_callback_list* sigc::trackable::callback_list()' has some indirect sub-type changes: + return type changed: + pointed to type 'struct sigc::internal::trackable_callback_list' changed, as reported earlier + + [C]'method sigc::trackable& sigc::trackable::operator=(const sigc::trackable&)' has some indirect sub-type changes: + return type changed: + referenced type 'struct sigc::trackable' changed, as reported earlier + parameter 1 of type 'const sigc::trackable&' has sub-type changes: + in referenced type 'const sigc::trackable': + unqualified underlying type 'struct sigc::trackable' changed, as reported earlier + [C]'method sigc::trackable::trackable(const sigc::trackable&)' has some indirect sub-type changes: parameter 1 of type 'const sigc::trackable&' has sub-type changes: in referenced type 'const sigc::trackable': -- 2.43.5