Categorize base class changes as SIZE_OR_OFFSET_CHANGE_CATEGORY

* include/abg-comparison.h (class_diff::{deleted, inserted,
	changed}_bases): Declare new member functions ...
	* src/abg-comparison.cc ((class_diff::{deleted, inserted,
	changed}_bases)): ... and define them.
	* src/abg-comp-filter.cc (base_classes_added_or_removed): Define
	new static functions.
	(harmless_filter): Categorize base classes added or removed.
	* tests/data/test-diff-dwarf/test8-report.txt: New test input.
	* tests/data/test-diff-dwarf/test8-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test8-v0.o: Likewise.
	* tests/data/test-diff-dwarf/test8-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test8-v1.o: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: New test input.
	* tests/data/test-diff-filter/test13-v0.cc: Likewise.
	* tests/data/test-diff-filter/test13-v0.o: Likewise.
	* tests/data/test-diff-filter/test13-v1.cc: Likewise.
	* tests/data/test-diff-filter/test13-v1.o: Likewise.
	* tests/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-dwarf.cc: Use the new relevant input above to
	run more tests.
	* tests/test-diff-filter.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-04-17 15:26:38 +02:00
parent a436ee1094
commit 262c39f763
16 changed files with 244 additions and 3 deletions

View File

@ -898,6 +898,15 @@ public:
edit_script&
base_changes();
const string_base_sptr_map&
deleted_bases() const;
const string_base_sptr_map&
inserted_bases() const;
const string_changed_base_map&
changed_bases();
const edit_script&
member_types_changes() const;

View File

@ -484,6 +484,28 @@ static bool
has_non_virtual_mem_fn_change(const diff* diff)
{return has_non_virtual_mem_fn_change(dynamic_cast<const class_diff*>(diff));}
/// Test if a class_diff carries base classes adding or removals.
///
/// @param diff the class_diff to consider.
///
/// @return true iff @p diff carries base classes adding or removals.
static bool
base_classes_added_or_removed(const class_diff* diff)
{
if (!diff)
return false;
return diff->deleted_bases().size() || diff->inserted_bases().size();
}
/// Test if a class_diff carries base classes adding or removals.
///
/// @param diff the class_diff to consider.
///
/// @return true iff @p diff carries base classes adding or removals.
static bool
base_classes_added_or_removed(const diff* diff)
{return base_classes_added_or_removed(dynamic_cast<const class_diff*>(diff));}
/// The visiting code of the harmless_filter.
///
/// @param d the diff node being visited.
@ -552,7 +574,8 @@ harmful_filter::visit(diff* d, bool pre)
if (type_size_changed(f, s)
|| data_member_offset_changed(f, s)
|| non_static_data_member_type_size_changed(f, s)
|| non_static_data_member_added_or_removed(d))
|| non_static_data_member_added_or_removed(d)
|| base_classes_added_or_removed(d))
category |= SIZE_OR_OFFSET_CHANGE_CATEGORY;
if (has_virtual_mem_fn_change(d))

View File

@ -3194,6 +3194,30 @@ const edit_script&
class_diff::base_changes() const
{return priv_->base_changes_;}
/// Getter for the deleted base classes of the diff.
///
/// @return a map containing the deleted base classes, keyed with
/// their pretty representation.
const string_base_sptr_map&
class_diff::deleted_bases() const
{return priv_->deleted_bases_;}
/// Getter for the inserted base classes of the diff.
///
/// @return a map containing the inserted base classes, keyed with
/// their pretty representation.
const string_base_sptr_map&
class_diff::inserted_bases() const
{return priv_->inserted_bases_;}
/// Getter for the changed base classes of the diff.
///
/// @return a map containing the changed base classes, keyed with
/// their pretty representation.
const string_changed_base_map&
class_diff::changed_bases()
{return priv_->changed_bases_;}
/// @return the edit script of the bases of the two classes.
edit_script&
class_diff::base_changes()

View File

