diff mbox series

Bug 27331 - Data member offset change not considered local

Message ID 86tuqmhkim.fsf@redhat.com
State New
Headers show
Series Bug 27331 - Data member offset change not considered local | expand

Commit Message

Dodji Seketeli Feb. 8, 2021, 11:22 a.m. UTC
Hello,

The comparison code fails to consider that a data member which offset
changed (and which type didn't change) constitutes a local change of
the enclosing class type.

Fixed thus.

	* src/abg-ir.cc (equals): In the overload of class_or_union, when
	a data member changes without having its type change, then
	consider the data change as being local.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
	Adjust.
	* tests/data/test-diff-filter/test-PR27331-report-0.txt: New
	reference output.
	* tests/data/test-diff-filter/test-PR27331-v{0,1}.c: New test
	source files.
	* tests/data/test-diff-filter/test-PR27331-v{0,1}.o: New test
	binary inputs.
	* tests/data/Makefile.am: Add these new test material to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the tests above to
	the harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.

---
 src/abg-ir.cc                                            |   3 ++-
 tests/data/Makefile.am                                   |   5 +++++
 tests/data/test-diff-filter/test-PR27331-report-0.txt    |   9 +++++++++
 tests/data/test-diff-filter/test-PR27331-v0.c            |   4 ++++
 tests/data/test-diff-filter/test-PR27331-v0.o            | Bin 0 -> 2744 bytes
 tests/data/test-diff-filter/test-PR27331-v1.c            |   4 ++++
 tests/data/test-diff-filter/test-PR27331-v1.o            | Bin 0 -> 2744 bytes
 ...0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt |   4 ++--
 tests/test-diff-filter.cc                                |   7 +++++++
 9 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 tests/data/test-diff-filter/test-PR27331-report-0.txt
 create mode 100644 tests/data/test-diff-filter/test-PR27331-v0.c
 create mode 100644 tests/data/test-diff-filter/test-PR27331-v0.o
 create mode 100644 tests/data/test-diff-filter/test-PR27331-v1.c
 create mode 100644 tests/data/test-diff-filter/test-PR27331-v1.o
diff mbox series

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 02f3cc2..dec85fe 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -19732,7 +19732,8 @@  equals(const class_or_union& l, const class_or_union& r, change_kind* k)
 	    {
 	      // Report any representation change as being local.
 	      if (!types_have_similar_structure((*d0)->get_type(),
-						(*d1)->get_type()))
+						(*d1)->get_type())
+		  || (*d0)->get_type() == (*d1)->get_type())
 		*k |= LOCAL_TYPE_CHANGE_KIND;
 	      else
 		*k |= SUBTYPE_CHANGE_KIND;
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 40ad0e4..68ad902 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -919,6 +919,11 @@  test-diff-filter/test-PR26684-dwarf5.o 	     \
 test-diff-filter/test-PR26684-dwarf4.o       \
 test-diff-filter/test-PR26684.c              \
 test-diff-filter/test-PR26684-report-0.txt   \
+test-diff-filter/test-PR27331-v0.c           \
+test-diff-filter/test-PR27331-v0.o           \
+test-diff-filter/test-PR27331-v1.c           \
+test-diff-filter/test-PR27331-v1.o           \
+test-diff-filter/test-PR27331-report-0.txt   \
 \
 test-diff-suppr/test0-type-suppr-v0.cc	\
 test-diff-suppr/test0-type-suppr-v1.cc	\
