From patchwork Mon Jun 22 16:06:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39762 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 BFD71383E802; Mon, 22 Jun 2020 16:06:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFD71383E802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1592841989; bh=lk6V/NoJmgVrXjihh1stdK2ycCPFTB6s9wnROqNMG/U=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=AVS2eR/1/b0U7WUFM0AzYy2XOah8ao/hdynPkhsSleru6e5KrKeVQTrt1l2yDqNMU YO4RmPHSKEhul1aMPaEqKoNIheHIV5p6EuBgiDgCjsIP3lJTqnJVc3QM/B5ZAgb8dZ P0cHLWqRJhGyTeXqUjIbdQfyf9dNNjKGDdTFjOrs= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by sourceware.org (Postfix) with ESMTPS id E269C383E802 for ; Mon, 22 Jun 2020 16:06:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E269C383E802 Received: by mail-qv1-xf4a.google.com with SMTP id g13so6252355qvp.5 for ; Mon, 22 Jun 2020 09:06:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=lk6V/NoJmgVrXjihh1stdK2ycCPFTB6s9wnROqNMG/U=; b=QypoSp3d/daeT4xD1XcUoh/ZatENaNu+nhbcA3RsfAfL3C8wyBR734/T58RRH9PX14 V2zdzNc8eJLklxqwLbhq6wY1d6Q6m8UhhK1lgMsC4MWqgAUbdOVSsayQqzXTguwalEtg uXfBvEMBcKTkYP717DRf5auK0JK1yJQU1gHRkr4S/acqlOKcmyW31Kt0ob9TcoLB9K+S 4j7PAW2dj+vTb7RGu0aOWAhfw324MF4FXa5A+Tk0FvIt1/DjdfZW03buqIs6J1LQ0Qns U3bCkAjTZ5XW80DXVFc0IgIWTvz0LQQ2hTrBRR55+dSAV4tgomo0R1wTMA+mxEszfbDB GQFg== X-Gm-Message-State: AOAM533p4P/L2E9XIBeiGashjz/hkX54k4kGSan0OSNxPdJmx2BBynBo Ywhp+7eDEkKcMA+4eiaeVSyytuPKMtBVWwH6sOG5UnOJMWD8useqSl9h76URABxHF3F0ktIR3it 2Nifyj6CBW7u7qiElXgIfrXOkZbTlb+Uy7fH12BNoLhXMmZwfaK76+NmZYewNiD6KM2IDtso= X-Google-Smtp-Source: ABdhPJy23v/tl3RQum1AnV7U/nWfsQTFBonNjDBRtX8wblTYApRmJgAQbArXsCrqSX6DeWYPMzjjGolFOyjnfQ== X-Received: by 2002:ad4:42a6:: with SMTP id e6mr21717766qvr.170.1592841986318; Mon, 22 Jun 2020 09:06:26 -0700 (PDT) Date: Mon, 22 Jun 2020 17:06:19 +0100 Message-Id: <20200622160619.4154-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.111.gc72c7da667-goog Subject: [PATCH] abg-reader.cc: track WIP types by pointer not name To: libabigail@sourceware.org X-Spam-Status: No, score=-23.3 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, USER_IN_DEF_DKIM_WL 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: , X-Patchwork-Original-From: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, kernel-team@android.com, gprocida@google.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" When reading ABI XML files, the reader needs to construct types progressively as any type may depend on other types and even on itself. Such work-in-progress types are tracked explicitly. The storage used for this is a map from (external, qualified) type name to a count of how many times the type (name) has been seen. However, function type names are invariably stored as "void ()" as they are incomplete at the point they are added to the map. When the reader later attempts to remove the marking they have their proper, different names. In short, the code doesn't do what it's supposed to. This commit changes the map key from string to const type_base*. Equality on type_base_sptr has been defined to be a deep comparison so storing those wouldn't be quite right. Note that this removes some of the call paths that result in incorrect (external) type names being cached (regardless of whether they are actually used). * src/abg-reader.cc (xml_reader::m_wip_types_map): Change type to unordered_map. (xml_reader::mark_type_as_wip): Just increment count of type pointer. (xml_reader::unmark_type_as_wip): Add assertion that type pointer is present. Decrement type pointer count and remove if zero. (xml_reader::is_wip_type): Test if type pointer in map. Signed-off-by: Giuliano Procida --- src/abg-reader.cc | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index eb74659f..fe82f4ec 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -119,7 +119,7 @@ private: unordered_map > m_types_map; unordered_map > m_fn_tmpl_map; unordered_map > m_class_tmpl_map; - unordered_map m_wip_types_map; + abg_compat::unordered_map m_wip_types_map; vector m_types_to_canonicalize; string_xml_node_map m_id_xml_node_map; xml_node_decl_base_sptr_map m_xml_node_decl_map; @@ -534,12 +534,7 @@ public: { if (!t) return; - string qname = get_type_name(t, /*qualified=*/true); - unordered_map::iterator it = m_wip_types_map.find(qname); - if (it == m_wip_types_map.end()) - m_wip_types_map[qname] = 1; - else - ++it->second; + ++(m_wip_types_map[t.get()]); } /// Mark a given class as being *NOT* "Work In Progress" anymore; @@ -551,13 +546,10 @@ public: { if (!t) return; - - string qname = get_type_name(t, /*qualified=*/true); - unordered_map::iterator it = m_wip_types_map.find(qname); - if (it == m_wip_types_map.end()) - return; - if (it->second) - --it->second; + unordered_map::iterator it = + m_wip_types_map.find(t.get()); + ABG_ASSERT(it != m_wip_types_map.end() && it->second > 0); + --it->second; if (it->second == 0) m_wip_types_map.erase(it); } @@ -571,11 +563,7 @@ public: { if (!t) return false; - - string qname = get_type_name(t, /*qualified=*/true); - unordered_map::const_iterator i = - m_wip_types_map.find(qname); - return i != m_wip_types_map.end(); + return m_wip_types_map.count(t.get()); } /// Test if two types are equal, without comparing them structurally.