From patchwork Wed Sep 8 14:24:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 44910 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 9EFA9386197E for ; Wed, 8 Sep 2021 14:25:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9EFA9386197E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631111106; bh=L+WMxE+K1z8Y7xt0fq4IUGqrQs2U+ZBDdHwEC9TxABs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=NWV8WUzuMvXqRnr/4zaeBIfmbkh/ryCaG7exGfoDxigDg+Zz0Dk9swOtFbRkn3p6x 5MOir9uvt6uEsPJKwpAazTXM3Dxw8WWs4O74rnnyLFUoq3jGgjk7PRU64wdye4Q1te NJ1laHOIwcYGZC8cvS7gNUwbS0QqSvBqctcltQK0= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 9486A3858414 for ; Wed, 8 Sep 2021 14:25:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9486A3858414 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-9vcO0ZhFNkGnmaZrrtrXEA-1; Wed, 08 Sep 2021 10:25:01 -0400 X-MC-Unique: 9vcO0ZhFNkGnmaZrrtrXEA-1 Received: by mail-wr1-f70.google.com with SMTP id j1-20020adff541000000b001593715d384so562375wrp.1 for ; Wed, 08 Sep 2021 07:25:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=L+WMxE+K1z8Y7xt0fq4IUGqrQs2U+ZBDdHwEC9TxABs=; b=cQMrrloLbSzuk+c2zH1qwiV25ZxeplYEwg0qzwETuxI+vFfTcTj1YTR32TG3p5apPe 7UUgaiN+jJFjpUu4KZ3Zmkno2VwHqiPxwW7NrOXTbEn0mP/rsZedqShXAn9eOFEOdCHp a1hSlNmWSEtSyl/y5VCY7eLKtjW1dgApNncYr9lDoq635NvwV5aSVFUfJCTCNbTUlx4S Tk1RrlGTHa0W9sHlAMPWG93prJqhJvVTmJgNKqXB4CPwZB9JBC7yzilrxfpuJ6D0riXL Eu0YMdvWnquoniCiMOH9whK03ng12CcByix8iaPHHPvvFvclhP90DZwjxRinkrXacSz3 pM2Q== X-Gm-Message-State: AOAM533jmdXwn50lxGgkkHsgvl1K+ZRSrmnLr8W0jTgqCDOjZoum2Qlk CzYkqVM+tGYFnQLHHeuoRJ7IIM+tjBS9/P8rYdpsmdXYEbjqKYDCbdMynUN8LOT6aSFTFUhfNY5 9IELElDUrlSS3r+YUsjjP5qy1oWztyL0QT6jMuqPNcZjH3iFCw/M1NpfkdrNpyXmDlzaV X-Received: by 2002:a1c:2705:: with SMTP id n5mr3886074wmn.176.1631111099647; Wed, 08 Sep 2021 07:24:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQ44q4cuMTFLQw7kUNSeK/zTtbt0Kb7dC2Ylb+LAvQyvG6Zq0uXIeg2m+efBXo7zwhmtRaxg== X-Received: by 2002:a1c:2705:: with SMTP id n5mr3886043wmn.176.1631111099235; Wed, 08 Sep 2021 07:24:59 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id y1sm2381902wmq.43.2021.09.08.07.24.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 07:24:58 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 9831458000E; Wed, 8 Sep 2021 16:24:58 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] xml-reader: Get back to original way of building qualified types Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Wed, 08 Sep 2021 16:24:58 +0200 Message-ID: <877dfrf8lh.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, We build qualified types today by building a temporary qualified type of "void" (one that has no underlying type), then the underlying type is built, and once it's built, it's set to the qualified type. We do this so that if during the construction of the underlying type, the proper qualified type is needed (by recursion) then the temporary type is found and used. We used this strategy recently as a temporary measure until the canonical type propagation algorithm is fixed. And now it seems fixed. The problem with that temporary approach is that in some rare cases, the temporary qualified void type can be used elsewhere and violate assertions that expect a proper qualified type. The patch thus creates the underlying type first. If the qualified type is created (by recursion) in the process, we use it. Otherwise, the qualified type is later created with the proper underlying type that is already available. This helps to fix https://bugzilla.redhat.com/show_bug.cgi?id=1951501. * src/abg-reader.cc (build_qualified_type_decl): Create the underlying type first, then create the qualified type. This helps fix bug Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-reader.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 559f8210..2331815e 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -3672,20 +3672,6 @@ build_qualified_type_decl(read_context& ctxt, if (restrict_cv) cv = cv | qualified_type_def::CV_RESTRICT; - // Create the qualified type /before/ the underlying type. After - // the creation, the type is 'keyed' using - // ctxt.push_and_key_type_decl. This means that the type can be - // retrieved from its type ID. This is so that if the underlying - // type indirectly uses this qualified type (via recursion) then - // that is made possible. - // - // The underlying type will later be set after it's created. - qualified_type_def_sptr decl; - decl.reset(new qualified_type_def(ctxt.get_environment(), cv, loc)); - maybe_set_artificial_location(ctxt, node, decl); - ctxt.push_and_key_type_decl(decl, id, add_to_current_scope); - ctxt.map_xml_node_to_decl(node, decl); - string type_id; if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "type-id")) type_id = CHAR_STR(s); @@ -3694,7 +3680,21 @@ build_qualified_type_decl(read_context& ctxt, shared_ptr underlying_type = ctxt.build_or_get_type_decl(type_id, true); ABG_ASSERT(underlying_type); - decl->set_underlying_type(underlying_type); + + qualified_type_def_sptr decl; + if (type_base_sptr t = ctxt.get_type_decl(id)) + { + decl = is_qualified_type(t); + ABG_ASSERT(decl); + } + else + { + decl.reset(new qualified_type_def(underlying_type, cv, loc)); + maybe_set_artificial_location(ctxt, node, decl); + ctxt.push_and_key_type_decl(decl, id, add_to_current_scope); + } + + ctxt.map_xml_node_to_decl(node, decl); return decl; }