From patchwork Wed Apr 22 21:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39121 From: gprocida@google.com (Giuliano Procida) Date: Wed, 22 Apr 2020 22:20:57 +0100 Subject: [PATCH 1/3] Add tests for declaration-only struct diffs. Message-ID: <20200422212059.258602-1-gprocida@google.com> There were no tests exercising this reporting path. The new test is run with --harmless as these changes are considered harmless. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: New test case generating "declaration-only" output. * tests/data/test-abidiff-exit/test-decl-struct-v0.c: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v0.o: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v1.c: Ditto. * tests/data/test-abidiff-exit/test-decl-struct-v1.o: Ditto. * tests/test-abidiff-exit.cc: Run new test case. Signed-off-by: Giuliano Procida --- tests/data/Makefile.am | 5 +++++ .../test-decl-struct-report.txt | 17 +++++++++++++++++ .../test-abidiff-exit/test-decl-struct-v0.c | 5 +++++ .../test-abidiff-exit/test-decl-struct-v0.o | Bin 0 -> 3016 bytes .../test-abidiff-exit/test-decl-struct-v1.c | 5 +++++ .../test-abidiff-exit/test-decl-struct-v1.o | Bin 0 -> 3016 bytes tests/test-abidiff-exit.cc | 9 +++++++++ 7 files changed, 41 insertions(+) create mode 100644 tests/data/test-abidiff-exit/test-decl-struct-report.txt create mode 100644 tests/data/test-abidiff-exit/test-decl-struct-v0.c create mode 100644 tests/data/test-abidiff-exit/test-decl-struct-v0.o create mode 100644 tests/data/test-abidiff-exit/test-decl-struct-v1.c create mode 100644 tests/data/test-abidiff-exit/test-decl-struct-v1.o diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 6e926ebd..a1b9bf64 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -146,6 +146,11 @@ test-abidiff-exit/test-member-size-v1.cc \ test-abidiff-exit/test-member-size-v1.o \ test-abidiff-exit/test-member-size-report0.txt \ test-abidiff-exit/test-member-size-report1.txt \ +test-abidiff-exit/test-decl-struct-v0.c \ +test-abidiff-exit/test-decl-struct-v0.o \ +test-abidiff-exit/test-decl-struct-v1.c \ +test-abidiff-exit/test-decl-struct-v1.o \ +test-abidiff-exit/test-decl-struct-report.txt \ \ test-diff-dwarf/test0-v0.cc \ test-diff-dwarf/test0-v0.o \ diff --git a/tests/data/test-abidiff-exit/test-decl-struct-report.txt b/tests/data/test-abidiff-exit/test-decl-struct-report.txt new file mode 100644 index 00000000..aa5dedae --- /dev/null +++ b/tests/data/test-abidiff-exit/test-decl-struct-report.txt @@ -0,0 +1,17 @@ +Functions changes summary: 0 Removed, 2 Changed, 0 Added functions +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +2 functions with some indirect sub-type change: + + [C] 'function void reg1(const embodied*)' at test-decl-struct-v1.c:4:1 has some indirect sub-type changes: + parameter 1 of type 'const embodied*' has sub-type changes: + in pointed to type 'const embodied': + in unqualified underlying type 'struct embodied' at test-decl-struct-v1.c:1:1: + type size changed from 0 to 32 (in bits) + type struct embodied was a declaration-only type and is now a defined type + [C] 'function void reg2(const disembodied*)' at test-decl-struct-v1.c:5:1 has some indirect sub-type changes: + parameter 1 of type 'const disembodied*' has sub-type changes: + in pointed to type 'const disembodied': + in unqualified underlying type 'struct disembodied': + type size changed from 32 to 0 (in bits) + type struct disembodied was a defined type and is now a declaration-only type diff --git a/tests/data/test-abidiff-exit/test-decl-struct-v0.c b/tests/data/test-abidiff-exit/test-decl-struct-v0.c new file mode 100644 index 00000000..2aca0211 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-decl-struct-v0.c @@ -0,0 +1,5 @@ +struct embodied; +struct disembodied { int x; }; + +void reg1(const struct embodied * foo) { (void)foo; } +void reg2(const struct disembodied * foo) { (void)foo; } diff --git a/tests/data/test-abidiff-exit/test-decl-struct-v0.o b/tests/data/test-abidiff-exit/test-decl-struct-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..030f443128d0e318695a7f8b4301c747741f34d7 GIT binary patch literal 3016 zcmbVO&2Jk;6o2EjV~1_FNlhUk99&WQA=t$mp%S-EF$B_9MHMP4LP#jA?TKv>udCg4 zNkNDT@u6N&k&qA)2L%5Cf&&*MgpfFM>x~N%S8hlg;Jw*-&SbK=^hut1@Auws=Iz^g zvwr`@mo`d50E>VNuxl|2P^<3hZKbxM4oBenr8|FKy7S&Yci;HMP=CgVvWlvy#SSUm z7#=e866s}8s%_xx?0_geaz(kzK2DW#Wf*5LLx`xTiBy*c6!Fz<9IIR7F?vssUixeR zHMLgGDHm|QpK{8N{iHdwI768{wc3xQiv{txS9cw6*;^1ts`C%y+I8W0u6x!!=eAr? z$8_hwspaP7`YI+>J^_~zuN(*0z2G`EfSEu%yX1Iz(8(oQs=fHd^GigpRt$P+5w|{! zJX&D34vu$z3DbBIf2u@)iy2~;(17788jfNK@vk=r0tF%b3CLuc`90a)_R}nxbTj{E zGw3REvCXjFQ6?4yaVukeGk|~cx&v|f%};1O*q>; zAABxCP=`bB%uW6P+N_g{Ga#Ivc7Z??o*9=p3`h0M_-$=dCz4R+(>_7{G=V4-Z}w-P z&>W|IE82d=!r#^Q>w4z(`T0Mw;`A#&|CX*=HkS27H-W9chJU;MTa zL+Wq&-vDT60-ZO4xL5F-r(_LBdrfjIYmoau1sBA=T!2yRH=5rh!w`F~E9fiA|1aGv z%%}Y6HnsEbA!e_M5d5yeYh)N=$8MspX#Yihptw%7Kiwzx{x=Y#H91dIl^oYi%J&81 zyg$!$4;Ash(|kH#rZA7^57EiG8F$aTBn*cg`=#dF;eTl0HG@kkKR?5tqf%7Armi2? zh3ZFNE9P@uDIa@pgkV)S)IcXp-wpZ-+I)H^cJCnsUsF;j$MR`9+Rsnx7V+QI`F}fQ I=8Db#AFEN&ivR!s literal 0 HcmV?d00001 diff --git a/tests/data/test-abidiff-exit/test-decl-struct-v1.c b/tests/data/test-abidiff-exit/test-decl-struct-v1.c new file mode 100644 index 00000000..c069fa5e --- /dev/null +++ b/tests/data/test-abidiff-exit/test-decl-struct-v1.c @@ -0,0 +1,5 @@ +struct embodied { int y; }; +struct disembodied; + +void reg1(const struct embodied * foo) { (void)foo; } +void reg2(const struct disembodied * foo) { (void)foo; } diff --git a/tests/data/test-abidiff-exit/test-decl-struct-v1.o b/tests/data/test-abidiff-exit/test-decl-struct-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..ee0b463b7052f715fad177dd718d6464f8f0790e GIT binary patch literal 3016 zcmbVO-ESL35TEtgvBNb-Qd62JJh-Btf;(~%DskHsLm+KcRH0U_DkK!n_Qtk|&(+-uhCBSKg3#fSJ7=d%JO7I+Ay0e>1<`xw)M^ zfAsnr>jfczMZkF&&lm-$l*e{MnGLAILAZYL&clm$KK$qI+rJv-FBnl&Q5Ch=0c9J* z(}rCjyC_6u9ksIqLL9!V+(jQ%saWd88B7r(N=lLG(tskq-^H=KIT)b#_?KuG?scJp z8j8C(Ojka`F=rPiu<|<=CRCG zaJ+L1nD>*o0IdYiQ&#vxry6-MOUM}MEBJF1ONf8H87!xIz4#skWHQbCwrp+rX_gFI znSVPBT8dmc3Dfy5I6YLF|D^QXDvkvQ`HAd=(C($O-yF1ivJDrmT(7N#FV*V7auC** zm%@4&F4b#(KO4q!wIgGh^jbKLl2&(hd*!r$`o)^xsrj2xx)Zm$$sisKQ-2u0*NfYJ z7B#nIx=(7j^)kGW^>4vwbGWd!cBXdnHQDS%ah`%7)=yc%e_X z^(LI>toJ_`A*jQlcjnf90_SX#i!&gco_3Bv6xNK(9EL+$Grp_m*pf;p^HHCmeJY26 z;?4dH44n3*TZrUZu2ekXAL#j8TJ!q+{2yEKB|X1q;d%<+YJ=BdoNGdP@*3ou)d6<= z*?sVu#;FEo9U2zS`9qNI^s&WJXGyNRY-MsggPhzQP7snVP~TkZw}C> z?5NpHB9Usyb>?*%+OThHiZ$g3P6)F*{)QQ3*f#$J`sn;UE#IERhk%L$8Ml+(*E=MKyjUDf4Vp9{cj;gYjU1w zDmki~^eYCm=KWdIJv52`v*y$JGKG1pKSd|oX563VC1E)1*zYvo4u7D5n+BImetw3( zMq^U_mUR8NE>u7IS}~vNO8MA(BLpkDp}IO@`fkuy(B{)Sv3n08_<@o_Ig+c X-Patchwork-Id: 39122 From: gprocida@google.com (Giuliano Procida) Date: Wed, 22 Apr 2020 22:20:58 +0100 Subject: [PATCH 2/3] abidiff: Blank line after declaration-only diff. In-Reply-To: <20200422212059.258602-1-gprocida@google.com> References: <20200422212059.258602-1-gprocida@google.com> Message-ID: <20200422212059.258602-2-gprocida@google.com> In the case where a type change is summarised as declaration-only to defined or vice versa, the trailing new line was missing. * src/abg-default-reporter.cc (default_reporter::report): In the class_or_union_diff overload, emit a new line at the end of the declaration-only reporting path. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: Add missing blank lines. Signed-off-by: Giuliano Procida --- src/abg-default-reporter.cc | 2 +- tests/data/test-abidiff-exit/test-decl-struct-report.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/abg-default-reporter.cc b/src/abg-default-reporter.cc index ff7ed67e..04e2bb76 100644 --- a/src/abg-default-reporter.cc +++ b/src/abg-default-reporter.cc @@ -859,7 +859,7 @@ default_reporter::report(const class_or_union_diff& d, : " and is now a defined type"; out << indent << "type " << first->get_pretty_representation() - << was << is_now; + << was << is_now << "\n"; return; } diff --git a/tests/data/test-abidiff-exit/test-decl-struct-report.txt b/tests/data/test-abidiff-exit/test-decl-struct-report.txt index aa5dedae..8bb712e6 100644 --- a/tests/data/test-abidiff-exit/test-decl-struct-report.txt +++ b/tests/data/test-abidiff-exit/test-decl-struct-report.txt @@ -9,9 +9,11 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable in unqualified underlying type 'struct embodied' at test-decl-struct-v1.c:1:1: type size changed from 0 to 32 (in bits) type struct embodied was a declaration-only type and is now a defined type + [C] 'function void reg2(const disembodied*)' at test-decl-struct-v1.c:5:1 has some indirect sub-type changes: parameter 1 of type 'const disembodied*' has sub-type changes: in pointed to type 'const disembodied': in unqualified underlying type 'struct disembodied': type size changed from 32 to 0 (in bits) type struct disembodied was a defined type and is now a declaration-only type + From patchwork Wed Apr 22 21:20:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39123 From: gprocida@google.com (Giuliano Procida) Date: Wed, 22 Apr 2020 22:20:59 +0100 Subject: [PATCH 3/3] abidiff: Omit declaration-only type size 0 diffs. In-Reply-To: <20200422212059.258602-1-gprocida@google.com> References: <20200422212059.258602-1-gprocida@google.com> Message-ID: <20200422212059.258602-3-gprocida@google.com> When reporting declaration-only type changes, the size is reported as changing to or from 0, which is not correct. The declaration type is of unknown size. This patch eliminates such size reports. * src/abg-reporter-priv.cc (report_size_and_alignment_changes): Filter out declaration-only / defined type size changes unconditionally. * tests/data/test-abidiff-exit/test-decl-struct-report.txt: Update test. Signed-off-by: Giuliano Procida --- src/abg-reporter-priv.cc | 9 ++++----- tests/data/test-abidiff-exit/test-decl-struct-report.txt | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc index bdf6690d..4ea591aa 100644 --- a/src/abg-reporter-priv.cc +++ b/src/abg-reporter-priv.cc @@ -714,12 +714,11 @@ report_size_and_alignment_changes(type_or_decl_base_sptr first, class_or_union_sptr first_class = is_class_or_union_type(first), second_class = is_class_or_union_type(second); - if (filtering::has_class_decl_only_def_change(first_class, second_class) - && !(ctxt->get_allowed_category() & CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY)) + if (filtering::has_class_decl_only_def_change(first_class, second_class)) // So these two classes differ only by the fact that one is the - // declaration-only form of the second. And the user asked that - // this kind of change be filtered out, so do not report any size - // change due to this. + // declaration-only form of the second. The declaration-only class + // is of unknown size (recorded as 0) and it is not meaningful to + // report a size change. return; unsigned fs = f->get_size_in_bits(), ss = s->get_size_in_bits(), diff --git a/tests/data/test-abidiff-exit/test-decl-struct-report.txt b/tests/data/test-abidiff-exit/test-decl-struct-report.txt index 8bb712e6..f1fa2077 100644 --- a/tests/data/test-abidiff-exit/test-decl-struct-report.txt +++ b/tests/data/test-abidiff-exit/test-decl-struct-report.txt @@ -7,13 +7,11 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable parameter 1 of type 'const embodied*' has sub-type changes: in pointed to type 'const embodied': in unqualified underlying type 'struct embodied' at test-decl-struct-v1.c:1:1: - type size changed from 0 to 32 (in bits) type struct embodied was a declaration-only type and is now a defined type [C] 'function void reg2(const disembodied*)' at test-decl-struct-v1.c:5:1 has some indirect sub-type changes: parameter 1 of type 'const disembodied*' has sub-type changes: in pointed to type 'const disembodied': in unqualified underlying type 'struct disembodied': - type size changed from 32 to 0 (in bits) type struct disembodied was a defined type and is now a declaration-only type