From patchwork Thu Mar 26 17:53:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39060 From: gprocida@google.com (Giuliano Procida) Date: Thu, 26 Mar 2020 17:53:50 +0000 Subject: [PATCH] abg-ir.cc: Add types_have_similar_structure tests. Message-ID: <20200326175350.144389-1-gprocida@google.com> This is a follow-up to a recent commit. This patch adds more tests, as suggested by a reviewer. * src/abg-ir.cc (types_have_similar_structure): Update TODO regarding structure of arrays - multidimensional arrays are the issue. * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Updated following changes. * tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Add more cases (see below). * tests/data/test-abidiff-exit/test-leaf-peeling-v0.o: Updated. * tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Add comment about a potential change to local-change semantics; add test cases to demonstrate that * and & and * and *** are structurally different; add a TODO regarding multidimensional arrays where changes are sometimes missed in leaf mode. * tests/data/test-abidiff-exit/test-leaf-peeling-v1.o Signed-off-by: Giuliano Procida Reviewed-by: Matthias Maennich --- src/abg-ir.cc | 2 +- .../test-leaf-peeling-report.txt | 29 ++++++++++++++---- .../test-abidiff-exit/test-leaf-peeling-v0.cc | 19 ++++++++---- .../test-abidiff-exit/test-leaf-peeling-v0.o | Bin 3704 -> 4528 bytes .../test-abidiff-exit/test-leaf-peeling-v1.cc | 24 +++++++++++---- .../test-abidiff-exit/test-leaf-peeling-v1.o | Bin 3752 -> 4600 bytes 6 files changed, 55 insertions(+), 19 deletions(-) diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-v1.o b/tests/data/test-abidiff-exit/test-leaf-peeling-v1.o index e71ade4431f80a78ee73292d60808a2ee5404640..81fcfe0a5a5abecf2d104e71859a04ab529d0b04 100644 GIT binary patch literal 4600 zcmbtXUuaup6hB{X)8001)--mmR_Cp5xG{6rq-ob}cB`v)E4op|z4(XjCcR06?M+G2 zt(`i@5O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cn|GSJ6qdaP#d}H{Jv;Mt- zPjQ}~7$-(~)V}E=1xbykd>x{mFz{cc7p_CbRUU>L*15_-Hu>U1Zu(Dfpou$-Q#ag| zL?#Vf)ql#s)%ct@@FCV;HgGk+;8xd`@Ww`7tAu<(Ni~192JXC9^T5qjtKe4rMbDl0 zb1TKUQcx(PP0C&_SMg6bn7xV@6!8(Dhu|y7S0UI1xcTzZl8=|Z8D`542bk)%Yv;c@&zB-!^^_tg<7GAHBv@yc$2M$LyOzp5YDs pDHlxd2)YN&c$yP)?;!-U?DzsH8kyfud7H&w;`(3HVo5aP{|3Dhq4EF# delta 989 zcmZ9LO=uHA6vyZ7=3^(D-ER7k%~~so#E-?eOj)viTs@&4Q_Fe?I{nj;2QwCQu@po( z1~JTNrhkDgA(LVJD);9SqluLj-VE{f5-K?!GqM3*xa;jr?^#JE0HsPfAH7ko74v2L zO0-z66G!3B(fYM2sa075S+n!STHRjDR;sm8T=n+p+#$>)xfw(BEDU8AN5}q8OwNxx z33aLstHV{>E)~o91fKWy;B6&>6_0}J-u2CUzDckmtjkWq4ljl(<`MkkH|ZRU zI1OV)i9u_LN!(EeA&VhuS|3GzkC^%GQ1n^)#GB2xd1MK?T?|Y5KZwLyJQWKWkHt9l%LF63B^~3gDtX5qRfw<6Xdq`UL$X zcGz<2f9r92U%aRhM>*0FmtHG)p(9PV1XyynV&J=iUl@qW?vmYT87VXj1qPgyk`b4d zJna33@sZDi8%CTiyZ;}#iQkMA-BsMeIkZA4x-Hlpyv(9YqR(Y_w@{o;^Sfr_sjFzg Ef0VYQb^rhX diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 5576c137..e1e757e9 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -22725,7 +22725,7 @@ types_have_similar_structure(const type_base* first, if (const array_type_def* ty1 = is_array_type(first)) { const array_type_def* ty2 = is_array_type(second); - // TODO: Handle uint32_t[10] vs uint64_t[5] better. + // TODO: Handle int[5][2] vs int[2][5] better. if (ty1->get_size_in_bits() != ty2->get_size_in_bits() || ty1->get_dimension_count() != ty2->get_dimension_count() || !types_have_similar_structure(ty1->get_element_type(), diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt b/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt index eeffc7b5..119d01b4 100644 --- a/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt +++ b/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt @@ -1,9 +1,9 @@ -Leaf changes summary: 4 artifacts changed -Changed leaf types summary: 4 leaf types changed +Leaf changes summary: 6 artifacts changed +Changed leaf types summary: 6 leaf types 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 foo at test-leaf-peeling.0.cc:1:1' changed: +'struct foo at test-leaf-peeling-v0.cc:1:1' changed: type size changed from 32 to 64 (in bits) there are data member changes: type 'int' of 'foo::z' changed: @@ -12,7 +12,7 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable and size changed from 32 to 64 (in bits) (by +32 bits) -'struct ops1 at test-leaf-peeling.0.cc:5:1' changed: +'struct ops1 at test-leaf-peeling-v0.cc:5:1' changed: type size hasn't changed there are data member changes: type 'int*' of 'ops1::x' changed: @@ -20,15 +20,32 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable -'struct ops2 at test-leaf-peeling.0.cc:9:1' changed: +'struct ops2 at test-leaf-peeling-v0.cc:9:1' changed: type size changed from 320 to 640 (in bits) there are data member changes: 'foo ops2::y[10]' size changed from 320 to 640 (in bits) (by +320 bits) -'struct ops3 at test-leaf-peeling.0.cc:13:1' changed: +'struct ops3 at test-leaf-peeling-v0.cc:13:1' changed: type size hasn't changed there are data member changes: type 'void (int&)*' of 'ops3::spong' changed: pointer type changed from: 'void (int&)*' to: 'void (int&&)*' + + +'struct ops4 at test-leaf-peeling-v0.cc:17:1' changed: + type size hasn't changed + there are data member changes: + type 'int*' of 'ops4::x' changed: + entity changed from 'int*' to 'int&' + type size hasn't changed + + + +'struct ops5 at test-leaf-peeling-v0.cc:21:1' changed: + type size hasn't changed + there are data member changes: + type 'int*' of 'ops5::x' changed: + pointer type changed from: 'int*' to: 'int***' + diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc b/tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc index b927d15e..745d44f5 100644 --- a/tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc +++ b/tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc @@ -14,11 +14,18 @@ struct ops3 { void (*spong)(int & wibble); }; -void register_ops1(ops1*) { -} +struct ops4 { + int * x; +}; + +struct ops5 { + int * x; +}; -void register_ops2(ops2*) { -} +int var6[2][5]; -void register_ops3(ops3*) { -} +void register_ops1(ops1*) { } +void register_ops2(ops2*) { } +void register_ops3(ops3*) { } +void register_ops4(ops4*) { } +void register_ops5(ops5*) { } diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-v0.o b/tests/data/test-abidiff-exit/test-leaf-peeling-v0.o index a556a63560122a5e926ab708bb13f0fd40714638..e6ed6218704e957cbac929f82d0a571fd181103f 100644 GIT binary patch literal 4528 zcmbtXTW?!M5T5mkBv?_LE$4M`cHV|kV6{-rU;!Zemjvb5mII>UL zq}(b5sC}YHrCd~`3f}q$C~pXmC_*Zgc;OEq5Krv`QYDaJX3wm9K2&sOLH1hFbpS-ocra-xz}%>fAO2UF6-0lOEP#H=kl`I7 zYQIC_H4p<4vH&7kY(BuBO-&S{b_BI57q`DaXMhlq7`R3nVqar3NDahg?S7fW0~oS@ z#Q+Upm14QxZIgKYUUY9Hb`tg4bYJK*xd{wnF@wh+`|aEzYh0 z-);KYCD$oumtA+M>Q%BQ$8x2Tq=(ZG4f>%1_loeAx5DYEu5HM|s`ce&zGuOPTd6jE zw=pNPmg-(5v*In?G?__qen8{W$*|O7I^Gb`2x>sLm zW>>sZRc|5dJM&9!6R@`eHRIG2shQ{)R8b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-abidiff-exit/test-leaf-peeling-v1.cc index 7c88df9f..439f7c0b 100644 --- a/tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc +++ b/tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc @@ -7,6 +7,10 @@ struct ops1 { }; struct ops2 { + // A change to foo's size is currently considered local here. Arguably this + // should be considered non-local as the change to foo is being reported + // independently. If this happens, the test case will need to be updated (to + // remove the reporting of an ops5 diff). foo y[10]; }; @@ -14,11 +18,19 @@ struct ops3 { void (*spong)(int && wibble); }; -void register_ops1(ops1*) { -} +struct ops4 { + int & x; +}; + +struct ops5 { + int *** x; +}; -void register_ops2(ops2*) { -} +// TODO: This *should* be considered a local change, but currently is not. +int var6[5][2]; -void register_ops3(ops3*) { -} +void register_ops1(ops1*) { } +void register_ops2(ops2*) { } +void register_ops3(ops3*) { } +void register_ops4(ops4*) { } +void register_ops5(ops5*) { }