diff --git a/tests/data/test-diff-filter/test-PR27331-report-0.txt b/tests/data/test-diff-filter/test-PR27331-report-0.txt
new file mode 100644
index 0000000..8e02a0a
--- /dev/null
+++ b/tests/data/test-diff-filter/test-PR27331-report-0.txt
@@ -0,0 +1,9 @@ 
+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 S at test-PR27331-v0.c:1:1' changed:
+  type size hasn't changed
+  there are data member changes:
+    'int S::var' offset changed from 0 to 1 (in bits) (by +1 bits)
diff --git a/tests/data/test-diff-filter/test-PR27331-v0.c b/tests/data/test-diff-filter/test-PR27331-v0.c
new file mode 100644
index 0000000..361089b
--- /dev/null
+++ b/tests/data/test-diff-filter/test-PR27331-v0.c
@@ -0,0 +1,4 @@ 
+struct S {
+  int var : 1;
+};
+int fun(struct S s) { return s.var; }
diff --git a/tests/data/test-diff-filter/test-PR27331-v0.o b/tests/data/test-diff-filter/test-PR27331-v0.o
new file mode 100644
index 0000000000000000000000000000000000000000..d86229db831cfbc709385b50e7726eee83605d3d
GIT binary patch
literal 2744
zcmbtW&1)M+6n~@DT1wYaY^!c#T*wv@5<_<N;gYxsPSuLkHVMITaZd?mC5_}w^kH_#
zj?)ryDTUlxD3n5Px#ZeQk0m9S-un;a(tCRgG|;@aJ0q{gD_YVAn)l}SKIh}j>e00u
zpJo^XMGUUO(M+KLFU=#l9*K1*!5nO_KmOzK!&fJNzV_<Z7rAFIb0>d!cIWv6w8%zQ
z`6$?QBqxS<5_0A<$TF7SK*%`o0$`aO$ys(9hpg!j1el%u0kEt|xFQvT{Wuk(Zq7kP
z=Gz_sn`LK<CCex-7H8R9ZsuLYOU%ey)@AF8^`XT|n5Y0oKAvurEUREmTPqf(I|G(=
z)iUw`rprEBP&VflHcAw$e(L*A767Kqgm>l?CcZ$)qsq`VL8{0E6p8CNW?>0O#@OG*
z0x{Yt{4o$b6wc;W?b7mc)j6oRt;ofkhZAuMoX(r4g?aY3Oa>jxVQ+Xp-1AzzT5b>9
zcl~nL7v-Mc^qPLx^Lyovf5^i!MGebsPk52&wEa%U>G(atgOrSGH@EFZ^^#q!x)rx#
z*DAG2wN_iU&u{Uzz3vIAa4Ji-)86mzHNB8K{7~3#%Xa!=f52C}e82;rre4t6T|Hd6
z=v@53cDev-jmBmBJf>Ls5AmbL!`m?f_Qe*k!x^?Xoy&iNyY(L8^dpKk`{Uxw*O^9P
z>J}QraOy~#orS;tNmClB9e|fc9<lCYpeBtB*#o-HfGHh{<_6>@;3p>Fcx6+_fI<pN
z^%p1L$NCd{8?d`+mtq=S<l~o<dULd*x6nMfIu)64TE%u84rV1+ctg(THC#>syDlQC
zXw(HLQwtGMoaA}mj?k!~#_UyXWS@A_U}l2-$^_h&IMtG@2i)*MUwBRAB8d5}k_7e#
zxYU8*Hp39yfcHGN&71q(9e>anqArrXW;5UiV`?w(23<bx((?ygxnK%#Tf=^z<7?>-
zhJw4;UQQ^y);$@B@9uO0ug_)S|C24EKb?izPZh2%h0%SH^P`&-1MedvOz)h}rM=E{
z|8r<S=l!PsRrJ+kQcjisAx#pb+tPziU$}b0hQ#&wvj<NlPWOr+bvNl_L9~iLJtpD5
z(|{ymHX3!?P1NWZ8LvsOGV+WC-S#@dY4!gp>sS6%KfOwN{cXhbm<Yjr3ErSdf^^#*
z)TQOOWmBqsqWtu3==t{$qnN5r6eD^r6aAzB$yI*EzeGIEU&v-I|BL@u(qA)!Cu5Jn
zkyhnZ$PdzAH-9Pt_3kKpwSG1K4u!P+TS?hJdi9mR+E=Pa&rPvkNN`gYOz$*(O>}=c
g6TSBkf(jLdgnzomNMAq2P4nNB^*<T&K7Q9;19ij40RR91

literal 0
HcmV?d00001

diff --git a/tests/data/test-diff-filter/test-PR27331-v1.c b/tests/data/test-diff-filter/test-PR27331-v1.c
new file mode 100644
index 0000000..24c2a9a
--- /dev/null
+++ b/tests/data/test-diff-filter/test-PR27331-v1.c
@@ -0,0 +1,4 @@ 
+struct S {
+  int : 1, var : 1;
+};
+int fun(struct S s) { return s.var; }
diff --git a/tests/data/test-diff-filter/test-PR27331-v1.o b/tests/data/test-diff-filter/test-PR27331-v1.o
new file mode 100644
index 0000000000000000000000000000000000000000..7e35429c17fe030da9185303b769a8dab760eec1
GIT binary patch
literal 2744
zcmbtW&2Jk;6o2FOIxZW#N!&oAAi9;P+DPpBBd85UDF&+~QL8EhrKh53ZI7L${)l!b
zX$q>iAf(<vLPAK~dg+x5M^w}ccm9E1dWT!3R-*6i&N%DITA=nxp7-YWKIh}j`kSlQ
zKg}=(iWpphqnSbho|#8-Jre6s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`9J)>mHwI;JQ#Zn
zj<hPTLVlM1y7@y1sCP%%tM#k-k0_+=-%85<(W|fg)xJ_adTxsSM1q^LV0x$NYohzp
gndrTT5LBorB>dAgM*8|GZkqq5tpCB7_wl>-609D_2LJ#7

literal 0
HcmV?d00001

diff --git a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt
index 3e50dc7..249651f 100644
--- a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt
+++ b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt
@@ -1,6 +1,6 @@ 
 ================ changes of 'libspice-server.so.1.8.0'===============
-Leaf changes summary: 10 artifacts changed (10 filtered out)
-  Changed leaf types summary: 1 (10 filtered out) leaf types changed
+Leaf changes summary: 10 artifacts changed (13 filtered out)
+  Changed leaf types summary: 1 (13 filtered out) leaf types changed
   Removed/Changed/Added functions summary: 1 Removed, 0 Changed, 8 Added functions
   Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
 
diff --git a/tests/test-diff-filter.cc b/tests/test-diff-filter.cc
index 50e2f22..9bc2750 100644
--- a/tests/test-diff-filter.cc
+++ b/tests/test-diff-filter.cc
@@ -780,6 +780,13 @@  InOutSpec in_out_specs[] =
    "data/test-diff-filter/test-PR26684-report-0.txt",
    "output/test-diff-filter/test-PR26684-report-0.txt",
   },
+  {
+   "data/test-diff-filter/test-PR27331-v0.o",
+   "data/test-diff-filter/test-PR27331-v1.o",
+   "--no-default-suppression --leaf-changes-only",
+   "data/test-diff-filter/test-PR27331-report-0.txt",
+   "output/test-diff-filter/test-PR27331-report-0.txt",
+  },
   // This should be the last entry
   {NULL, NULL, NULL, NULL, NULL}
 };