]> sourceware.org Git - libabigail.git/commit
Support suppressing data member insertion before a flexible array member
authorDodji Seketeli <dodji@redhat.com>
Thu, 5 Oct 2023 11:32:21 +0000 (13:32 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 18 Oct 2023 09:08:58 +0000 (11:08 +0200)
commitb12ba51e62de7c61526bd0a0cac6cc9bcf28fdee
tree1c6701f069454303fbfd1da98543d98195462dc2
parentd38ee66d6b8d63f3390e20d735f15293bde7fe0d
Support suppressing data member insertion before a flexible array member

Consider this code example:

    $ cat test-v0.c
     1 struct foo
     2 {
     3   int member0;
     4   char pad[]; /* <-- flexible array member.  */
     5 };
     6
     7 void
     8 foo(struct foo * p __attribute__((unused)))
     9 {
    10 }
    $

Consider this new version of the code where a data member has been
added right before the flexible array member:

    $ cat -n test-v1.c
     1 struct foo
     2 {
     3   int member0;
     4   char member1; /*<-- added member.  */
     5   char pad[]; /* <-- flexible array member.  */
     6 };
     7
     8 void
     9 foo(struct foo * p __attribute__((unused)))
    10 {
    11 }
    $

Here is what abidiff reports about the change:

    $ abidiff test-v0.o test-v1.o || echo "returned value: $?"
    Functions changes summary: 0 Removed, 1 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    1 function with some indirect sub-type change:

      [C] 'function void foo(foo*)' at test-v0.c:8:1 has some indirect sub-type changes:
parameter 1 of type 'foo*' has sub-type changes:
  in pointed to type 'struct foo' at test-v1.c:1:1:
    type size changed from 32 to 64 (in bits)
    1 data member insertion:
      'char member1', at offset 32 (in bits) at test-v1.c:4:1
    1 data member change:
      'char pad[]' offset changed from 32 to 40 (in bits) (by +8 bits)

    returned value: 4
    $

This patch allows users to suppress this change report using a new
property value to the "has_data_member_inserted_at" property of the
[suppress_type] directive.  The resulting suppression specification
reads:

    $ cat -n foo.suppr
 1 [suppress_type]
 2  type_kind = struct
         3       name = foo
 4  has_data_member_inserted_at = offset_of_flexible_array_data_member
 5  has_size_change = yes
    $

With this suppression specification the previous command now gives:

    $ abidiff --suppr foo.suppr test-v0.o test-v1.o && echo "returned value: $?"
    Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    returned value: 0
    $

The patch adds new test cases and updates the documentation to add a
mention to the new offset_of_flexible_array_data_member named
boundary.

* doc/manuals/libabigail-concepts.rst: Add documentation for the
new "offset_of_flexible_array_data_member" named boundary.
* include/abg-fwd.h (has_flexible_array_data_member): Declare new
function.
* src/abg-ir.cc (has_flexible_array_data_member): Define it.
* include/abg-suppression.h
(type_suppression::insertion_range::named_boundary_sptr): Define
new typedef.
(type_suppression::insertion_range::create_named_boundary): Declare
new static function member function.
(is_named_boundary): Declare new function.
(class type_suppression::insertion_range::named_boundary): Declare
new type.
* src/abg-suppression.cc
(struct type_suppression::insertion_range::named_boundary::priv):
Define new private type.
(OFFSET_OF_FLEXIBLE_ARRAY_DATA_MEMBER_STRING): Define new static
constant string getter function.
(type_suppression::insertion_range::create_named_boundary): Define
new static member function.
(is_named_boundary): Define new function.
(read_type_suppression): Parse the new
"offset_of_flexible_array_data_member" named boundary.
(type_suppression::insertion_range::eval_boundary): Evaluate the
new "offset_of_flexible_array_data_member" named boundary.
* tests/data/test-abidiff-exit/test-fam1-report-[1-5].txt: New
reference test output.
* tests/data/test-abidiff-exit/test-fam2-report-1.txt: Likewise.
* tests/data/test-abidiff-exit/test-fam1-suppr-[1-4].abignore: New test
suppression specification.
* tests/data/test-abidiff-exit/test-fam{1,2}-v{0,1}.o: New test input
binaries.
* tests/data/test-abidiff-exit/test-fam{1,2}-v{0,1}.c: Source code of
the test input binaries.
* tests/data/Makefile.am: Add the new test material to the source
distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the new test
input to this harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
25 files changed:
doc/manuals/libabigail-concepts.rst
include/abg-fwd.h
include/abg-suppression.h
src/abg-ir.cc
src/abg-suppression.cc
tests/data/Makefile.am
tests/data/test-abidiff-exit/test-fam1-report-1.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-report-2.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-report-3.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-report-4.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-report-5.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-suppr-1.abignore [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-suppr-2.abignore [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-suppr-3.abignore [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-suppr-4.abignore [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-v0.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-v1.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam1-v1.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam2-report-1.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam2-v0.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam2-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam2-v1.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-fam2-v1.o [new file with mode: 0644]
tests/test-abidiff-exit.cc
This page took 0.037128 seconds and 5 git commands to generate.