Fix comparison wrt hash number

* src/abg-ir.cc (decl_base::operator==): Do not consider empty
	hashes.
	(class_decl::operator==): Better support for comparing decl-only
	classes against non-decl-only classes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-03-10 23:15:54 +01:00
parent 372cd79430
commit 6021659d3b

View File

@ -432,7 +432,8 @@ decl_base::get_qualified_name() const
bool
decl_base::operator==(const decl_base& other) const
{
if (hash_ != other.hash_)
if (hash_ && other.hash_
&& hash_ != other.hash_)
return false;
return get_name() == other.get_name();
}
@ -3283,11 +3284,6 @@ class_decl::operator==(const decl_base& other) const
if (comparison_started_ && o.comparison_started_)
return true;
if (hash_ != 0
&& other.hash_ != 0
&& hash_ != other.hash_)
return false;
comparison_started_ = true;
o.comparison_started_ = true;
@ -3311,7 +3307,9 @@ class_decl::operator==(const decl_base& other) const
? o.get_definition_of_declaration().get()
: op;
if (!def1 || !def2)
if (!def1 || !def2
|| def1->is_declaration_only()
|| def2->is_declaration_only())
{
string q1 = get_qualified_name();
string q2 = o.get_qualified_name();
@ -3324,14 +3322,16 @@ class_decl::operator==(const decl_base& other) const
RETURN(val);
}
if (hash_ != 0
&& other.hash_ != 0
&& hash_ != other.hash_)
RETURN(false);
// No need to go further if the classes have different names or
// different size / alignment.
if (!(decl_base::operator==(o) && type_base::operator==(o)))
RETURN(false);
if (hash_ != other.hash_)
RETURN(false);
// Compare bases.
{
if (get_base_specifiers().size() != o.get_base_specifiers().size())
@ -3351,6 +3351,7 @@ class_decl::operator==(const decl_base& other) const
}
//Compare member types
#if 0
{
if (get_member_types().size() != o.get_member_types().size())
RETURN(false);
@ -3370,6 +3371,7 @@ class_decl::operator==(const decl_base& other) const
RETURN(false);
}
}
#endif
//compare data_members
{