From patchwork Mon Sep 2 08:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 96873 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 6BFB7385E458 for ; Mon, 2 Sep 2024 08:13:37 +0000 (GMT) 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 1CA37385DDCE for ; Mon, 2 Sep 2024 08:13:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CA37385DDCE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1CA37385DDCE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725264813; cv=none; b=Y4kGSKWkBh421oJzaYiBuCOV/SMQFgeh16Ni9We3Fg/ZJh0UexQQh5rDVqd5L1BlBM5IYnNhFNxO0tUvuyWz5Ohj2u1S+16nAXFdauAce5XvWnrfFyT2z3Pb8WGuApi/jbYiER0A4owQkm6Hof6u+TvNBVaZ9OIjE1RGL/qJ1ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725264813; c=relaxed/simple; bh=EQW+9VBi8oxLKuHYcntJsc9NK/UVozHLPrGSYCsQo+Y=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aGBCsKssPg1rgtJLpelocfg2j5bSOTib4jsfly0Mq0vvQLAa0RvMd+u/qp8Luiu1mp49rmgj3P1l2Wp8+OBgP0if6pS4ze6MHoYnhYA+s+LuNopz8ltyf3vK5p0tcKCrVR5Deema74atzSR2p/5icC3aHraiptQCfmtDdaA1POk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725264811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=yUs+UAPWV4ddO3Z/H6OxWKS8hCyX0yQ10mOiYlPnIAA=; b=cldBl0pvTZqdbH2E73UGJZRhLs/jWXgy0Z9/lLlCn1ioScZ5HeK5jrGNF85E/uSBPrttig iYYnLzEZOWq3upxVq/fwvgmqPJVqj419l2gzz4a/YzhvhPBEBFC0V+wXnofJQqeVUUsk44 52m8GFnjSPPsEA7KPXIsMNlXmCPQVxk= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-ibUuuJsNMaG4qfF8uT-ZBw-1; Mon, 02 Sep 2024 04:13:30 -0400 X-MC-Unique: ibUuuJsNMaG4qfF8uT-ZBw-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7a80b569384so454736685a.2 for ; Mon, 02 Sep 2024 01:13:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725264810; x=1725869610; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yUs+UAPWV4ddO3Z/H6OxWKS8hCyX0yQ10mOiYlPnIAA=; b=OY7T+z0+ff+bjSV3sXJLNRe+EZ+Fx2yXuctIU89aITB84w32PWJoFQ9Xgy7Q5QsK8s tlXI+phRiLza2fAgXiNJRDVe7Yc2vWfxqmBrHYFreSGxGUzvp/cxpC34qMM/ulZ8f0fE 5TZPATFGkotHB3+SAj1UsOSMSxdmRNvmI2m2dgV6Op88RDJI6EIgUgx+y3+ZqfSkLDMF YxXHHOar/uWeBYF7f13CCssIvYpaZOx+bHGRJz9QJk70xYagUxHlkaBP21vzPIHOx3yb alk2WBb9NG5D4LSOFwm/f11YnMxbN93tbiSFPc3JBF6oVSK9GqTIleYRftM9D91XvH4c oa3w== X-Gm-Message-State: AOJu0YwZdss7vcW6q3RlX+uX8U5ua36qUkZAxqEXyljfoI9KatfQuxP+ 3+QCgFbtKKCPxDICrwRCDCY3suSzp3Pv/zz6EUbem1TldAKxtTVJBZMUCQVJt9IblzqiAQEzzsF /FIChTmjo+qvyzKj4ZjuL67zl+3wwgf6ghPOvUMG6d7Nr2un3IJD6RXs4CGFinH6hJ2ng13kGwU dptdwB3jJnl0bAjt3mkQvM7GalTtExOCTYK+1ZBg== X-Received: by 2002:a05:620a:28d1:b0:7a2:c96:8638 with SMTP id af79cd13be357-7a8ac3f7706mr810478485a.58.1725264810039; Mon, 02 Sep 2024 01:13:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7E37Y1PURfvA16mOQiU5AXQfucZZUxYtSQpVTDTSpM3u8KBLkvUXw+WoPq8atxrNFyZw+4w== X-Received: by 2002:a05:620a:28d1:b0:7a2:c96:8638 with SMTP id af79cd13be357-7a8ac3f7706mr810476585a.58.1725264809531; Mon, 02 Sep 2024 01:13:29 -0700 (PDT) Received: from localhost (88-120-130-27.subs.proxad.net. [88.120.130.27]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a806d881ecsm391682485a.132.2024.09.02.01.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 01:13:29 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id E207D503C602; Mon, 2 Sep 2024 10:13:26 +0200 (CEST) From: Dodji Seketeli To: libabigail@sourceware.org Subject: [PATCH] comparison: Sort anonymous types using their flat representation Organization: Red Hat / France X-Operating-System: AlmaLinux 9.4 X-URL: http://www.redhat.com Date: Mon, 02 Sep 2024 10:13:26 +0200 Message-ID: <87wmjuiic9.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.1 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libabigail-bounces~patchwork=sourceware.org@sourceware.org Hello, When changes to types non-reachable from external interfaces are emitted, they are sorted using the pretty representation of said types. In the current form, it's the "internal" pretty representation that is used for the sorting. That internal form, which is normally used for the purpose of type canonicalization, doesn't differentiate an anonymous types against another one. For instance, all anonymous enums are named __anonymous_enum__. In that case, the sorting of anonymous type changes becomes non stable. This patch uses the non-internal form of type pretty representation for the sorting. In that form, anonymous enums are named using their flat representation. * src/abg-comparison-priv.h (diff_comp::operator()): Use the non-internal pretty representation for sorting. * tests/data/test-abidiff-exit/test-anon-types-report-1.txt: Adjust. * tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt: Adjust. Signed-off-by: Dodji Seketeli --- src/abg-comparison-priv.h | 4 ++-- .../test-abidiff-exit/test-anon-types-report-1.txt | 10 +++++----- .../test-anonymous-enums-change-report-v1.txt | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/abg-comparison-priv.h b/src/abg-comparison-priv.h index 5f63cf64..0e3569d5 100644 --- a/src/abg-comparison-priv.h +++ b/src/abg-comparison-priv.h @@ -881,9 +881,9 @@ struct diff_comp bool operator()(const diff& l, diff& r) const { - return (get_pretty_representation(l.first_subject(), true) + return (get_pretty_representation(l.first_subject()) < - get_pretty_representation(r.first_subject(), true)); + get_pretty_representation(r.first_subject())); } /// Lexicographically compare two diff nodes. diff --git a/tests/data/test-abidiff-exit/test-anon-types-report-1.txt b/tests/data/test-abidiff-exit/test-anon-types-report-1.txt index 916b880d..2ff8167c 100644 --- a/tests/data/test-abidiff-exit/test-anon-types-report-1.txt +++ b/tests/data/test-abidiff-exit/test-anon-types-report-1.txt @@ -9,17 +9,17 @@ Unreachable types summary: 2 removed, 3 changed, 0 added types 3 changed types unreachable from any public interface: - [C] 'struct {int a; int b;}' changed: - type size changed from 64 to 96 (in bits) - 1 data member insertion: - 'int c', at offset 64 (in bits) at test-anon-types-v1.c:18:1 - [C] 'enum {a=0, b=1, c=2, d=3, }' changed: type size hasn't changed 2 enumerator insertions: 'e' value '4' 'f' value '5' + [C] 'struct {int a; int b;}' changed: + type size changed from 64 to 96 (in bits) + 1 data member insertion: + 'int c', at offset 64 (in bits) at test-anon-types-v1.c:18:1 + [C] 'union {int a; int b; int d;}' changed: type size hasn't changed 1 data member change: diff --git a/tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt b/tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt index 8639fa44..0567e865 100644 --- a/tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt +++ b/tests/data/test-abidiff-exit/test-anonymous-enums-change-report-v1.txt @@ -4,17 +4,17 @@ Unreachable types summary: 0 removed, 2 changed, 1 added types 2 changed types unreachable from any public interface: + [C] 'enum {E3_0=0, E3_1=1, }' changed: + type size hasn't changed + 1 enumerator insertion: + 'E3_2' value '2' + [C] 'enum {E4_0=0, E4_1=1, E4_2=2, E4_LAST_ELEMENT=3, }' changed: type size hasn't changed 2 enumerator deletions: 'E4_2' value '2' 'E4_LAST_ELEMENT' value '3' - [C] 'enum {E3_0=0, E3_1=1, }' changed: - type size hasn't changed - 1 enumerator insertion: - 'E3_2' value '2' - 1 added type unreachable from any public interface: [A] 'enum {E5_0=0, E5_1=1, }' at test-anonymous-enums-change-v1.c:26:1