From patchwork Thu Jun 18 14:11:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 39670 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B77B9387086A; Thu, 18 Jun 2020 14:11:20 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by sourceware.org (Postfix) with ESMTPS id D8094387085C for ; Thu, 18 Jun 2020 14:11:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D8094387085C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dodji@seketeli.org X-Originating-IP: 91.166.131.130 Received: from localhost (91-166-131-130.subs.proxad.net [91.166.131.130]) (Authenticated sender: dodj@seketeli.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4ACEEE000C for ; Thu, 18 Jun 2020 14:11:16 +0000 (UTC) Received: by localhost (Postfix, from userid 1001) id 45ED11A07AC; Thu, 18 Jun 2020 16:11:15 +0200 (CEST) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH] Bug 26127 - abidw --annotate emits incomplete function types Organization: Me, myself and I X-Operating-System: Red Hat Enterprise Linux Server 7.8 X-URL: http://www.seketeli.net/~dodji Date: Thu, 18 Jun 2020 16:11:15 +0200 Message-ID: <86r1ucea64.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Hello, When we get the qualified name of a pointer type, the result is cached so that subsequent invocations of the getter yields a faster result. When the pointed-to type is not yet fully constructed at the time of the first invocation of the getter of the qualified name, what is cached is the name of the pointer to a non-yet fully qualified type. Then after the pointed-to type is fully constructed (and canonicalized), the pointer type also becomes canonicalized (in that order) and thus, the cache needs to be invalidated so that the qualified name of the pointer to the fully qualified type is cached again by a subsequent invocation of the getter. The problem in this problem report is that the cache doesn't get invalidated when the pointer type is canonicalized. This patch fixes that. A similar issue exists with reference and qualified types so the patch addresses it for those types as well. * include/abg-ir.h (decl_base::clear_qualified_name): Declare new protected member function. ({pointer_type_def, reference_type_def, qualified_type_def, function_type}::on_canonical_type_set): Declare virtual member functions. * src/abg-ir.cc (decl_base::clear_qualified_name): Define new protected member function. ({pointer_type_def, reference_type_def, qualified_type_def, function_type}::on_canonical_type_set): Define virtual member functions. * tests/data/test-annotate/test17-pr19027.so.abi: Adjust. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. Signed-off-by: Dodji Seketeli Applied to master. --- include/abg-ir.h | 13 +++++ src/abg-ir.cc | 56 ++++++++++++++++++++++ tests/data/test-annotate/test17-pr19027.so.abi | 6 +-- .../test18-pr19037-libvtkRenderingLIC-6.1.so.abi | 6 +-- .../test20-pr19025-libvtkParallelCore-6.1.so.abi | 6 +-- 5 files changed, 78 insertions(+), 9 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index ebcc4b8..d81de21 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -1392,6 +1392,9 @@ protected: peek_qualified_name() const; void + clear_qualified_name(); + + void set_qualified_name(const interned_string&) const; const interned_string& @@ -2024,6 +2027,7 @@ class qualified_type_def : public virtual type_base, public virtual decl_base protected: string build_name(bool, bool internal = false) const; + virtual void on_canonical_type_set(); public: @@ -2126,6 +2130,9 @@ class pointer_type_def : public virtual type_base, public virtual decl_base // Forbidden. pointer_type_def(); +protected: + virtual void on_canonical_type_set(); + public: /// A hasher for instances of pointer_type_def @@ -2180,6 +2187,9 @@ class reference_type_def : public virtual type_base, public virtual decl_base // Forbidden. reference_type_def(); +protected: + virtual void on_canonical_type_set(); + public: /// Hasher for intances of reference_type_def. @@ -3068,6 +3078,9 @@ class function_type : public virtual type_base struct priv; typedef shared_ptr priv_sptr; +protected: + virtual void on_canonical_type_set(); + public: /// Hasher for an instance of function_type struct hash; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 217d42d..da3716d 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -3535,6 +3535,15 @@ const interned_string& decl_base::peek_qualified_name() const {return priv_->qualified_name_;} +/// Clear the qualified name of this decl. +/// +/// This is useful to ensure that the cache for the qualified name of +/// the decl is refreshed right after type canonicalization, for +/// instance. +void +decl_base::clear_qualified_name() +{priv_->qualified_name_.clear();} + /// Setter for the qualified name. /// /// @param n the new qualified name. @@ -13105,6 +13114,17 @@ qualified_type_def::build_name(bool fully_qualified, bool internal) const fully_qualified, internal); } +/// This function is automatically invoked whenever an instance of +/// this type is canonicalized. +/// +/// It's an overload of the virtual type_base::on_canonical_type_set. +/// +/// We put here what is thus meant to be executed only at the point of +/// type canonicalization. +void +qualified_type_def::on_canonical_type_set() +{clear_qualified_name();} + /// Constructor of the qualified_type_def /// /// @param type the underlying type @@ -13502,6 +13522,17 @@ struct pointer_type_def::priv {} }; //end struct pointer_type_def +/// This function is automatically invoked whenever an instance of +/// this type is canonicalized. +/// +/// It's an overload of the virtual type_base::on_canonical_type_set. +/// +/// We put here what is thus meant to be executed only at the point of +/// type canonicalization. +void +pointer_type_def::on_canonical_type_set() +{clear_qualified_name();} + pointer_type_def::pointer_type_def(const type_base_sptr& pointed_to, size_t size_in_bits, size_t align_in_bits, @@ -13783,6 +13814,17 @@ operator!=(const pointer_type_def_sptr& l, const pointer_type_def_sptr& r) // +/// This function is automatically invoked whenever an instance of +/// this type is canonicalized. +/// +/// It's an overload of the virtual type_base::on_canonical_type_set. +/// +/// We put here what is thus meant to be executed only at the point of +/// type canonicalization. +void +reference_type_def::on_canonical_type_set() +{clear_qualified_name();} + reference_type_def::reference_type_def(const type_base_sptr pointed_to, bool lvalue, size_t size_in_bits, @@ -16232,6 +16274,20 @@ struct function_type::priv } };// end struc function_type::priv +/// This function is automatically invoked whenever an instance of +/// this type is canonicalized. +/// +/// It's an overload of the virtual type_base::on_canonical_type_set. +/// +/// We put here what is thus meant to be executed only at the point of +/// type canonicalization. +void +function_type::on_canonical_type_set() +{ + priv_->cached_name_.clear(); + priv_->internal_cached_name_.clear(); +} + /// The most straightforward constructor for the function_type class. /// /// @param return_type the return type of the function type. diff --git a/tests/data/test-annotate/test17-pr19027.so.abi b/tests/data/test-annotate/test17-pr19027.so.abi index 4937e36..42d5f81 100644 --- a/tests/data/test-annotate/test17-pr19027.so.abi +++ b/tests/data/test-annotate/test17-pr19027.so.abi @@ -36663,7 +36663,7 @@ - + @@ -36785,7 +36785,7 @@ - + @@ -36802,7 +36802,7 @@ - + diff --git a/tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi b/tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi index 0f42c9c..d5ab3e3 100644 --- a/tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi +++ b/tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi @@ -5095,11 +5095,11 @@ - + - + @@ -8298,7 +8298,7 @@ - + diff --git a/tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi b/tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi index 14178e8..dc009c8 100644 --- a/tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi +++ b/tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi @@ -6555,7 +6555,7 @@ - + @@ -7693,11 +7693,11 @@ - + - +