Better propagation of suppressed-ness to function types
authorDodji Seketeli <dodji@redhat.com>
Wed, 4 Sep 2019 09:10:31 +0000 (11:10 +0200)
committerDodji Seketeli <dodji@redhat.com>
Mon, 30 Sep 2019 12:56:41 +0000 (14:56 +0200)
In the comparison engine, when a sub-type of a function type (say, a
parameter type size change) has been suppressed, this suppression is
not necessarily well propagated to the function carrying the function
type, because the parameter type size, for instance, is considered as
a type local change to that function; and we generally don't propagate
suppression to a non-suppressed parent diff node that already carries
a local change.

This leads to an empty change report for the function we are looking
at because the only sub-type change has been suppressed.

This patch properly propagates the suppressed-ness in that case, so
that the parent function diff node is suppressed as well.

* src/abg-comparison.cc
(suppression_categorization_visitor::visit_end): Propagate
suppression-ness from suppressed function type diff node to its
parent function node if the latter doesn't have any local non-type
change.
* tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt:
New test reference output.
* tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt:
New test input suppression file.
* tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v{0,1}.cc:
Source code of input binary file.
* tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v{0,1}.o:
Input binary files.
* tests/data/Makefile.am: Add the new test input files above to
source distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the test input to
test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-comparison.cc
tests/data/Makefile.am
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt [new file with mode: 0644]
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt [new file with mode: 0644]
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.cc [new file with mode: 0644]
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o [new file with mode: 0644]
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.cc [new file with mode: 0644]
tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o [new file with mode: 0644]
tests/test-diff-suppr.cc

index 55033b09677b843bf5efd2c0ec12fc3172f4e19e..18ebd10911e39ea9edc0c4c068a9e19087ec89e2 100644 (file)
@@ -10798,6 +10798,12 @@ struct suppression_categorization_visitor : public diff_node_visitor
            || is_pointer_diff(d)
            || is_reference_diff(d)
            || (is_qualified_type_diff(d)
+               && (!(d->has_local_changes() & LOCAL_NON_TYPE_CHANGE_KIND)))
+           || (is_function_decl_diff(d)
+               && (!(d->has_local_changes() & LOCAL_NON_TYPE_CHANGE_KIND)))
+           || (is_fn_parm_diff(d)
+               && (!(d->has_local_changes() & LOCAL_NON_TYPE_CHANGE_KIND)))
+           || (is_function_type_diff(d)
                && (!(d->has_local_changes() & LOCAL_NON_TYPE_CHANGE_KIND)))))
       {
        // Note that we handle private diff nodes differently from
@@ -10884,6 +10890,27 @@ struct suppression_categorization_visitor : public diff_node_visitor
              canonical_diff->add_to_category
                (SUPPRESSED_CATEGORY|PRIVATE_TYPE_CATEGORY);
          }
+
+       if (const function_decl_diff *fn_diff = is_function_decl_diff(d))
+         if (!(d->has_local_changes() & LOCAL_NON_TYPE_CHANGE_KIND))
+           {
+             // d is a function diff that carries a local *type*
+             // change (that means it's a change to the function
+             // type).  Let's see if the child function type diff
+             // node is suppressed.  That would mean that we are
+             // instructed to show details of a diff that is deemed
+             // suppressed; this means the suppression conflicts with
+             // a local type change.  In that case, let's follow what
+             // the user asked and suppress the function altogether,
+             if (function_type_diff_sptr fn_type_diff = fn_diff->type_diff())
+               if (fn_type_diff->is_suppressed())
+                 d->add_to_category(SUPPRESSED_CATEGORY);
+           // If a node was suppressed, all the other nodes of its class
+           // of equivalence are suppressed too.
+           diff *canonical_diff = d->get_canonical_diff();
+           if (canonical_diff != d)
+             canonical_diff->add_to_category(SUPPRESSED_CATEGORY);
+         }
       }
   }
 }; //end struct suppression_categorization_visitor
index 5b52186b3df94d4e8d5f4f7dea3674082f40dde7..57551db5685bbd128e5b31a1e961312d118b6686 100644 (file)
@@ -1205,6 +1205,12 @@ test-diff-suppr/test41-enumerator-changes-0.suppr \
 test-diff-suppr/test41-enumerator-changes-report-0.txt \
 test-diff-suppr/test41-enumerator-changes-v0.cc \
 test-diff-suppr/test41-enumerator-changes-v1.cc \
+test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt \
+test-diff-suppr/test43-suppr-direct-fn-subtype-v0.cc \
+test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o \
+test-diff-suppr/test43-suppr-direct-fn-subtype-v1.cc \
+test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o \
+test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt \
 \
 test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1 \
 test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi \
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt
new file mode 100644 (file)
index 0000000..9666a8f
--- /dev/null
@@ -0,0 +1,3 @@
+Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt
new file mode 100644 (file)
index 0000000..051f30a
--- /dev/null
@@ -0,0 +1,2 @@
+[suppress_type]
+  name = type
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.cc b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.cc
new file mode 100644 (file)
index 0000000..b1a3013
--- /dev/null
@@ -0,0 +1,9 @@
+struct type
+{
+  int m0;
+};
+
+void
+func0(struct type)
+{
+}
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o
new file mode 100644 (file)
index 0000000..fe0ee04
Binary files /dev/null and b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o differ
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.cc b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.cc
new file mode 100644 (file)
index 0000000..07e8942
--- /dev/null
@@ -0,0 +1,10 @@
+struct type
+{
+  int m0;
+  char m1;
+};
+
+void
+func0(struct type)
+{
+}
diff --git a/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o
new file mode 100644 (file)
index 0000000..13e1134
Binary files /dev/null and b/tests/data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o differ
index 8cbb8b7c657ab2bb02bbd17e275e4afd932fa84d..dfc828831f927b17f139cf9d1b898d1254e8b402 100644 (file)
@@ -1748,6 +1748,16 @@ InOutSpec in_out_specs[] =
     "data/test-diff-suppr/test41-enumerator-changes-report-0.txt",
     "output/test-diff-suppr/test41-enumerator-changes-report-0.txt"
   },
+  {
+    "data/test-diff-suppr/test43-suppr-direct-fn-subtype-v0.o",
+    "data/test-diff-suppr/test43-suppr-direct-fn-subtype-v1.o",
+    "",
+    "",
+    "data/test-diff-suppr/test43-suppr-direct-fn-subtype-suppr-1.txt",
+    "--no-default-suppression",
+    "data/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt",
+    "output/test-diff-suppr/test43-suppr-direct-fn-subtype-report-1.txt"
+  },
   // This should be the last entry
   {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 };