Fix redundancy categorization propagation

Propagating redundancy categorization is broken for cases where there
is a diff node that has children nodes carrying changes that are all
filtered out.  In that case, if among those children changes there is
a redundant change, normally the parent diff node we are look at
should be marked redundant too.  The bug is that it's not marked as
redundant at the moment.  This patch fixes that.

	* src/abg-comparison.cc (redundancy_marking_visitor::visit_end):
	Consider the cases of changes that are a filtered out.
	* tests/data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v{0,1}.so:
	New test binaries to use as test input.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-{0,1,2}.txt:
	New test result baselines.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-v{0,1}.cc:
	Source code for the test input binaries above.
	* tests/test-diff-filter.cc (in_out_spec): Add the binaries to the
	test inputs used for this test harness.
	* tests/data/Makefile.am: Add the new test material above to the
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2015-03-13 13:30:01 +01:00
parent 17c35386c5
commit 5244794279
10 changed files with 160 additions and 1 deletions

View File

@ -12493,7 +12493,8 @@ struct redundancy_marking_visitor : public diff_node_visitor
if ((*i)->has_changes())
{
has_non_empty_child = true;
if (((*i)->get_category() & REDUNDANT_CATEGORY) == 0)
if ((*i)->to_be_reported()
&& ((*i)->get_category() & REDUNDANT_CATEGORY) == 0)
has_non_redundant_child = true;
}
if (has_non_redundant_child)

View File

@ -367,6 +367,13 @@ test-diff-filter/test26-qualified-redundant-node-report-0.txt \
test-diff-filter/test26-qualified-redundant-node-report-1.txt \
test-diff-filter/test26-qualified-redundant-node-v0.cc \
test-diff-filter/test26-qualified-redundant-node-v1.cc \
test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so \
test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so \
test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt \
test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt \
test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt \
test-diff-filter/test27-redundant-and-filtered-children-nodes-v0.cc \
test-diff-filter/test27-redundant-and-filtered-children-nodes-v1.cc \
\
test-diff-suppr/test0-type-suppr-v0.cc \
test-diff-suppr/test0-type-suppr-v1.cc \

View File

@ -0,0 +1,12 @@
Functions changes summary: 0 Removed, 1 Changed (1 filtered out), 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function S0* bar(S1*, S2*)' has some indirect sub-type changes:
return type changed:
in pointed to type 'struct S0':
size changed from 32 to 64 bits
1 data member insertion:
'char S0::m1', at offset 32 (in bits)

View File

@ -0,0 +1,19 @@
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 S0* bar(S1*, S2*)' has some indirect sub-type changes:
return type changed:
in pointed to type 'struct S0':
size changed from 32 to 64 bits
1 data member insertion:
'char S0::m1', at offset 32 (in bits)
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
1 data member changes (2 filtered):
type of 'S0* S::m0' changed:
pointed to type 'struct S0' changed, as reported earlier

View File

@ -0,0 +1,31 @@
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 S0* bar(S1*, S2*)' has some indirect sub-type changes:
return type changed:
in pointed to type 'struct S0':
size changed from 32 to 64 bits
1 data member insertion:
'char S0::m1', at offset 32 (in bits)
parameter 0 of type 'S1*' changed:
in pointed to type 'struct S1':
entity changed from 'struct S1' to compatible type 'typedef S1Renamed'
parameter 1 of type 'S2*' changed:
in pointed to type 'struct S2':
entity changed from 'struct S2' to compatible type 'typedef S2Renamed'
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
3 data member changes:
type of 'S0* S::m0' changed:
pointed to type 'struct S0' changed, as reported earlier
type of 'S1* S::m1' changed:
in pointed to type 'struct S1':
entity changed from 'struct S1' to compatible type 'typedef S1Renamed'
type of 'S2* S::m2' changed:
in pointed to type 'struct S2':
entity changed from 'struct S2' to compatible type 'typedef S2Renamed'

View File

@ -0,0 +1,31 @@
// To compile this, do:
// g++ -g -shared test27-redundant-and-filtered-children-nodes-v0.cc -o libtest27-redundant-and-filtered-children-nodes-v0.so
struct S0
{
int m0;
};
struct S1
{
};
struct S2
{
};
struct S
{
S0* m0;
S1* m1;
S2* m2;
};
void
foo(S&)
{
}
S0*
bar(S1*, S2*)
{return 0;}

View File

@ -0,0 +1,37 @@
// To compile this, do:
// g++ -g -shared test27-redundant-and-filtered-children-nodes-v1.cc -o libtest27-redundant-and-filtered-children-nodes-v1.so
struct S0
{
int m0;
char m1;
};
typedef S0 S0Renamed;
struct S1
{
};
typedef S1 S1Renamed;
struct S2
{
};
typedef S2 S2Renamed;
struct S
{
S0* m0;
S1Renamed* m1;
S2Renamed* m2;
};
void
foo(S&)
{
}
S0*
bar(S1Renamed*, S2Renamed*)
{return 0;}

View File

@ -327,6 +327,27 @@ InOutSpec in_out_specs[] =
"data/test-diff-filter/test26-qualified-redundant-node-report-1.txt",
"output/test-diff-filter/test26-qualified-redundant-node-report-1.txt"
},
{
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
"--no-linkage-name --no-redundant",
"data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt",
"output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt"
},
{
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
"--no-linkage-name --redundant",
"data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt",
"output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt"
},
{
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v0.so",
"data/test-diff-filter/libtest27-redundant-and-filtered-children-nodes-v1.so",
"--no-linkage-name --redundant --harmless",
"data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt",
"output/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt"
},
// This should be the last entry
{NULL, NULL, NULL, NULL, NULL}
};