From patchwork Tue Dec 7 17:45:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 48591 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 7CB7E3858427 for ; Tue, 7 Dec 2021 17:45:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CB7E3858427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638899123; bh=DUiiYbxRZza7Hw8Z5lPD0yVDTF4eef7/aSTHIy173uI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=eCb4QZ2hqCmEUMZE/6pHf6/7/5n6iMH0bdNEc+09w1BG9vvOYYpmGej2kuuy4cvcP et8KfTGe84mLyPYTmfHJ8vRdfhXWEUQlKyNhmOfsTsjNdTMiScbhZnUyPwu2PpvM/g T/9X2tL5fRSNF5PrJop072UXHnFixGRYCX+ki9r0= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id E57BA3858D28 for ; Tue, 7 Dec 2021 17:45:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E57BA3858D28 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-uk80_mFzMOyCKICuXEkspQ-1; Tue, 07 Dec 2021 12:45:17 -0500 X-MC-Unique: uk80_mFzMOyCKICuXEkspQ-1 Received: by mail-qk1-f197.google.com with SMTP id p18-20020a05620a057200b00467bc32b45aso17059637qkp.12 for ; Tue, 07 Dec 2021 09:45:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=DUiiYbxRZza7Hw8Z5lPD0yVDTF4eef7/aSTHIy173uI=; b=bTYZeIiPo1sv8Z6LR2FQiTB8s0RbHytCxKTd4rk3iQTqUmln9G0FOA93ypiMuBIknE YP7cv2RHm1iXGx/3mnxs9FgaYd/FTThl7K7H72iJkoDymFM1LdZhlXCofB1kClfBFlgI Oj+Ga0ORTR3qwrJoMDLqvOxN1wG01D5F7anDrktsW435xAk/Go0K2RqNpli1Bs7hb9Mc Dr/YSnAaKXm0S8f4x/e9ehY/tRLsVdg3Me+3+dOApZCOyOPTWe0PySXFbVgrKDOlIuX6 w8i6yq8C1nkRKihgG4FdNJuJFij1yWihcKs/AKlZc2sMx6WQPvBptdY9vH48Tn/2JMNk Z0XQ== X-Gm-Message-State: AOAM5310FWEeeIuI2zqjP+T21W+2q47fHZMG4NozuSKRlTYnbjdiVuWf d2UPjKA9S/Rp1ut4SUfZZ3Lwx9TebSvk+XtYpzTIh91ygT4y2LwUl893fT6YGS5YFozD7vqBQfx Eh/t33F3kiNrON5Jvja67DUy4DjsHbdtp59jh/MUzFjM9orwCKYlH0kyOTXyxRwzqB2zm X-Received: by 2002:a05:622a:307:: with SMTP id q7mr876811qtw.330.1638899116419; Tue, 07 Dec 2021 09:45:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzSPYO6p4C5OO7d8V9ROOLqM4fMfotzNXgAfkJ1TdcLjAfcBtaqW495ElWn/Vu0CJREVYlb1Q== X-Received: by 2002:a05:622a:307:: with SMTP id q7mr876749qtw.330.1638899116039; Tue, 07 Dec 2021 09:45:16 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id o126sm148550qke.11.2021.12.07.09.45.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 09:45:15 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 21DCE581C2E; Tue, 7 Dec 2021 18:45:03 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] reader: Build array types with their element type "a priori" Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Tue, 07 Dec 2021 18:45:03 +0100 Message-ID: <871r2os40w.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.4 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_H3, RCVD_IN_MSPIKE_WL, 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, In some ancient settings, we were building array types with no element type set, then, when we have the element type built, we'd set it to the array type. This was to avoid looping indefinitely in cases where the element type would indirectly depend on the array type itself. Since then, we've built infrastructure to avoid those loops. So we don't need those 'temporarily empty arrays' anymore. Besides, trying get the pretty representation of a variable declaration which type is one of those temporarily empty arrays crashes because that code doesn't expect empty arrays. This patch sets the element type at array type building type now. The code also asserts that element types of arrays are not empty, in the pretty representation of variable declarations. * src/abg-ir.cc (var_decl::get_pretty_representation): Assert that array element types are not empty. * src/abg-reader.cc (build_array_type_def): Set array element types a priori. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-ir.cc | 7 +++++-- src/abg-reader.cc | 12 +++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 2cc4cf8c..03b38c3a 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -18497,8 +18497,11 @@ var_decl::get_pretty_representation(bool internal, bool qualified_name) const else name = get_qualified_name(internal); - result += - get_type_declaration(t->get_element_type())->get_qualified_name(internal) + type_base_sptr et = t->get_element_type(); + ABG_ASSERT(et); + decl_base_sptr decl = get_type_declaration(et); + ABG_ASSERT(decl); + result += decl->get_qualified_name(internal) + " " + name + t->get_subrange_representation(); } else diff --git a/src/abg-reader.cc b/src/abg-reader.cc index bf08b2e7..541ca179 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -4282,17 +4282,15 @@ build_array_type_def(read_context& ctxt, } } - array_type_def_sptr ar_type(new array_type_def(ctxt.get_environment(), - subranges, loc)); - maybe_set_artificial_location(ctxt, node, ar_type); - if (ctxt.push_and_key_type_decl(ar_type, id, add_to_current_scope)) - ctxt.map_xml_node_to_decl(node, ar_type); - // The type of array elements. type_base_sptr type = ctxt.build_or_get_type_decl(type_id, true); ABG_ASSERT(type); - ar_type->set_element_type(type); + + array_type_def_sptr ar_type(new array_type_def(type, subranges, loc)); + maybe_set_artificial_location(ctxt, node, ar_type); + if (ctxt.push_and_key_type_decl(ar_type, id, add_to_current_scope)) + ctxt.map_xml_node_to_decl(node, ar_type); if (dimensions != ar_type->get_dimension_count() || (alignment_in_bits