mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-30 05:42:05 +00:00
From inside the comparison engine re-use IR's equality operators
From inside the comparison engine, I noticed that there were some discrepancies between some comparison performed there and the comparison performed from inside the internal representation of abigail::ir. This can lead to some change reports in which the reporter thinks there are changes in the IR where there actually are not. This patch re-uses comparison operators from the generic IR, rather than re-implementing them in the comparison engine. * include/abg-ir.h (operator==(scope_decl_sptr, scope_decl_sptr)): Declare. (operator==(type_decl_sptr, type_decl_sptr)): Likewise. (operator==(enum_type_decl_sptr, enum_type_decl_sptr)): Likewise. * src/abg-comparison.cc (diff_length_of_decl_bases) (diff_length_of_type_bases): Remove these static functions. (class_diff::has_changes): Re-use the comparison operator for class_decl_sptr. (type_decl_diff::has_changes): Re-use the comparison operator for type_decl_sptr. * src/abg-ir.cc (operator==(scope_decl_sptr, scope_decl_sptr)): Define. (operator==(type_decl_sptr, type_decl_sptr)): Likewise. (operator==(enum_type_decl_sptr, enum_type_decl_sptr)): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
30295244e8
commit
de8dec2016
@ -895,6 +895,9 @@ public:
|
||||
remove_decl_from_scope(decl_base_sptr decl);
|
||||
};//end class scope_decl
|
||||
|
||||
bool
|
||||
operator==(scope_decl_sptr, scope_decl_sptr);
|
||||
|
||||
/// Hasher for the @ref scope_decl type.
|
||||
struct scope_decl::hash
|
||||
{
|
||||
@ -1104,6 +1107,9 @@ public:
|
||||
bool
|
||||
equals(const scope_type_decl&, const scope_type_decl&, change_kind*);
|
||||
|
||||
bool
|
||||
operator==(type_decl_sptr, type_decl_sptr);
|
||||
|
||||
/// A type that introduces a scope.
|
||||
class scope_type_decl : public scope_decl, public virtual type_base
|
||||
{
|
||||
@ -1518,6 +1524,8 @@ public:
|
||||
virtual ~enum_type_decl();
|
||||
}; // end class enum_type_decl
|
||||
|
||||
bool
|
||||
operator==(enum_type_decl_sptr l, enum_type_decl_sptr r);
|
||||
/// The abstraction of an enumerator
|
||||
class enum_type_decl::enumerator
|
||||
{
|
||||
|
@ -4268,44 +4268,6 @@ get_pretty_representation(diff* d)
|
||||
string prefix= "diff of ";
|
||||
return prefix + get_pretty_representation(d->first_subject());
|
||||
}
|
||||
/// Return the length of the diff between two instances of @ref decl_base
|
||||
///
|
||||
/// @param first the first instance of @ref decl_base to consider.
|
||||
///
|
||||
/// @param second the second instance of @ref decl_base to consider.
|
||||
///
|
||||
/// @return the length of the differences between @p first and @p second.
|
||||
static unsigned
|
||||
diff_length_of_decl_bases(decl_base_sptr first, decl_base_sptr second)
|
||||
{
|
||||
unsigned l = 0;
|
||||
|
||||
if (first->get_name() != second->get_name())
|
||||
++l;
|
||||
if (first->get_visibility() != second->get_visibility())
|
||||
++l;
|
||||
return l;
|
||||
}
|
||||
|
||||
/// Return the length of the diff between two instances of @ref type_base
|
||||
///
|
||||
/// @param first the first instance of @ref type_base to consider.
|
||||
///
|
||||
/// @param second the second instance of @ref type_base to consider.
|
||||
///
|
||||
/// @return the length of the differences between @p first and @p second.
|
||||
static unsigned
|
||||
diff_length_of_type_bases(type_base_sptr first, type_base_sptr second)
|
||||
{
|
||||
unsigned l = 0;
|
||||
|
||||
if (first->get_size_in_bits() != second->get_size_in_bits())
|
||||
++l;
|
||||
if (first->get_alignment_in_bits() != second->get_alignment_in_bits())
|
||||
++l;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static bool
|
||||
maybe_report_diff_for_member(decl_base_sptr decl1,
|
||||
@ -6963,17 +6925,7 @@ class_diff::get_pretty_representation() const
|
||||
/// @return true iff the current diff node carries a change.
|
||||
bool
|
||||
class_diff::has_changes() const
|
||||
{
|
||||
if (!!first_class_decl() != !! second_class_decl())
|
||||
return true;
|
||||
if (first_class_decl().get() == second_class_decl().get())
|
||||
return false;
|
||||
if (first_class_decl()->get_hash() && second_class_decl()->get_hash()
|
||||
&& first_class_decl()->get_hash() != second_class_decl()->get_hash())
|
||||
return true;
|
||||
|
||||
return (*first_class_decl() != *second_class_decl());
|
||||
}
|
||||
{return (first_class_decl() != second_class_decl());}
|
||||
|
||||
/// @return true iff the current diff node carries local changes.
|
||||
bool
|
||||
@ -9547,15 +9499,7 @@ type_decl_diff::get_pretty_representation() const
|
||||
/// @return true iff the current diff node carries a change.
|
||||
bool
|
||||
type_decl_diff::has_changes() const
|
||||
{
|
||||
type_base_sptr f = is_type(first_type_decl()),
|
||||
s = is_type(second_type_decl());
|
||||
assert(f && s);
|
||||
|
||||
return (diff_length_of_decl_bases(first_type_decl(),
|
||||
second_type_decl())
|
||||
|| diff_length_of_type_bases(f, s));
|
||||
}
|
||||
{return first_type_decl() != second_type_decl();}
|
||||
|
||||
/// @return true iff the current diff node carries local changes.
|
||||
bool
|
||||
|
@ -2589,6 +2589,23 @@ scope_decl::operator==(const decl_base& o) const
|
||||
return equals(*this, *other, 0);
|
||||
}
|
||||
|
||||
/// Equality operator for @ref scope_decl_sptr.
|
||||
///
|
||||
/// @param l the left hand side operand of the equality operator.
|
||||
///
|
||||
/// @pram r the right hand side operand of the equalify operator.
|
||||
///
|
||||
/// @return true iff @p l equals @p r.
|
||||
bool
|
||||
operator==(scope_decl_sptr l, scope_decl_sptr r)
|
||||
{
|
||||
if (!!l != !!r)
|
||||
return false;
|
||||
if (l.get() == r.get())
|
||||
return true;
|
||||
return *l == *r;
|
||||
}
|
||||
|
||||
/// Find a member of the current scope and return an iterator on it.
|
||||
///
|
||||
/// @param decl the scope member to find.
|
||||
@ -4125,6 +4142,23 @@ type_decl::operator==(const type_decl& o) const
|
||||
return *this == other;
|
||||
}
|
||||
|
||||
/// Equality operator for @ref type_decl_sptr.
|
||||
///
|
||||
/// @param l the first operand to compare.
|
||||
///
|
||||
/// @param r the second operand to compare.
|
||||
///
|
||||
/// @return true iff @p l equals @p r.
|
||||
bool
|
||||
operator==(type_decl_sptr l, type_decl_sptr r)
|
||||
{
|
||||
if (!!l != !!r)
|
||||
return false;
|
||||
if (l.get() == r.get())
|
||||
return true;
|
||||
return *l == *r;
|
||||
}
|
||||
|
||||
string
|
||||
type_decl::get_pretty_representation() const
|
||||
{return get_qualified_name();}
|
||||
@ -5455,6 +5489,24 @@ enum_type_decl::operator==(const type_base& o) const
|
||||
return *this == *other;
|
||||
}
|
||||
|
||||
/// Equality operator for @ref enum_type_decl_sptr.
|
||||
///
|
||||
/// @param l the first operand to compare.
|
||||
///
|
||||
/// @param r the second operand to compare.
|
||||
///
|
||||
/// @return true iff @p l equals @p r.
|
||||
bool
|
||||
operator==(enum_type_decl_sptr l, enum_type_decl_sptr r)
|
||||
{
|
||||
if (!!l != !!r)
|
||||
return false;
|
||||
if (l.get() == r.get())
|
||||
return true;
|
||||
decl_base_sptr o = r;
|
||||
return *l == *o;
|
||||
}
|
||||
|
||||
/// The type of the private data of an @ref
|
||||
/// enum_type_decl::enumerator.
|
||||
class enum_type_decl::enumerator::priv
|
||||
|
Loading…
Reference in New Issue
Block a user