@ -152,6 +152,11 @@ data/test-diff-dwarf/test7-v0.o \
data/test-diff-dwarf/test7-v1.cc \
data/test-diff-dwarf/test7-v1.o \
data/test-diff-dwarf/test7-report.txt \
data/test-diff-dwarf/test8-v0.cc \
data/test-diff-dwarf/test8-v0.o \
data/test-diff-dwarf/test8-v1.cc \
data/test-diff-dwarf/test8-v1.o \
data/test-diff-dwarf/test8-report.txt \
\
data/test-read-dwarf/test0 \
data/test-read-dwarf/test0.abi \
@ -224,7 +229,12 @@ data/test-diff-filter/test12-v0.cc \
data/test-diff-filter/test12-v1.cc \
data/test-diff-filter/test12-v0.o \
data/test-diff-filter/test12-v1.o \
data/test-diff-filter/test12-report.txt
data/test-diff-filter/test12-report.txt \
data/test-diff-filter/test13-v0.cc \
data/test-diff-filter/test13-v1.cc \
data/test-diff-filter/test13-v0.o \
data/test-diff-filter/test13-v1.o \
data/test-diff-filter/test13-report.txt
clean-local: clean-local-check
.PHONY: clean-local-check

View File

@ -0,0 +1,30 @@
Functions changes summary: 0 Removed, 1 Changed, 1 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
1 base class change:
'struct B0' changed:
1 data member change:
'char B0::m0' access changed from 'public' to 'private'
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64, access changed from 'public' to 'private'
and its type 'int' changed:
name changed from 'int' to 'char'
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
1 Added function:
'method B1::B1()'

View File

@ -0,0 +1,21 @@
struct B0
{
char m0;
B0()
: m0(0)
{}
};
struct S : public B0
{
int m0;
S()
: m0(0)
{}
};
void
foo(S&)
{}

Binary file not shown.

View File

@ -0,0 +1,33 @@
class B0
{
char m0;
public:
B0()
: m0(0)
{}
};
class B1
{
unsigned m0;
public:
B1()
: m0(0)
{}
};
class S : public B0, public B1
{
char m0;
public:
S()
: m0(0)
{}
};
void
foo(S&)
{}

Binary file not shown.

View File

@ -0,0 +1,24 @@
Functions changes summary: 0 Removed, 1 Changed, 1 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
no base class change (1 filtered);
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64
and its type 'int' changed:
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
1 Added function:
'method B1::B1()'

View File

@ -0,0 +1,21 @@
struct B0
{
char m0;
B0()
: m0(0)
{}
};
struct S : public B0
{
int m0;
S()
: m0(0)
{}
};
void
foo(S&)
{}

Binary file not shown.

View File

@ -0,0 +1,33 @@
class B0
{
char m0;
public:
B0()
: m0(0)
{}
};
class B1
{
unsigned m0;
public:
B1()
: m0(0)
{}
};
class S : public B0, public B1
{
char m0;
public:
S()
: m0(0)
{}
};
void
foo(S&)
{}

Binary file not shown.

View File

@ -108,7 +108,13 @@ InOutSpec in_out_specs[] =
"data/test-diff-dwarf/test7-v0.o",
"data/test-diff-dwarf/test7-v1.o",
"data/test-diff-dwarf/test7-report.txt",
"output/test-diff-dwarf/test6-report.txt"
"output/test-diff-dwarf/test7-report.txt"
},
{
"data/test-diff-dwarf/test8-v0.o",
"data/test-diff-dwarf/test8-v1.o",
"data/test-diff-dwarf/test8-report.txt",
"output/test-diff-dwarf/test8-report.txt"
},
// This should be the last entry
{NULL, NULL, NULL, NULL}

View File

@ -152,6 +152,13 @@ InOutSpec in_out_specs[] =
"data/test-diff-filter/test12-report.txt",
"output/test-diff-filter/test12-report.txt",
},
{
"data/test-diff-filter/test13-v0.o",
"data/test-diff-filter/test13-v1.o",
"--no-harmless",
"data/test-diff-filter/test13-report.txt",
"output/test-diff-filter/test13-report.txt",
},
// This should be the last entry
{NULL, NULL, NULL, NULL, NULL}
};