From 013a19c5fe300265f3fadc27963f84bde2c3b6ef Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 3 Feb 2021 13:47:46 +0100 Subject: [PATCH] Bug 27331 - Data member offset change not considered local 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 --- src/abg-ir.cc | 3 ++- tests/data/Makefile.am | 5 +++++ .../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 ...9.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 --git a/src/abg-ir.cc b/src/abg-ir.cc index 02f3cc24..dec85fe0 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 40ad0e44..68ad902b 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 00000000..8e02a0ae --- /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 00000000..361089b0 --- /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-P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OrKE+6o~r>PgTc2^Hq zE;<+Ax1BD)TBC8FAY<8Hl;IQ@vC&HlJJ^IfJ< z$bE(eF`PQmW@q7_f76skY6sw@kw>ii7^q1jL-v5KGa#o!(cFNk3HXT#I9}NlGN6!x zQvJmV__6-P-UjS$+NGFA7y0<*q~08@=nXVau1-ZJoK~?Nhl5$k72c5Zc@39Sz^;pk zDjIbG%G5$c6eoG!w<0uZs4;t08`&qGG?j5{s+ZSFFxd>vut0aN_ z0WNhQxXmyGH{d zgQ4IqwwDtMuXS4n;=4PY!0U5a_-nF7^ry2>`>Dd!r7*fLa(;A^V&E(?!t~C$DeZNp z`=3VxI`3EYucEIWlX9y3_h^zJ-IgAF`oh%{HYBdcpFMaeak^Iosk=!Z3!+v0=`jia ziv}bSv(c#AZlXrV$aqbHm62yG=(g7oPOJZKS-u)2b$3zJ3NbovM5~SPi zpe`-HEt^v96XmCOL(jj57{yd|q8QO*ndnyqNUriL{x#xh{z5i$`9J)>mHwI;JQ#Zn zjdAgM*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 3e50dc70..249651fd 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 50e2f226..9bc27503 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} };