mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-15 22:44:41 +00:00
247b4a1815
1 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Dodji Seketeli
|
059c86ec0b |
Bug 20476 - Compare virtual member functions when comparing classes
There are cases where a virtual member function doesn't have an implementation that is defined and publicly exported. This is the cases for virtual pure classes. Even in those cases, users might want to detect vtable changes on virtual member pure classes (interfaces). Now that, for C++ binaries, all the partial representations of a class are merged into one class (in a given binary), we can envision to compare virtual member functions of classes as part of comparing two classes. This is what this patch does. While comparing two classes, the virtual member functions are compared too. Note that as there can be several virtual member functions that have the same vtable offset (think about a virtual destructor that might have several generated functions that 'conceptually' share the same vtable offset), comparing the virtual functions can be a little bit non-trivial. The approach taken is to check that in the first set of virtual functions, each virtual function actually matches at least one virtual function in the second set. And the match is a "loose" one. That is, it doesn't take into account the symbol name or the mangled name. The patch also fixes the "less than" operator used to sort virtual member functions. There is also a buglet in the way we compute the highest vtable offset number today. This patch provides a new function named class_decl::get_biggest_vtable_offset that is used in the change reports. The patch also fixes a related bug in where we were forgetting to report about added and removed virtual member functions without an associated elf symbol. This patch fixes that. * include/abg-ir.h (class_decl::get_biggest_vtable_offset): Declare new member function. * src/abg-ir.cc (virtual_member_function_less_than::operator()): Either compare the symbol id strings if the functions have symbols or just compare their pretty representations. (class_decl::get_biggest_vtable_offset): Define new member function. (methods_equal_modulo_elf_symbol) (method_matches_at_least_one_in_vector): New static methods. (equals): In the overload for classes, compare the virtual member functions while comparing classes. * src/abg-comparison.cc (represent): In the overload for method_decl_sptr, fix the way we compute the highest vtable offset number for a give class_decl. (class_decl::ensure_lookup_tables_populated): Don't forget added and removed virtual member functions in the report for changed classes. * tests/data/test-diff-dwarf/libtest41-PR20476-hidden-old.so: New test binary input file. * tests/data/test-diff-dwarf/libtest41-PR20476-hidden-new.so: Likewise. * tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt: New reference output. * tests/data/Makefile.am: Add the new test material above to the source distribution. * tests/test-diff-dwarf.cc (in_out_spec): Add the new tests here. * tests/data/test-annotate/test10-pr18818-gcc.so.abi: Adjust. * tests/data/test-annotate/test11-pr18828.so.abi: Adjust. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust. * tests/data/test-annotate/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust. |