Cleanup ODR-based type canonicalization optimization gating logic
authorDodji Seketeli <dodji@redhat.com>
Wed, 4 Jan 2017 22:54:16 +0000 (23:54 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 5 Jan 2017 11:26:20 +0000 (12:26 +0100)
During type canonicalization we use an ODR-based optimization which
consists of saying that if two types of the same kind have the same
name and are defined in the same ABI corpus, then they are the same
type -- whithout needing to actually perform a structural comparison
of both types.  This speeds up type canonicalization greatly for types
that are duplicated in the ABI corpus.

The condition to apply that ODR-based optimization is basically that
the binary we are looking at must be in C++.

This patch just makes that condition clearer.

* src/abg-ir.cc (type_base::get_canonical_type_for): Make it clear
that the ODR-based optimization is allowed only on C++ ABI
corpora.

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

index 9fa993ad515daeff9e8c434bc2bf46849bb782c0..b932781495879a653b849309b32a0672c08450df 100644 (file)
@@ -9030,12 +9030,11 @@ type_base::get_canonical_type_for(type_base_sptr t)
          translation_unit::language other_lang =
            (*it)->get_translation_unit()->get_language();
 
+         bool is_odr_allowed =
+           is_cplus_plus_language(lang) && is_cplus_plus_language(other_lang);
+
          if (t_corpus
-             && ((is_c_language(lang) || is_cplus_plus_language(lang))
-                 && (is_c_language(other_lang)
-                     || is_cplus_plus_language(other_lang)))
-             // We are doing the ODR-based optimization just for
-             // non-anonymous user-defined types, and built-in types
+             && is_odr_allowed
              && type_eligible_for_odr_based_comparison(t))
            {
              if (const corpus* it_corpus = (*it)->get_corpus())