mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-21 00:06:58 +00:00
File static data member changes in STATIC_DATA_MEMBER_CHANGE_CATEGORY
* include/abg-comparison.h (diff_category::STATIC_DATA_MEMBER_CHANGE_CATEGORY): New category. (diff_category::EVERYTHING_CATEGORY): Update * src/abg-comp-filter.cc (static_data_member_type_size_changed) (static_data_member_added_or_removed): Define new static functions. (harmless_filter::visit): Categorize changes to static data members as STATIC_DATA_MEMBER_CHANGE_CATEGORY. * tools/bidiff.cc (set_diff_context_from_opts): STATIC_DATA_MEMBER_CHANGE_CATEGORY is falls into the harmless group. * tests/data/test-diff-filter/test12-report.txt: New test input. * tests/data/test-diff-filter/test12-v0.cc: Likewise. * tests/data/test-diff-filter/test12-v0.o: Likewise. * tests/data/test-diff-filter/test12-v1.cc: Likewise. * tests/data/test-diff-filter/test12-v1.o: Likewise. * tools/bidiff.cc: Run this test with the additional input data above. * tests/Makefile.am: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
fc6af95304
commit
e4820f9e33
@ -245,15 +245,18 @@ enum diff_category
|
||||
/// or removal of a non-virtual member function.
|
||||
NON_VIRT_MEM_FUN_CHANGE_CATEGORY = 1 << 3,
|
||||
|
||||
/// This means that a diff node in the sub-tree carries an addition
|
||||
/// or removal of a static data member.
|
||||
STATIC_DATA_MEMBER_CHANGE_CATEGORY = 1 << 4,
|
||||
|
||||
/// This means the diff node (or at least one of its descendant
|
||||
/// nodes) carries a change that modifies the size of a type or an
|
||||
/// offset of a type member.
|
||||
SIZE_OR_OFFSET_CHANGE_CATEGORY = 1 << 4,
|
||||
SIZE_OR_OFFSET_CHANGE_CATEGORY = 1 << 5,
|
||||
|
||||
/// This means that a diff node in the sub-tree carries a change to
|
||||
/// a vtable.
|
||||
VIRTUAL_MEMBER_CHANGE_CATEGORY = 1 << 5,
|
||||
VIRTUAL_MEMBER_CHANGE_CATEGORY = 1 << 6,
|
||||
|
||||
/// A special enumerator that is the logical 'or' all the
|
||||
/// enumerators above.
|
||||
@ -265,6 +268,7 @@ enum diff_category
|
||||
| COMPATIBLE_TYPE_CHANGE_CATEGORY
|
||||
| DECL_NAME_CHANGE_CATEGORY
|
||||
| NON_VIRT_MEM_FUN_CHANGE_CATEGORY
|
||||
| STATIC_DATA_MEMBER_CHANGE_CATEGORY
|
||||
| SIZE_OR_OFFSET_CHANGE_CATEGORY
|
||||
| VIRTUAL_MEMBER_CHANGE_CATEGORY
|
||||
};
|
||||
|
@ -200,6 +200,30 @@ non_static_data_member_type_size_changed(decl_base_sptr f, decl_base_sptr s)
|
||||
return type_size_changed(fv->get_type(), sv->get_type());
|
||||
}
|
||||
|
||||
/// Test if the size of a non-static data member changed accross two
|
||||
/// versions.
|
||||
///
|
||||
/// @param f the first version of the non-static data member.
|
||||
///
|
||||
/// @param s the second version of the non-static data member.
|
||||
static bool
|
||||
static_data_member_type_size_changed(decl_base_sptr f, decl_base_sptr s)
|
||||
{
|
||||
if (!is_member_decl(f)
|
||||
|| !is_member_decl(s))
|
||||
return false;
|
||||
|
||||
var_decl_sptr fv = dynamic_pointer_cast<var_decl>(f),
|
||||
sv = dynamic_pointer_cast<var_decl>(s);
|
||||
if (!fv
|
||||
|| !sv
|
||||
|| !get_member_is_static(fv)
|
||||
|| !get_member_is_static(sv))
|
||||
return false;
|
||||
|
||||
return type_size_changed(fv->get_type(), sv->get_type());
|
||||
}
|
||||
|
||||
/// Test if two types are different but compatible.
|
||||
///
|
||||
/// @param d1 the declaration of the first type to consider.
|
||||
@ -279,6 +303,49 @@ non_static_data_member_added_or_removed(const diff* diff)
|
||||
(dynamic_cast<const class_diff*>(diff));
|
||||
}
|
||||
|
||||
/// Test if a class_diff node has static members added or removed.
|
||||
///
|
||||
/// @param diff the diff node to consider.
|
||||
///
|
||||
/// @return true iff the class_diff node has static members added
|
||||
/// or removed.
|
||||
static bool
|
||||
static_data_member_added_or_removed(const class_diff* diff)
|
||||
{
|
||||
if (diff && !diff_involves_decl_only_class(diff))
|
||||
{
|
||||
for (string_decl_base_sptr_map::const_iterator i =
|
||||
diff->inserted_data_members().begin();
|
||||
i != diff->inserted_data_members().end();
|
||||
++i)
|
||||
if (get_member_is_static(i->second))
|
||||
return true;
|
||||
|
||||
for (string_decl_base_sptr_map::const_iterator i =
|
||||
diff->deleted_data_members().begin();
|
||||
i != diff->deleted_data_members().end();
|
||||
++i)
|
||||
if (get_member_is_static(i->second))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Test if a class_diff node has static members added or
|
||||
/// removed.
|
||||
///
|
||||
/// @param diff the diff node to consider.
|
||||
///
|
||||
/// @return true iff the class_diff node has static members added
|
||||
/// or removed.
|
||||
static bool
|
||||
static_data_member_added_or_removed(const diff* diff)
|
||||
{
|
||||
return static_data_member_added_or_removed
|
||||
(dynamic_cast<const class_diff*>(diff));
|
||||
}
|
||||
|
||||
/// Test if the class_diff node has a change involving virtual member
|
||||
/// functions.
|
||||
///
|
||||
@ -448,6 +515,10 @@ harmless_filter::visit(diff* d, bool pre)
|
||||
if (has_non_virtual_mem_fn_change(d))
|
||||
category |= NON_VIRT_MEM_FUN_CHANGE_CATEGORY;
|
||||
|
||||
if (static_data_member_added_or_removed(d)
|
||||
|| static_data_member_type_size_changed(f, s))
|
||||
category |= STATIC_DATA_MEMBER_CHANGE_CATEGORY;
|
||||
|
||||
if (category)
|
||||
d->add_to_category(category);
|
||||
}
|
||||
|
@ -219,7 +219,12 @@ data/test-diff-filter/test11-v0.cc \
|
||||
data/test-diff-filter/test11-v1.cc \
|
||||
data/test-diff-filter/test11-v0.o \
|
||||
data/test-diff-filter/test11-v1.o \
|
||||
data/test-diff-filter/test11-report.txt
|
||||
data/test-diff-filter/test11-report.txt \
|
||||
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
|
||||
|
||||
clean-local: clean-local-check
|
||||
.PHONY: clean-local-check
|
||||
|
7
tests/data/test-diff-filter/test12-report.txt
Normal file
7
tests/data/test-diff-filter/test12-report.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
|
||||
Variables changes summary: 0 Removed, 0 Changed, 1 Added variable
|
||||
|
||||
|
||||
1 Added variable:
|
||||
'static char S::m0
|
||||
|
10
tests/data/test-diff-filter/test12-v0.cc
Normal file
10
tests/data/test-diff-filter/test12-v0.cc
Normal file
@ -0,0 +1,10 @@
|
||||
struct S
|
||||
{
|
||||
static int m1;
|
||||
};
|
||||
|
||||
int S::m1;
|
||||
|
||||
void
|
||||
foo(S&)
|
||||
{}
|
BIN
tests/data/test-diff-filter/test12-v0.o
Normal file
BIN
tests/data/test-diff-filter/test12-v0.o
Normal file
Binary file not shown.
12
tests/data/test-diff-filter/test12-v1.cc
Normal file
12
tests/data/test-diff-filter/test12-v1.cc
Normal file
@ -0,0 +1,12 @@
|
||||
struct S
|
||||
{
|
||||
static char m0;
|
||||
static int m1;
|
||||
};
|
||||
|
||||
char S::m0;
|
||||
int S::m1;
|
||||
|
||||
void
|
||||
foo(S&)
|
||||
{}
|
BIN
tests/data/test-diff-filter/test12-v1.o
Normal file
BIN
tests/data/test-diff-filter/test12-v1.o
Normal file
Binary file not shown.
@ -145,6 +145,13 @@ InOutSpec in_out_specs[] =
|
||||
"data/test-diff-filter/test11-report.txt",
|
||||
"output/test-diff-filter/test11-report.txt",
|
||||
},
|
||||
{
|
||||
"data/test-diff-filter/test12-v0.o",
|
||||
"data/test-diff-filter/test12-v1.o",
|
||||
"--no-harmless",
|
||||
"data/test-diff-filter/test12-report.txt",
|
||||
"output/test-diff-filter/test12-report.txt",
|
||||
},
|
||||
// This should be the last entry
|
||||
{NULL, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
@ -297,7 +297,8 @@ set_diff_context_from_opts(diff_context_sptr ctxt,
|
||||
(abigail::comparison::ACCESS_CHANGE_CATEGORY
|
||||
| abigail::comparison::COMPATIBLE_TYPE_CHANGE_CATEGORY
|
||||
| abigail::comparison::DECL_NAME_CHANGE_CATEGORY
|
||||
| abigail::comparison::NON_VIRT_MEM_FUN_CHANGE_CATEGORY);
|
||||
| abigail::comparison::NON_VIRT_MEM_FUN_CHANGE_CATEGORY
|
||||
| abigail::comparison::STATIC_DATA_MEMBER_CHANGE_CATEGORY);
|
||||
if (!opts.show_harmful_changes)
|
||||
ctxt->switch_categories_off
|
||||
(abigail::comparison::SIZE_OR_OFFSET_CHANGE_CATEGORY
|
||||
|
Loading…
Reference in New Issue
Block a user