Better detect when diff nodes only carry local type changes
authorDodji Seketeli <dodji@redhat.com>
Wed, 23 May 2018 09:43:29 +0000 (11:43 +0200)
committerDodji Seketeli <dodji@redhat.com>
Thu, 24 May 2018 14:04:44 +0000 (16:04 +0200)
commit11c2437a19ee000b9217c81670813611ed0bc312
tree6b392ca4d17f633d53b6d3ee7e6f548901145f38
parent1ef833b38d176abc720b5cb36075c43b4bc2c82a
Better detect when diff nodes only carry local type changes

For some fine grain redundancy filtering, we need to know when a diff
node carries *only* a basic type change.  This is because basic type
changes should not be marked as redundant; we want to see all of them
-- unlike for class or union (user defined) type changes.

And so to know if a diff node carries only a basic type change, we
need to know if a diff node only carries a local type change.  If it
carries only a type change, we can safely just look at that type
change and see if it's a basic type change or not.

So, we then need to know what kind of local changes a diff node
carries: type change or non-type change.  That way, we can analyze the
local changes a node carries and infer that it only carries a local
type change or if it also carries a non-type change.

This patch thus changes the diff::has_local_changes() pure virtual member
function to make it return the enum change_kind bitmask, which
describes the different kinds of local changes the diff node has.

Note that two new bit values were added to that enum:
LOCAL_TYPE_CHANGE_KIND and LOCAL_NON_TYPE_CHANGE_KIND.  The first one
says that the diff node carries a local type change, while the second
one says that the diff node carries a local non-type change kind.

The various implementations of that interface are thus amended to make
them return the right bitmask.  To do this, the patch updates the
various 'equals' overloads to make them return the proper enum
change_kind bitmap with the LOCAL_TYPE_CHANGE_KIND and
LOCAL_NON_TYPE_CHANGE_KIND set, if need be.

* include/abg-comparison.h ({diff, type_diff_base, decl_diff_base,
distinct_diff, var_diff, pointer_diff, reference_diff, array_diff,
qualified_type, enum_diff, class_or_union_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_type_diff,
function_decl_diff, typedef_diff,
translation_unit_diff}::has_local_changes): Return an enum
change_kind, rather than just a bool.
(is_diff_of_basic_type): Declare an overload that takes a boolean
flag.
(is_qualified_type_diff, peel_pointer_diff, peel_reference_diff)
(peel_qualified_type, peel_pointer_or_qualified_type): Declare new
functions
* include/abg-fwd.h (peel_qualified_type):
* include/abg-ir.h (enum change_kind::{LOCAL_TYPE_CHANGE_KIND,
LOCAL_NON_TYPE_CHANGE_KIND, ALL_LOCAL_CHANGES_MASK}): Add these
three new enumerators.
* src/abg-comparison.cc ({distinct_diff, var_diff, pointer_diff,
array_diff, reference_diff, qualified_type_diff, enum_diff,
class_or_union_diff, class_diff, base_diff, scope_diff,
fn_parm_diff, function_type_diff, function_decl_diff,
type_decl_diff, typedef_diff,
translation_unit_diff}::has_local_changes): Adjust to return an
enum change_kind, rather than just a bool.
(has_local_type_change_only): Define new functions.
(has_basic_type_change_only): Use the new
has_local_type_change_only function and the new overload for
is_diff_of_basic_type.
(is_diff_of_basic_type): Define an overload that takes a boolean
flag.
(is_qualified_type_diff, peel_pointer_diff, peel_reference_diff)
(peel_qualified_type, peel_pointer_or_qualified_type): Define new
functions.
* src/abg-ir.cc (equals): In the overloads for decl_base,
scope_decl, type_base, qualified_type_diff, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_or_union, class_decl::base_spec and class_decl, properly set
the new abigail::ir::{LOCAL_CHANGE_KIND,
LOCAL_NON_TYPE_CHANGE_KIND, LOCAL_TYPE_CHANGE_KIND} bits.
(types_have_similar_structure): Peel qualified types and typedefs
off, first thing.
(peel_qualified_or_typedef_type): Define new function.
* 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/libtest45-basic-type-change-report-{0,1}.txt:
New reference test reports.
* tests/data/test-diff-filter/libtest45-basic-type-change-v{0,1}.so:
New input test binaries.
* tests/data/test-diff-filter/test45-basic-type-change-v{0,1}.cc:
Source code of the input test binaries above.
* tests/data/Makefile.am: Add the new test file above to source
distribution.
* tests/test-diff-filter.cc: Add the test input above to the test
harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
14 files changed:
include/abg-comparison.h
include/abg-fwd.h
include/abg-ir.h
src/abg-comparison.cc
src/abg-ir.cc
tests/data/Makefile.am
tests/data/test-diff-filter/libtest45-basic-type-change-report-0.txt [new file with mode: 0644]
tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt [new file with mode: 0644]
tests/data/test-diff-filter/libtest45-basic-type-change-v0.so [new file with mode: 0755]
tests/data/test-diff-filter/libtest45-basic-type-change-v1.so [new file with mode: 0755]
tests/data/test-diff-filter/test45-basic-type-change-v0.cc [new file with mode: 0644]
tests/data/test-diff-filter/test45-basic-type-change-v1.cc [new file with mode: 0644]
tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt
tests/test-diff-filter.cc