From patchwork Fri Dec 4 11:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41299 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 015843851C0D; Fri, 4 Dec 2020 11:07:08 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by sourceware.org (Postfix) with ESMTPS id 1713C3857C61 for ; Fri, 4 Dec 2020 11:07:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1713C3857C61 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dodji@seketeli.org Received: from localhost (91-166-131-65.subs.proxad.net [91.166.131.65]) (Authenticated sender: dodj@seketeli.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 6F39A100013; Fri, 4 Dec 2020 11:07:01 +0000 (UTC) Received: by localhost (Postfix, from userid 1001) id 1AE271A2631; Fri, 4 Dec 2020 12:07:01 +0100 (CET) From: Dodji Seketeli To: Giuliano Procida Subject: [PATCH 2/2] ir: Arrays are indirect types for type similarity purposes Organization: Me, myself and I References: <20201203150916.3540551-1-gprocida@google.com> <865z5hq1eo.fsf@seketeli.org> X-Operating-System: Red Hat Enterprise Linux Server 7.8 X-URL: http://www.seketeli.net/~dodji Date: Fri, 04 Dec 2020 12:07:01 +0100 In-Reply-To: <865z5hq1eo.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 04 Dec 2020 12:02:55 +0100") Message-ID: <86wnxxomne.fsf_-_@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: , Cc: kernel-team@android.com, libabigail@sourceware.org, maennich@google.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" As described in the comments of types_have_similar_structure: "Two indirect types have similar structure if their underlying types are of the same kind and have the same name. [...] The size of their underlying type does not matter" Yet, the size of array elements (a.k.a the underlying type of an array type) is wrongly considered to matter when assessing the "type similarity" relationship for arrays. This patch fixes that. * 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 Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 2 +- tests/data/Makefile.am | 5 +++++ .../test-abidiff-exit/test-non-leaf-array-report.txt | 11 +++++++++++ tests/data/test-abidiff-exit/test-non-leaf-array-v0.c | 12 ++++++++++++ tests/data/test-abidiff-exit/test-non-leaf-array-v0.o | Bin 0 -> 3096 bytes tests/data/test-abidiff-exit/test-non-leaf-array-v1.c | 12 ++++++++++++ tests/data/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 7354ae3..39225af 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -23608,7 +23608,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)) + /*indirect_type=*/true)) return false; return true; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 8444718..f1d7ee4 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 0000000..f13cd0d --- /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 0000000..9594c39 --- /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 0000000..516c8b1 --- /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 bb0262b..bf1facc 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} };