From patchwork Fri Jun 3 13:09:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 54778 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 CBB1C38207F1 for ; Fri, 3 Jun 2022 13:09:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBB1C38207F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654261785; bh=XSEfdippe3hT5qCBLdFWf6DpDqMPEbpyDQe6WhTR8oE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=VRBC+Z+yaGc+UUnlw+aEjkEVLxe0UDkqwSVUkSk6WSoxm2HIYoOKOvIHknzEMzGQm 9Fo9QvMLSq16QBtaHi18E64oAE24g47/mRFvtyVYJTLA0QkyivLMZYMHtrWzMysABT 93Ot3CCSx7jt23271j0EAMJ5G2CMqPiWB02TRJ4E= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by sourceware.org (Postfix) with ESMTPS id 4403E38207E7 for ; Fri, 3 Jun 2022 13:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4403E38207E7 Received: by mail-ed1-x54a.google.com with SMTP id g7-20020a056402424700b0042dee9d11d0so5425466edb.3 for ; Fri, 03 Jun 2022 06:09:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=XSEfdippe3hT5qCBLdFWf6DpDqMPEbpyDQe6WhTR8oE=; b=KgGRxaJeMfgaXK8ROIWXVNRWVOsy7fD5L4uTlO1Ht8aBckHcfJRrDqDL+3JLWJH8DA O/uMeN0MiO5LTef910I9iXScsIWlM37aEt7ah5xgCOKZKWamS3f7BNr4BLlynRktZcT0 msEuHk/yLoD58Q7Bovf0bJ5Nmft1lMmn8NJEluNVIYaKpEujh0eKafml9fDMNxYEl1Ay KmdfYkqSdBWJ7O1kvyAu14qyuYtxd9xHsyFDcRxPV/4HxZEPztM10ioB92VoxqAWyVBs 6aGyc9ia//T54FTPB85fQmvaALBTuGva43P1LxNhcXDX7FiysFr5/g2jg/wuOqDC1ViE JTgw== X-Gm-Message-State: AOAM533o9B2sRozPhlNv0Vs3GZwvhXaNUwKmPV9ALozjq6O65K9B32uh xJDxDYQZ90Wc1tKAdhnHczGu9fvY8pvkFyGYMALQF7M7kKNkNzWHxhKnPx/6zkZDFMYabPj/hHX o2+E+XbskcUtDZO5DQN4I6cBSpEN14DgaS8oc8uxBhScUvAYlh84V0z0V7H/syU3lR12U2gA= X-Google-Smtp-Source: ABdhPJyYOV7XZE05wUIrXxmrKldV3512HA8g38xkeJ+KsvE3SaZB6+ZpeXEpAHlfXe8ENS8B/D2ASGHc57qWYg== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:209:758b:79ee:2dff:316d]) (user=gprocida job=sendgmr) by 2002:a05:6402:1d4a:b0:42e:93de:17f4 with SMTP id dz10-20020a0564021d4a00b0042e93de17f4mr2510418edb.8.1654261762850; Fri, 03 Jun 2022 06:09:22 -0700 (PDT) Date: Fri, 3 Jun 2022 14:09:10 +0100 Message-Id: <20220603130910.3039296-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.255.ge46751e96f-goog Subject: [PATCH] XML writer: unify type emission tracking To: libabigail@sourceware.org X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, kernel-team@android.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Empirically, the tracking of declaration-only type emission no longer seems to make any difference. It is removed here. * src/abg-writer.cc (write_context): Remove the m_emitted_decl_only_set member. (write_context::has_non_emitted_referenced_types): Remove the calls to decl_only_type_is_emitted. (write_context::record_decl_only_type_as_emitted): Removed. (write_context::decl_only_type_is_emitted): Ditto. (write_context::get_emitted_decl_only_types_set): Ditto. (referenced_type_should_be_emitted): Remove the calls to decl_only_type_is_emitted. (write_class_decl): Just call record_type_as_emitted. (write_union_decl): Ditto. (write_enum_type_decl): Not changed, but now all 3 functions have the same behaviour. (write_canonical_type_ids): Remove the call to get_emitted_decl_only_types_set. Signed-off-by: Giuliano Procida --- src/abg-writer.cc | 90 +++++------------------------------------------ 1 file changed, 8 insertions(+), 82 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 7802128d..3f50a900 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -143,7 +143,6 @@ class write_context mutable type_ptr_map m_type_id_map; mutable unordered_set m_used_type_id_hashes; mutable type_ptr_set_type m_emitted_type_set; - type_ptr_set_type m_emitted_decl_only_set; // A map of types that are referenced by emitted pointers, // references or typedefs type_ptr_set_type m_referenced_types_set; @@ -491,18 +490,15 @@ public: has_non_emitted_referenced_types() const { for (const auto t : get_referenced_types()) - if (!type_is_emitted(t) - && !decl_only_type_is_emitted(t)) - return false; + if (!type_is_emitted(t)) + return false; for (const auto t : get_referenced_non_canonical_types()) - if (!type_is_emitted(t) - && !decl_only_type_is_emitted(t)) - return false; + if (!type_is_emitted(t)) + return false; for (const auto t : get_referenced_non_canonical_types()) - if (!type_is_emitted(t) - && !decl_only_type_is_emitted(t)) + if (!type_is_emitted(t)) return false; return true; @@ -741,55 +737,6 @@ public: return m_emitted_decls_set.find(irepr) != m_emitted_decls_set.end(); } - /// Record a declaration-only class as being emitted. - /// - /// For now, this function expects a declaration-only class, - /// otherwise, it aborts. - /// - /// @param t the declaration-only class to report as emitted. - void - record_decl_only_type_as_emitted(type_base* t) - { - class_or_union* cl = is_class_or_union_type(t); - ABG_ASSERT(cl && cl->get_is_declaration_only()); - m_emitted_decl_only_set.insert(t); - } - - /// Record a declaration-only class as being emitted. - /// - /// For now, this function expects a declaration-only class, - /// otherwise, it aborts. - /// - /// @param t the declaration-only class to report as emitted. - void - record_decl_only_type_as_emitted(const type_base_sptr& t) - {record_decl_only_type_as_emitted(t.get());} - - /// Test if a declaration-only class has been emitted. - /// - /// @param t the declaration-only class to test for. - /// - /// @return true iff the declaration-only class @p t has been - /// emitted. - bool - decl_only_type_is_emitted(const type_base* t) const - { - type_ptr_set_type::const_iterator i = m_emitted_decl_only_set.find(t); - if (i == m_emitted_decl_only_set.end()) - return false; - return true; - } - - /// Test if a declaration-only class has been emitted. - /// - /// @param t the declaration-only class to test for. - /// - /// @return true iff the declaration-only class @p t has been - /// emitted. - bool - decl_only_type_is_emitted(const type_base_sptr& t) const - {return decl_only_type_is_emitted(t.get());} - /// Record a declaration as emitted in the abixml output. /// /// @param decl the decl to consider. @@ -808,13 +755,6 @@ public: get_emitted_types_set() const {return m_emitted_type_set;} - /// Get the set of types that have been emitted. - /// - /// @return the set of types that have been emitted. - const type_ptr_set_type& - get_emitted_decl_only_types_set() const - {return m_emitted_decl_only_set;} - /// Clear the map that contains the IDs of the types that has been /// recorded as having been written out to the XML output. void @@ -2246,8 +2186,7 @@ referenced_type_should_be_emitted(const type_base *t, if ((tu_is_last || (t->get_translation_unit() && (t->get_translation_unit()->get_absolute_path() == tu.get_absolute_path()))) - && !ctxt.type_is_emitted(t) - && !ctxt.decl_only_type_is_emitted(t)) + && !ctxt.type_is_emitted(t)) return true; return false; } @@ -3845,12 +3784,7 @@ write_class_decl(const class_decl_sptr& d, o << "\n"; } - // We allow several *declarations* of the same class in the corpus, - // but only one definition. - if (!decl->get_is_declaration_only()) - ctxt.record_type_as_emitted(decl); - else - ctxt.record_decl_only_type_as_emitted(decl); + ctxt.record_type_as_emitted(decl); return true; } @@ -4005,12 +3939,7 @@ write_union_decl(const union_decl_sptr& d, o << "\n"; } - // We allow several *declarations* of the same union in the corpus, - // but only one definition. - if (!decl->get_is_declaration_only()) - ctxt.record_type_as_emitted(decl); - else - ctxt.record_decl_only_type_as_emitted(decl); + ctxt.record_type_as_emitted(decl); return true; } @@ -4848,9 +4777,6 @@ write_canonical_type_ids(xml_writer::write_context& ctxt, ostream& o) for (const auto &type : ctxt.get_emitted_types_set()) write_type_record(ctxt, type, o); - for (const auto &type : ctxt.get_emitted_decl_only_types_set()) - write_type_record(ctxt, type, o); - o << "\n"; }