mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-30 21:31:35 +00:00
Add a new DECL_NAME_CHANGE_CATEGORY change category
* include/abg-comparison.h (enum diff_category::DECL_NAME_CHANGE_CATEGORY): New enumerator. * src/abg-comparison.cc (report_name_size_and_alignment_changes) ({enum, typedef}_diff::report): Adjust to avoid emitting name change report if the DECL_NAME_CHANGE_CATEGORY category of change is currently disallowed. * abg-comp-filter.cc (decl_name_changed): New static function. (harmless_filter::visit): Detect that the decl name changed and put the current diff node (and its parents) into the DECL_NAME_CHANGE_CATEGORY category. * tools/bidiff.cc (set_diff_context_from_opts): Set the new DECL_NAME_CHANGE_CATEGORY category into the harmless_changes group of categories. * tests/data/test-diff-filter/test6-report.txt: New test input file. * tests/data/test-diff-filter/test6-v0.cc: Likewise. * tests/data/test-diff-filter/test6-v0.o: Likewise. * tests/data/test-diff-filter/test6-v1.cc: Likewise. * tests/data/test-diff-filter/test6-v1.o: Likewise. * tests/data/test-diff-filter/test7-report.txt: Likewise. * tests/data/test-diff-filter/test7-v0.cc: Likewise. * tests/data/test-diff-filter/test7-v0.o: Likewise. * tests/data/test-diff-filter/test7-v1.cc: Likewise. * tests/data/test-diff-filter/test7-v1.o: Likewise. * tests/test-diff-filter.cc: Take the new inputs above to run new tests. * tests/Makefile.am: Add the new files above to the distribution. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
928efb2d4f
commit
23b7fa9ac2
@ -224,10 +224,14 @@ enum diff_category
|
||||
/// instance a type and its typedefs.
|
||||
COMPATIBLE_TYPE_CHANGE_CATEGORY = 1 << 1,
|
||||
|
||||
/// This means that a diff node in the sub-tree carries a
|
||||
/// declaration name change.
|
||||
DECL_NAME_CHANGE_CATEGORY = 1 << 2,
|
||||
|
||||
/// 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 << 2,
|
||||
SIZE_OR_OFFSET_CHANGE_CATEGORY = 1 << 3,
|
||||
|
||||
/// A special enumerator that is the logical 'or' all the
|
||||
/// enumerators above.
|
||||
@ -237,6 +241,7 @@ enum diff_category
|
||||
EVERYTHING_CATEGORY =
|
||||
ACCESS_CHANGE_CATEGORY
|
||||
| COMPATIBLE_TYPE_CHANGE_CATEGORY
|
||||
| DECL_NAME_CHANGE_CATEGORY
|
||||
| SIZE_OR_OFFSET_CHANGE_CATEGORY
|
||||
};
|
||||
|
||||
|
@ -150,6 +150,26 @@ is_compatible_change(decl_base_sptr d1, decl_base_sptr d2)
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Test if two decls have different names.
|
||||
///
|
||||
/// @param d1 the first declaration to consider.
|
||||
///
|
||||
/// @param d2 the second declaration to consider.
|
||||
///
|
||||
/// @return true if d1 and d2 have different names.
|
||||
static bool
|
||||
decl_name_changed(decl_base_sptr d1, decl_base_sptr d2)
|
||||
{
|
||||
string d1_name, d2_name;
|
||||
|
||||
if (d1)
|
||||
d1_name = d1->get_name();
|
||||
if (d2)
|
||||
d2_name = d2->get_name();
|
||||
|
||||
return d1_name != d2_name;
|
||||
}
|
||||
|
||||
/// The visiting code of the harmless_filter.
|
||||
///
|
||||
/// @param d the diff node being visited.
|
||||
@ -175,6 +195,9 @@ harmless_filter::visit(diff* d, bool pre)
|
||||
if (is_compatible_change(f, s))
|
||||
category |= COMPATIBLE_TYPE_CHANGE_CATEGORY;
|
||||
|
||||
if (decl_name_changed(f, s))
|
||||
category |= DECL_NAME_CHANGE_CATEGORY;
|
||||
|
||||
if (category)
|
||||
d->add_to_category(category);
|
||||
}
|
||||
|
@ -1178,7 +1178,8 @@ report_name_size_and_alignment_changes(decl_base_sptr first,
|
||||
string fn = first->get_qualified_name(),
|
||||
sn = second->get_qualified_name();
|
||||
|
||||
if (fn != sn)
|
||||
if (fn != sn
|
||||
&& ctxt->get_allowed_category() & DECL_NAME_CHANGE_CATEGORY)
|
||||
{
|
||||
if (nl)
|
||||
out << "\n";
|
||||
@ -2171,7 +2172,8 @@ enum_diff::report(ostream& out, const string& indent) const
|
||||
maybe_report_diff_for_member(first, second, context(), out, indent);
|
||||
|
||||
// name
|
||||
if (first->get_name() != second->get_name())
|
||||
if (first->get_name() != second->get_name()
|
||||
&& context()->get_allowed_category() & DECL_NAME_CHANGE_CATEGORY)
|
||||
out << indent << "enum name changed from '"
|
||||
<< first->get_qualified_name() << "' to '"
|
||||
<< second->get_qualified_name() << "'\n";
|
||||
@ -5011,7 +5013,8 @@ typedef_diff::report(ostream& out, const string& indent) const
|
||||
|
||||
maybe_report_diff_for_member(f, s, context(), out, indent);
|
||||
|
||||
if (f->get_name() != s->get_name())
|
||||
if (f->get_name() != s->get_name()
|
||||
&& context()->get_allowed_category() & DECL_NAME_CHANGE_CATEGORY)
|
||||
{
|
||||
out << indent << "typedef name changed from "
|
||||
<< f->get_qualified_name()
|
||||
|
@ -174,7 +174,17 @@ data/test-diff-filter/test5-v0.cc \
|
||||
data/test-diff-filter/test5-v1.cc \
|
||||
data/test-diff-filter/test5-v0.o \
|
||||
data/test-diff-filter/test5-v1.o \
|
||||
data/test-diff-filter/test5-report.txt
|
||||
data/test-diff-filter/test5-report.txt \
|
||||
data/test-diff-filter/test6-v0.cc \
|
||||
data/test-diff-filter/test6-v1.cc \
|
||||
data/test-diff-filter/test6-v0.o \
|
||||
data/test-diff-filter/test6-v1.o \
|
||||
data/test-diff-filter/test6-report.txt \
|
||||
data/test-diff-filter/test7-v0.cc \
|
||||
data/test-diff-filter/test7-v1.cc \
|
||||
data/test-diff-filter/test7-v0.o \
|
||||
data/test-diff-filter/test7-v1.o \
|
||||
data/test-diff-filter/test7-report.txt
|
||||
|
||||
clean-local: clean-local-check
|
||||
.PHONY: clean-local-check
|
||||
|
11
tests/data/test-diff-filter/test6-report.txt
Normal file
11
tests/data/test-diff-filter/test6-report.txt
Normal file
@ -0,0 +1,11 @@
|
||||
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
|
||||
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
|
||||
|
||||
1 function with some indirect sub-type change:
|
||||
|
||||
[C]'function return_type foo()' has some indirect sub-type changes:
|
||||
return type changed:
|
||||
underlying type 'unsigned char' changed:
|
||||
size changed from 8 to 32 bits
|
||||
alignment changed from 8 to 32 bits
|
||||
|
5
tests/data/test-diff-filter/test6-v0.cc
Normal file
5
tests/data/test-diff-filter/test6-v0.cc
Normal file
@ -0,0 +1,5 @@
|
||||
typedef unsigned char return_type;
|
||||
|
||||
return_type
|
||||
foo()
|
||||
{return 0;}
|
BIN
tests/data/test-diff-filter/test6-v0.o
Normal file
BIN
tests/data/test-diff-filter/test6-v0.o
Normal file
Binary file not shown.
5
tests/data/test-diff-filter/test6-v1.cc
Normal file
5
tests/data/test-diff-filter/test6-v1.cc
Normal file
@ -0,0 +1,5 @@
|
||||
typedef unsigned int return_type;
|
||||
|
||||
return_type
|
||||
foo()
|
||||
{return 0;}
|
BIN
tests/data/test-diff-filter/test6-v1.o
Normal file
BIN
tests/data/test-diff-filter/test6-v1.o
Normal file
Binary file not shown.
4
tests/data/test-diff-filter/test7-report.txt
Normal file
4
tests/data/test-diff-filter/test7-report.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function
|
||||
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
|
||||
|
||||
|
8
tests/data/test-diff-filter/test7-v0.cc
Normal file
8
tests/data/test-diff-filter/test7-v0.cc
Normal file
@ -0,0 +1,8 @@
|
||||
struct return_type
|
||||
{
|
||||
unsigned char m0;
|
||||
};
|
||||
|
||||
return_type
|
||||
foo()
|
||||
{return return_type();}
|
BIN
tests/data/test-diff-filter/test7-v0.o
Normal file
BIN
tests/data/test-diff-filter/test7-v0.o
Normal file
Binary file not shown.
8
tests/data/test-diff-filter/test7-v1.cc
Normal file
8
tests/data/test-diff-filter/test7-v1.cc
Normal file
@ -0,0 +1,8 @@
|
||||
struct other_return_type
|
||||
{
|
||||
unsigned char m0;
|
||||
};
|
||||
|
||||
other_return_type
|
||||
foo()
|
||||
{return other_return_type();}
|
BIN
tests/data/test-diff-filter/test7-v1.o
Normal file
BIN
tests/data/test-diff-filter/test7-v1.o
Normal file
Binary file not shown.
@ -103,6 +103,20 @@ InOutSpec in_out_specs[] =
|
||||
"data/test-diff-filter/test5-report.txt",
|
||||
"output/test-diff-filter/test5-report.txt",
|
||||
},
|
||||
{
|
||||
"data/test-diff-filter/test6-v0.o",
|
||||
"data/test-diff-filter/test6-v1.o",
|
||||
"--no-harmless",
|
||||
"data/test-diff-filter/test6-report.txt",
|
||||
"output/test-diff-filter/test6-report.txt",
|
||||
},
|
||||
{
|
||||
"data/test-diff-filter/test7-v0.o",
|
||||
"data/test-diff-filter/test7-v1.o",
|
||||
"--no-harmless",
|
||||
"data/test-diff-filter/test7-report.txt",
|
||||
"output/test-diff-filter/test7-report.txt",
|
||||
},
|
||||
// This should be the last entry
|
||||
{NULL, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
@ -294,7 +294,8 @@ set_diff_context_from_opts(diff_context_sptr ctxt,
|
||||
|
||||
if (!opts.show_harmless_changes)
|
||||
ctxt->switch_categories_off(abigail::comparison::ACCESS_CHANGE_CATEGORY
|
||||
| abigail::comparison::COMPATIBLE_TYPE_CHANGE_CATEGORY);
|
||||
| abigail::comparison::COMPATIBLE_TYPE_CHANGE_CATEGORY
|
||||
| abigail::comparison::DECL_NAME_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