Bug 20420 - Wrong ODR-based type comparison optimization on qualified type
authorDodji Seketeli <dodji@redhat.com>
Wed, 24 Aug 2016 08:37:08 +0000 (10:37 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 24 Aug 2016 08:37:08 +0000 (10:37 +0200)
During type canonicalizing, qualified types are being compared using
the ODR-based optimization.  This is wrong because, for instance, it's
not because two types from the same ABI corpus are both const
anonymous structs that they are meant to be equivalent.

This patch fixes the issue by applying the ODR-based comparison
optimization only to built-in types and non-anonymous struct and
enums.

The reproducer is a glibc package that takes a while to compare so
it's not suitable for inclusion in the test suite.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc

index a9674c936922e23ebd73af2d48f408cb15fcb430..00636dfa51886f69b982850c73caa723b5d6576e 100644 (file)
@@ -6889,25 +6889,12 @@ type_base::get_canonical_type_for(type_base_sptr t)
              && ((is_c_language(lang) || is_cplus_plus_language(lang))
                  && (is_c_language(other_lang)
                      || is_cplus_plus_language(other_lang)))
-             // We are not doing the optimizatin for anymous types
-             // because, well, two anonymous type have the same name
-             // (okay, they have no name), but that doesn't mean they
-             // are equal.
-             && !is_anonymous_type(t)
-             // We are not doing it for typedefs either, as I've seen
-             // instances of two typedefs with the same name but
-             // pointing to deferent types, e.g, in some boost
-             // library in our testsuite.
-             && !is_typedef(t)
-             // We are not doing it for pointers/references/arrays as
-             // two pointers to a type 'foo' might point to 'foo'
-             // meaning different things, as we've seen above.
-             && !is_pointer_type(t)
-             && !is_reference_type(t)
-             && !is_array_type(t)
-             // And we are not doing it for function types either,
-             // for similar reasons.
-             && !is_function_type(t))
+             // We are doing the ODR-based optimization just for
+             // non-anonymous user-defined types, and built-in types
+             && (is_class_type(t)
+                 || is_enum_type(t)
+                 || is_type_decl(t))
+             && !is_anonymous_type(t))
            {
              if (const corpus* it_corpus = (*it)->get_corpus())
                {