From patchwork Thu Dec 3 15:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 41287 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 78C1B3857C70; Thu, 3 Dec 2020 15:09:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78C1B3857C70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607008171; bh=nzdTuzxbfgsTbFKbAwlSjiS9XwQUyYU72rQ4j+AVfxo=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=J53GnSSajGhNHzuH6fD33zE3eVvXW2W7Vu36fW6GQFEO0yXyaDsqJ/Sio1B79XhIn G2reW/e8ahlPMOPtRI/eU6wyfNBNkL6EP31KP0UbLBVuJSYNusy0HbTcFUvrvM2aOu TGzcjZfG06YRwVg+M5w4eJYeDE8X8nnmdoLYGwd8= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by sourceware.org (Postfix) with ESMTPS id E4F843857C70 for ; Thu, 3 Dec 2020 15:09:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E4F843857C70 Received: by mail-qk1-x749.google.com with SMTP id d132so2198790qke.5 for ; Thu, 03 Dec 2020 07:09:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=nzdTuzxbfgsTbFKbAwlSjiS9XwQUyYU72rQ4j+AVfxo=; b=BoBDmniaFUYCeyL8e5H6Os0sfMPZpB69HzxF1qVB6dytdcnzOZWmpQD/yCejXiKi1c x5b9pz8T7EB8qNSZfZtboLuFrigZRjcyUv8uU0X9eGk/f1sunTWBRLDgOoHx5vTFxOy+ oQXE8zvposWz/rZsgyHkTl6vaAiUt38f9nIi3PXQkPia71tqYfWZHHomQP8/qPYyrEys Gi6KQrxNYkssT4V2jqISqAqmfIOu1J+OUK+oenSMiNqM1OzK70sjhAomeqtU/E0RVjSu 8ZOodJbZDah+UEiPNsKY0hWpKsYSccfDA/sxmOqTEE0yU33NIJFADFo/J1HxpRysaXEt IOmQ== X-Gm-Message-State: AOAM5308cYo/I/9axeQiwQ/JxQShXS29XPKU/ahvxC2ZRvZMvbsG6k2y o4oa6FYksECi/iX3Mp3gmhtlaFSKkMO4pBm1hyhSiFZn/4uxXJOcvoZuQNTPHzmGb7k1ZrZdAEo Kbm30FbNme/1x6PPjQc+VvI2r/lrsZV8puHB86zf1jD1BWbUPGWTWjGriLC8vvStAf0dagyc= X-Google-Smtp-Source: ABdhPJzY/h6bfxT6qY8HG2BWhYaf5GP3/mcxpKcyvn4uQA5sN7zOUWnBnIkiRg0acNKegScR2sVMw1aPCoK2OA== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:110:a6ae:11ff:fe11:4f04]) (user=gprocida job=sendgmr) by 2002:a0c:ec41:: with SMTP id n1mr3543734qvq.42.1607008159440; Thu, 03 Dec 2020 07:09:19 -0800 (PST) Date: Thu, 3 Dec 2020 15:09:16 +0000 Message-Id: <20201203150916.3540551-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH] abidiff: improve treatment of array types in leaf changes mode To: libabigail@sourceware.org X-Spam-Status: No, score=-23.0 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 Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" If an array's element type doesn't change name but has some other (local) change, then the change should not also be considered local to the array type. * src/abg-ir.cc (types_have_similar_structure): When examining array types, always treat element type changes as indirect changes. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-non-leaf-array-report.txt: New test case showing correct --leaf-changes-only reporting. * tests/data/test-abidiff-exit/test-non-leaf-array-v0.c: Likewise. * tests/data/test-abidiff-exit/test-non-leaf-array-v0.o: Likewise. * tests/data/test-abidiff-exit/test-non-leaf-array-v1.c: Likewise. * tests/data/test-abidiff-exit/test-non-leaf-array-v1.o: Likewise. * tests/test-abidiff-exit.cc: Run new test case. Signed-off-by: Giuliano Procida --- src/abg-ir.cc | 2 +- tests/data/Makefile.am | 5 +++++ .../test-non-leaf-array-report.txt | 11 +++++++++++ .../test-abidiff-exit/test-non-leaf-array-v0.c | 12 ++++++++++++ .../test-abidiff-exit/test-non-leaf-array-v0.o | Bin 0 -> 3096 bytes .../test-abidiff-exit/test-non-leaf-array-v1.c | 12 ++++++++++++ .../test-abidiff-exit/test-non-leaf-array-v1.o | Bin 0 -> 3072 bytes tests/test-abidiff-exit.cc | 11 +++++++++++ 8 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/data/test-abidiff-exit/test-non-leaf-array-report.txt create mode 100644 tests/data/test-abidiff-exit/test-non-leaf-array-v0.c create mode 100644 tests/data/test-abidiff-exit/test-non-leaf-array-v0.o create mode 100644 tests/data/test-abidiff-exit/test-non-leaf-array-v1.c create mode 100644 tests/data/test-abidiff-exit/test-non-leaf-array-v1.o diff --git a/src/abg-ir.cc b/src/abg-ir.cc index c6f7c13e..b0db9c39 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -23606,7 +23606,7 @@ types_have_similar_structure(const type_base* first, || ty1->get_dimension_count() != ty2->get_dimension_count() || !types_have_similar_structure(ty1->get_element_type(), ty2->get_element_type(), - indirect_type)) + true)) return false; return true; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 84447185..f1d7ee45 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -184,6 +184,11 @@ test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.c \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.o \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.c \ test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.o \ +test-abidiff-exit/test-non-leaf-array-v0.c \ +test-abidiff-exit/test-non-leaf-array-v0.o \ +test-abidiff-exit/test-non-leaf-array-v1.c \ +test-abidiff-exit/test-non-leaf-array-v1.o \ +test-abidiff-exit/test-non-leaf-array-report.txt \ \ test-diff-dwarf/test0-v0.cc \ test-diff-dwarf/test0-v0.o \ diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-report.txt b/tests/data/test-abidiff-exit/test-non-leaf-array-report.txt new file mode 100644 index 00000000..f13cd0d4 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-non-leaf-array-report.txt @@ -0,0 +1,11 @@ +Leaf changes summary: 1 artifact changed +Changed leaf types summary: 1 leaf type changed +Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function +Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable + +'struct buzz at test-non-leaf-array-v0.c:1:1' changed: + type size changed from 32 to 64 (in bits) + there are data member changes: + type 'int' of 'buzz::a' changed: + type name changed from 'int' to 'long int' + type size changed from 32 to 64 (in bits) diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v0.c b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.c new file mode 100644 index 00000000..9594c396 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.c @@ -0,0 +1,12 @@ +struct buzz { + int a; +}; + +struct flexible { + long count; + struct buzz lightyear[0]; +}; + +struct flexible var; +void fun(struct flexible flex) { (void) flex; } + diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v0.o b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..f45eecb207f8ed7a78ae672d348ec9995b25b378 GIT binary patch literal 3096 zcmbtW-D@0G6hC)oKV~z{n$0RUiO5tcwctz=scozzU5%y<)lv(EqDYwCo&CVw*)lsD zH&Llb5ekA81Qql_eep%G|AC-?fP()*!B^izAM~6%=WcFpC-~rjz4x5o`Ml?T%-(wW zm93l*ph&<597qZUxKTRb>yoWQ4d&tcr91a8-FffNyKnv^(O+=POU{;Ij!9k{9F5Nr zpBKX3!r2Ny;1$&HGffS-Bc@|0!y^EL)MO!LM9!eh(LIWTyi!Sd5 zF^HM!s|b}Xslj2UJ&r&)MJ21c#Fvs2&LY|8KIvl8s(7+ebF9izr7Gr2bB`ik6IR7> z&O6UL&pD!o)z5-ur{Z>P4MXHlg5zvBmW`F8uA=LTtg8T&gxIc80Q&@N*Uq71`HU9n z!b0vi*6NE33o87n1uCL`{IeGq0GxsrnoQwos#-1zGi#*Qr$LgXRa&r&qY!^rW^t6K z0XI)T5{?ot8b)3}4BB20$HAVryW%&cW5I=TnusFIh{Ey*ISbv}{czH2^g|#9E?&9r zZmynlS6BRJ{1w+5B;zPt?}Skp_nIgMakINVSv%{UJ>z;E*J}r(y{OrZhtY66^2X8I zy{P3S0md6ae;9S#aWv|6qOj%C0g;GgdYx{v7ve@Y#{2t67rvYfZbEZ7MqjwNxq04w z>ZP#J3nH%1TYdI4vvQ395A!VcuYs7%iKSyD`z|);F~sRdBwPDJW$we==4^2b4N^FB zq)U;9KmN&5V)wFO+@5Kl59uw`WRb-;(9~HlJ?)277HF4S(^yc}qyyGUS9}04XTj_P z7y%aGLC+uy9(WyK5$&qlx>PS8M|@uE&-6GSc}D5h(;ZJqt$YSW#gj%=Ksc>dRazw_ zlEQDNB0R#g!oOk}@1i8yL4CJQGfwtuEd==*PI+&!e8s?7gf|TQ8!R=5R0w@#XNNVG{cIvU#Hdf!YWiPgAN?#7WXh|EnK8*u`Ts_OMy4%&#^`@UU9%zfcLI^R z>_F#=AeEm!fkf;0Gh-5dlELpu(8#o`BVM$`kM8( zGGZcxf01YecrBf#qnUpPHCg%J=lrTql%MXdng1qY6jRlStfXt4|2qZntn#b*9mKQz z|6+glKm2dAzhMT8=7D4bl~>t+!Ty|1!Qit0+7w9{wSEPEicD7jKF{bMeKVB5>MPY_ v=BC&;IKMi-^qryi*7T=6$y(}OFqWBUIKkucXI literal 0 HcmV?d00001 diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v1.c b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.c new file mode 100644 index 00000000..516c8b1f --- /dev/null +++ b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.c @@ -0,0 +1,12 @@ +struct buzz { + long a; +}; + +struct flexible { + long count; + struct buzz lightyear[0]; +}; + +struct flexible var; +void fun(struct flexible flex) { (void) flex; } + diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v1.o b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..298dda06b0fbf53e001eede352f049a0196e5264 GIT binary patch literal 3072 zcmbtW-D@0G6hC(-yF1A=+iX^`X;h}7)Pgg~N^N5$>1s4>uoe~iqDYwCz59W?vt?#B zCJ|9Y#lA=d!7BPvUyA>O_~4Tdg8zizoA@U9py$k-JGr@?;DZPD-gAEE^Pc-L`~FMU zwn{>PA^{t4C@B=6Rn_>EZ9xMT;l|Zlzg@lc-e0%h`YA@>`Yl-CAF<4eTb zLfBh4TLFkt%3%b%Oe)rw?I{W=A}X0hCR9(7!iI{6)5rL$(m?KMwf1fhftahmg3zp$ zYKZGiLl90y$*Lgn%^X3(IZgJZ&j-lY#S^uLW7U>xb+K4ocnI-^uxgHT$$8Fs))5UX zdmb!16So^{7;NToaGVWv!je%}({&Xgwj1PCJp1 z%&k*jzOV!^SJvW@DLh4`;*YwZlUkIH5l>6AU zupi2*K zlXv)t-a<_gS$xw>odx;fKBBTfyTqEtf>}*EWUXw)hX8XH%-@F*U;&=_0gA(|FKYeC5Av~lPM4gnbVh3Bbe9!R8dU+|v|3eZos>ulrw4`T!EDO$Z&}7$ zm=f)vzFX%Qr#NaY1o;|HdGD~iZQvu8uNydv@TP&^WqDxWpRxR@fxp4>*F01G`YwL2 z;rhCMU|jWw)v4M8JR@=v)z`^3%tUXdQoM zOu`>w@Gc1&nYL7?iIMq_46bUv#G1C$=c4-8cte#x)laXlS%0@6CPMHBCwh$pjm-Qz zs4L1p;QXpjl%MXdng1qY6jRlSY)UP@jQ144v&ygLcM&i0|DFBa|M35a{S7m)%>&5> zDzCEtiv2mAf^+}19LX59eg%JlOi}+nDCi%3GnBvTE7fD>rr0g6U!7n2&d_^n`qQ2i dE%hE1h4ff9<)gWNid*D=hwJ|?_skg6|6ia;)N%j- literal 0 HcmV?d00001 diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc index bb0262bb..bf1facc4 100644 --- a/tests/test-abidiff-exit.cc +++ b/tests/test-abidiff-exit.cc @@ -337,6 +337,17 @@ InOutSpec in_out_specs[] = "data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt", "output/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt" }, + { + "data/test-abidiff-exit/test-non-leaf-array-v0.o", + "data/test-abidiff-exit/test-non-leaf-array-v1.o", + "", + "", + "", + "--leaf-changes-only", + abigail::tools_utils::ABIDIFF_ABI_CHANGE, + "data/test-abidiff-exit/test-non-leaf-array-report.txt", + "output/test-abidiff-exit/test-non-leaf-array-report.txt" + }, {0, 0, 0 ,0, 0, 0, abigail::tools_utils::ABIDIFF_OK, 0, 0} };