[PATCH] abg-ir.cc: Add types_have_similar_structure tests.

Matthias Maennich maennich@google.com
Sun Mar 29 15:13:55 GMT 2020


On Thu, Mar 26, 2020 at 05:53:50PM +0000, Giuliano Procida wrote:
>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 <gprocida@google.com>

Thanks for adding those additional test cases!
Reviewed-by: Matthias Maennich <maennich@google.com>

Cheers,
Matthias

>---
> 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/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?!M5T5mk<KsAXotR#N+v1>Bv?_LE$4M`cHV|kV6{-rU;!Zemjvb5mII>UL
>zq}(b5sC}YHrCd~`3f}q$C~pXmC_*Zgc;OEq5Krv`QYDaJX3wm<UfZCGk-RhW&3v<a
>z_Uz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^*cjo;J*qHp|2MNjTu8keXoU2c<q!`1hmd0F
>zLtHq7+CD-5H-YqvoKeK^P<k<u!Skl9omS7Nr_{Qp<A{GD{^+cUqwESa<pfT^k5R+F
>z%(BWT4KL-R^O<aBb(Q%DDdUJrLyHMHj1_!W8PDxYNk$mg*6Wq2TlH48Qn%Nps`WO^
>z5i{CqFc@vvm1?VPZ>+30TGOzk96Z7e#KdtfPN25kYNu;<`Fgrx+qG)FGJH35e9JJY
>z#6eQV;0__MsT^Zvz!PP2_wvXLHsh?E2pW!kSe-lFEWGv`G%unt&`CmZGR~3nFd#|X
>zg|Eagt3wt-V?qa*rtJ9!I$boc2=t~Wx&lpVm;ywPJ<&DTrbZ_v&<~#IMd5$);6H``
>zS!mu9pLk68Zj)|>If45{^DZv(UO=h{xQX1+OnV4fk!Z$)M+80#O?45^!nSI_M>W5j
>zA0?RWN+D?BGT#{33MPeB3Wni(Fiy*YdJXnM2K)&U$ZGMxme|rS7%pii=^OFBx6sop
>z>7E4dwVc!?5D4YyK<ru(3L#6{A#k68QQ1kWvaFVL$OnONPCDmfHN>D4PSU*d6QbMD
>k3tRLZac<{fk9n^|tP8qs(FIXS2@1>$^AFC>Q`XbuU(0!qTL1t6
>
>diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc b/tests/data/test-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*) { }
>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@5OHr)L=pPnUr=9s5LDQUpn|C25PT4QP*E88qTqwL2R-Mz=S#nQO%(A!zH`p+
>z{Q1uP{^!ZN@12ea0g411f(=cf0OLIy@}v|eAqjnO^4P_nk6nD?k4uky^k2k!vV9SN
>zHmTXN+fc5X0rqKfq);w{ErdOdpmi2RL`s;!j*^>fY!S5!WM2i*-bE5XyS*se3bq|>
>z(Na(geP>0d{TyP}8i;rYNdR^Vn^*DIDI3h)K``e|*dL?PMTqF@`kFYzzQm@R8tAd9
>zi+1V65&ib>2vId#J4phFOD8rD*h&0wGT#s*iK3}!>9ZFBSw@>|1#BS)u{}CK28$G;
>zUTVaSc4CTREQs}G^i5C`d3FJl|A~e$;MNuauTTIrVZgWbfLmGwd_@7&gaL2W1BO}z
>zSUBqmYQliEdVtd+AWH$%gaOAf07OFUj3;AOd@!C6eI32mqctfkI~F?-I~dy^6G<G`
>z9<c0Cok@=4n6&MHSnLo6;f$hlTz78Yg0>lq>R=}ur$LCBBxULxf|=xA%+Q4?<9f<i
>zzaWS1C_3N@IKoNdy)10WY5|7_BHM8MU2%9oWeH^YliOZAGC+9}l!u()cKqQdBVi#L
>z>03gBVICC=Tx^B77Vp7UZfu+v0X4r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