mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-16 23:14:36 +00:00
321da66678
Consider these two anonymous enum declarations in these different contexts: enum {A0 = 0; A1 = 1;} global0; // 1/: anonymous enum typedef enum {E0 = 0; E1 = 1;} E; // 2/: anonymous enum named by a typedef. E global0; In the first context "1/", the type of the global variable is an anonymous enum that is used as such. In the second context "2/", the type of the global variable is an anonymous type that is named by the typedef 'E'. So then, it's E that is used to designate the enum. The anonymous type is thus never used directly. In essence, it's the same thing as if it was declared as enum E {E0 = 0; E1 = 1;}; Right now, libabigail canonicalizes the enum 1/ and 2/ together and that results in 1/ being canonically equal to 2/. So, when saving the corpus into abixml, because enum 1/ and enum 2/ can be used interchangeably, either 1/ or 2/ is going to be saved. That can result in spurious change reports in which the reporter refer to the enum 1/ where it should refer to enum 2/ or vice versa. Intrinsically, the enum 1/ and enum 2/ are different because one essentially has a name (provided by a typedef) and the second does not. One is anonymous whereas the second is not, essentially. At the moment, libabigail supports typedef-named anonymous classes. But it doesn't support this concept for enums. This patch extends that concept to enums as well. It makes it so that any anonymous type can now by typedef-named. In that case, the type now looks like it has a name which is the typedef name. The information about the typedef naming a given type is kept and serialized into abixml. Thus with this patch, the enum in 1/ is now considered (canonically) different from enum 2/. So there is no possible confusion once the type is serialized into abixml. * include/abg-fwd.h (scope_anonymous_or_typedef_named) (is_anonymous_or_typedef_named): Declare new functions. * include/abg-ir.h (decl_base::set_has_anonymous_parent): Remove declaration. (decl_base::{get,set}_naming_typedef): Declare new member functions. * src/abg-ir.cc (update_qualified_name): Define static function. (decl_base::priv::naming_typedef_): Define new data member. (decl_base::priv::has_anonymous_parent_): Remove data member. (decl_base::priv::priv): Adjust constructor. (decl_base::get_has_anonymous_parent): Rather than storing a flag for this, dynamically look at if the scope is anonymous. (decl_base::set_has_anonymous_parent): Remove definition. (decl_base::{get,set}_naming_typedef): Define new member functions. (scope_anonymous_or_typedef_named) (is_anonymous_or_typedef_named): Define new functions. (get_decl_name_for_comparison): Define new sub-routine for the decl_base overload of equals. (equals): In the overload for decl_base, use the new get_decl_name_for_comparison. It helps to ensure that all anonymous decls of the same kind have the same name for the purpose of comparison. It also ensures that non anonymous decls that are part of anonymous scopes should be compared only by looking at their non-qualified names. In the overload for class_or_union, adjust. (scope_decl::add_member_decl): No more need to flag the fast that the parent scope is anonymous here. (get_debug_representation): Fix a thinko. (class_or_union::get_naming_typedef): Remove member function as it's now handled by decl_base::get_naming_typedef. * src/abg-dwarf-reader.cc (build_typedef_type): When a typedef is a naming typedef, then mark the named decl as being typedef-named. (maybe_canonicalize_type): Delay canonicalization of anonymous types because they can be typedef-named later. * src/abg-reader.cc (read_naming_typedef_id_string) (maybe_set_naming_typedef): Define new static function. (build_class_decl): Use it here, rather than reading the "naming-typedef-id" by hand. (build_enum_type_decl, build_union_decl): Read the "naming-typedef-id" property. * src/abg-writer.cc (write_naming_typedef): Make this accept decl_base_sptr, rather than just class_decl_sptr. (write_enum_type_decl): Write the naming-typedef-id property if needed. * tests/data/test-abidiff-exit/test-PR28316-report.txt: New test reference output. * tests/data/test-abidiff-exit/test-PR28316-v{0,1}.cc: Source code of new binary test input. * tests/data/test-abidiff-exit/test-PR28316-v{0,1}.o: New binary test input files. * tests/data/Makefile.am: Add the new test files to the source distribution. * tests/test-abidiff-exit.cc: Add the new test files above to this harness. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-annotate/test13-pr18894.so.abi: Likewise. * tests/data/test-annotate/test14-pr18893.so.abi: Likewise. * tests/data/test-annotate/test15-pr18892.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. * tests/data/test-diff-dwarf/test15-enum-report.txt: Likewise. * tests/data/test-diff-filter/test19-enum-report-1.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: Likewise. * tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise. * tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: Likewise. * tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Likewise. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise. * tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
---|---|---|
.. | ||
abg-comp-filter.h | ||
abg-comparison.h | ||
abg-config.h | ||
abg-corpus.h | ||
abg-cxx-compat.h | ||
abg-diff-utils.h | ||
abg-dwarf-reader.h | ||
abg-fwd.h | ||
abg-hash.h | ||
abg-ini.h | ||
abg-interned-str.h | ||
abg-ir.h | ||
abg-libxml-utils.h | ||
abg-reader.h | ||
abg-regex.h | ||
abg-reporter.h | ||
abg-sptr-utils.h | ||
abg-suppression.h | ||
abg-tools-utils.h | ||
abg-traverse.h | ||
abg-version.h.in | ||
abg-viz-common.h | ||
abg-viz-dot.h | ||
abg-viz-svg.h | ||
abg-workers.h | ||
abg-writer.h | ||
Makefile.am |