]> sourceware.org Git - libabigail.git/commitdiff
ir: Arrays are indirect types for type structure similarity purposes
authorGiuliano Procida <gprocida@google.com>
Thu, 3 Dec 2020 15:09:16 +0000 (15:09 +0000)
committerDodji Seketeli <dodji@redhat.com>
Sat, 5 Dec 2020 10:04:01 +0000 (11:04 +0100)
As described in the comments of types_have_similar_structure:

    "Two indirect types have similar structure if their underlying
    types are of the same kind and have the same name. [...] The size
    of their underlying type does not matter"

Yet, the size of array elements (a.k.a the underlying type of an array
type) is wrongly considered to matter when assessing the "type
structure similarity" relationship for arrays.

This patch fixes that.

* src/abg-ir.cc (types_have_similar_structure): When examining
array types, always treat element types as being underlying types
of an indirect type.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-non-leaf-array-report.txt:
New test case showing correct --leaf-changes-only reporting.
* tests/data/test-abidiff-exit/test-non-leaf-array-v0.c:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v0.o:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v1.c:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v1.o:
Likewise.
* tests/test-abidiff-exit.cc: Run new test case.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc
tests/data/Makefile.am
tests/data/test-abidiff-exit/test-non-leaf-array-report.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-non-leaf-array-v0.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-non-leaf-array-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-non-leaf-array-v1.c [new file with mode: 0644]
tests/data/test-abidiff-exit/test-non-leaf-array-v1.o [new file with mode: 0644]
tests/test-abidiff-exit.cc

index e654e18e62c7db44cb007c1f1ac6ae866fb05a9f..7b060a005bd4be8b00b65f1edf0bb9acace3f60b 100644 (file)
@@ -23608,7 +23608,7 @@ types_have_similar_structure(const type_base* first,
          || ty1->get_dimension_count() != ty2->get_dimension_count()
          || !types_have_similar_structure(ty1->get_element_type(),
                                           ty2->get_element_type(),
-                                          indirect_type))
+                                          /*indirect_type=*/true))
        return false;
 
       return true;
index 844471852092c9a81e682fed7aa43fdf6b0ddb90..f1d7ee4502d2beace1e2182d4b39f9156a5fec33 100644 (file)
@@ -184,6 +184,11 @@ test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.c \
 test-abidiff-exit/test-headers-dirs/test-headers-dir-v0.o \
 test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.c \
 test-abidiff-exit/test-headers-dirs/test-headers-dir-v1.o \
+test-abidiff-exit/test-non-leaf-array-v0.c \
+test-abidiff-exit/test-non-leaf-array-v0.o \
+test-abidiff-exit/test-non-leaf-array-v1.c \
+test-abidiff-exit/test-non-leaf-array-v1.o \
+test-abidiff-exit/test-non-leaf-array-report.txt \
 \
 test-diff-dwarf/test0-v0.cc            \
 test-diff-dwarf/test0-v0.o                     \
diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-report.txt b/tests/data/test-abidiff-exit/test-non-leaf-array-report.txt
new file mode 100644 (file)
index 0000000..f13cd0d
--- /dev/null
@@ -0,0 +1,11 @@
+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 buzz at test-non-leaf-array-v0.c:1:1' changed:
+  type size changed from 32 to 64 (in bits)
+  there are data member changes:
+    type 'int' of 'buzz::a' changed:
+      type name changed from 'int' to 'long int'
+      type size changed from 32 to 64 (in bits)
diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v0.c b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.c
new file mode 100644 (file)
index 0000000..9594c39
--- /dev/null
@@ -0,0 +1,12 @@
+struct buzz {
+  int a;
+};
+
+struct flexible {
+  long count;
+  struct buzz lightyear[0];
+};
+
+struct flexible var;
+void fun(struct flexible flex) { (void) flex; }
+
diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v0.o b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.o
new file mode 100644 (file)
index 0000000..f45eecb
Binary files /dev/null and b/tests/data/test-abidiff-exit/test-non-leaf-array-v0.o differ
diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v1.c b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.c
new file mode 100644 (file)
index 0000000..516c8b1
--- /dev/null
@@ -0,0 +1,12 @@
+struct buzz {
+  long a;
+};
+
+struct flexible {
+  long count;
+  struct buzz lightyear[0];
+};
+
+struct flexible var;
+void fun(struct flexible flex) { (void) flex; }
+
diff --git a/tests/data/test-abidiff-exit/test-non-leaf-array-v1.o b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.o
new file mode 100644 (file)
index 0000000..298dda0
Binary files /dev/null and b/tests/data/test-abidiff-exit/test-non-leaf-array-v1.o differ
index bb0262bb33a28070cdb6eedfe62d087a8e0f8457..bf1facc4ea0b096ca074740e21d9834fb5ce9331 100644 (file)
@@ -337,6 +337,17 @@ InOutSpec in_out_specs[] =
     "data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt",
     "output/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt"
   },
+  {
+    "data/test-abidiff-exit/test-non-leaf-array-v0.o",
+    "data/test-abidiff-exit/test-non-leaf-array-v1.o",
+    "",
+    "",
+    "",
+    "--leaf-changes-only",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/test-non-leaf-array-report.txt",
+    "output/test-abidiff-exit/test-non-leaf-array-report.txt"
+  },
   {0, 0, 0 ,0, 0, 0, abigail::tools_utils::ABIDIFF_OK, 0, 0}
 };
 
This page took 0.065344 seconds and 5 git commands to generate.