From: Giuliano Procida Date: Thu, 12 Mar 2020 06:30:36 +0000 (+0000) Subject: Treat function type changes as local. X-Git-Tag: upstream/2.3~679 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09946c4aee8767a3020aca789c33f08c4889519d;p=platform%2Fupstream%2Flibabigail.git Treat function type changes as local. In leaf-changes-only mode, if the type of a struct's function pointer member changes it currently gets categorised as a non-local change and so is not reported. The change to any function passing such a struct is considered non-local and also not reported. This patch broadens the definition of local changes to include these cases and so have them be reported in leaf-changes-only mode. It may be the first of a sequence of such patches, * src/abg-ir.cc (types_have_similar_structure): Always compare function types (instead of just returning true) regardless of whether they are components of pointer-to-function or reference-to-function types. * tests/data/Makefile.am: Add new test case files. * tests/data/test-abidiff-exit/test-leaf2-report.txt: New test case. * tests/data/test-abidiff-exit/test-leaf2-v0.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf2-v0.o: Ditto. * tests/data/test-abidiff-exit/test-leaf2-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-leaf2-v1.o: Ditto. * tests/test-abidiff-exit.cc: Run new test case. Signed-off-by: Giuliano Procida --- diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 3b1577a8..2cb76ffc 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -22745,25 +22745,25 @@ types_have_similar_structure(const type_base* first, const type_base* second) if (const function_type* ty1 = is_function_type(first)) { const function_type* ty2 = is_function_type(second); - if (!was_indirect_type) - { - if (!types_have_similar_structure(ty1->get_return_type(), - ty2->get_return_type())) - return false; + if (!ty2) + return false; - if (ty1->get_parameters().size() != ty2->get_parameters().size()) - return false; + if (!types_have_similar_structure(ty1->get_return_type(), + ty2->get_return_type())) + return false; - for (function_type::parameters::const_iterator - i = ty1->get_parameters().begin(), - j = ty2->get_parameters().begin(); - (i != ty1->get_parameters().end() - && j != ty2->get_parameters().end()); - ++i, ++j) - if (!types_have_similar_structure((*i)->get_type(), - (*j)->get_type())) - return false; - } + if (ty1->get_parameters().size() != ty2->get_parameters().size()) + return false; + + for (function_type::parameters::const_iterator + i = ty1->get_parameters().begin(), + j = ty2->get_parameters().begin(); + (i != ty1->get_parameters().end() + && j != ty2->get_parameters().end()); + ++i, ++j) + if (!types_have_similar_structure((*i)->get_type(), + (*j)->get_type())) + return false; return true; } diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index bf76ca2e..3b4b614b 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -120,6 +120,11 @@ test-abidiff-exit/test-leaf1-v0.o \ test-abidiff-exit/test-leaf1-v1.cc \ test-abidiff-exit/test-leaf1-v1.o \ test-abidiff-exit/test-leaf1-report.txt \ +test-abidiff-exit/test-leaf2-v0.cc \ +test-abidiff-exit/test-leaf2-v0.o \ +test-abidiff-exit/test-leaf2-v1.cc \ +test-abidiff-exit/test-leaf2-v1.o \ +test-abidiff-exit/test-leaf2-report.txt \ test-abidiff-exit/test-leaf3-v0.c \ test-abidiff-exit/test-leaf3-v0.o \ test-abidiff-exit/test-leaf3-v1.c \ diff --git a/tests/data/test-abidiff-exit/test-leaf2-report.txt b/tests/data/test-abidiff-exit/test-leaf2-report.txt new file mode 100644 index 00000000..2765b469 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-leaf2-report.txt @@ -0,0 +1,12 @@ +Leaf changes summary: 1 artifact changed +Changed leaf types summary: 1 leaf type changed +Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function +Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable + +'struct ops' changed: + type size hasn't changed + there are data member changes: + type 'void (int)*' of 'ops::munge' changed: + pointer type changed from: 'void (int)*' to: 'char (long int, bool)*' + + diff --git a/tests/data/test-abidiff-exit/test-leaf2-v0.cc b/tests/data/test-abidiff-exit/test-leaf2-v0.cc new file mode 100644 index 00000000..b75dd84c --- /dev/null +++ b/tests/data/test-abidiff-exit/test-leaf2-v0.cc @@ -0,0 +1,6 @@ +struct ops { + void (*munge)(int x); +}; + +void register_ops(const ops&) { +} diff --git a/tests/data/test-abidiff-exit/test-leaf2-v0.o b/tests/data/test-abidiff-exit/test-leaf2-v0.o new file mode 100644 index 00000000..211a3388 Binary files /dev/null and b/tests/data/test-abidiff-exit/test-leaf2-v0.o differ diff --git a/tests/data/test-abidiff-exit/test-leaf2-v1.cc b/tests/data/test-abidiff-exit/test-leaf2-v1.cc new file mode 100644 index 00000000..f308a343 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-leaf2-v1.cc @@ -0,0 +1,6 @@ +struct ops { + char (*munge)(long x, bool gunk); +}; + +void register_ops(const ops&) { +} diff --git a/tests/data/test-abidiff-exit/test-leaf2-v1.o b/tests/data/test-abidiff-exit/test-leaf2-v1.o new file mode 100644 index 00000000..9db3ed5e Binary files /dev/null and b/tests/data/test-abidiff-exit/test-leaf2-v1.o differ diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc index 5967863d..6ecbfd24 100644 --- a/tests/test-abidiff-exit.cc +++ b/tests/test-abidiff-exit.cc @@ -140,6 +140,15 @@ InOutSpec in_out_specs[] = "data/test-abidiff-exit/test-leaf1-report.txt", "output/test-abidiff-exit/test-leaf1-report.txt" }, + { + "data/test-abidiff-exit/test-leaf2-v0.o", + "data/test-abidiff-exit/test-leaf2-v1.o", + "", + "--no-show-locs --leaf-changes-only", + abigail::tools_utils::ABIDIFF_ABI_CHANGE, + "data/test-abidiff-exit/test-leaf2-report.txt", + "output/test-abidiff-exit/test-leaf2-report.txt" + }, { "data/test-abidiff-exit/test-leaf3-v0.o", "data/test-abidiff-exit/test-leaf3-v1.o",