Walk function_type_diff tree in a deterministic way

Some children nodes of function_type_diff are traversed in a
non-deterministic order depending on the ordering of elements in an
unordered_map.  This can lead to spurious reporting differences
between e.g the x86_64 an i686 platforms.

This patch sorts the parameter diff children nodes of
function_type_diff using the parameter index.

	* src/abg-comparison.cc
	(function_type_diff::priv::{sorted_subtype_changed_parms_,
	sorted_changed_parms_by_id_}): Add two data members.
	(function_type_diff::ensure_lookup_tables_populated): Sort the
	changed parameters here ...
	(function_type_diff::report): ... not here.
	(function_type_diff::chain_into_hierarchy): Chain the *sorted*
	changed parameters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2016-03-07 16:35:16 +01:00
parent 9efa6af3e2
commit ff91eea8cf

View File

@ -11329,13 +11329,15 @@ struct function_type_diff::priv
// This map contains parameters sub-type changes that don't change // This map contains parameters sub-type changes that don't change
// the name of the type of the parameter. // the name of the type of the parameter.
string_fn_parm_diff_sptr_map subtype_changed_parms_; string_fn_parm_diff_sptr_map subtype_changed_parms_;
unsigned_parm_map deleted_parms_by_id_; vector<fn_parm_diff_sptr> sorted_subtype_changed_parms_;
unsigned_parm_map added_parms_by_id_;
// This map contains parameter type changes that actually change the // This map contains parameter type changes that actually change the
// name of the type of the parameter, but in a compatible way; // name of the type of the parameter, but in a compatible way;
// otherwise, the mangling of the function would have changed (in // otherwise, the mangling of the function would have changed (in
// c++ at least). // c++ at least).
unsigned_fn_parm_diff_sptr_map changed_parms_by_id_; unsigned_fn_parm_diff_sptr_map changed_parms_by_id_;
vector<fn_parm_diff_sptr> sorted_changed_parms_by_id_;
unsigned_parm_map deleted_parms_by_id_;
unsigned_parm_map added_parms_by_id_;
priv() priv()
{} {}
@ -11413,6 +11415,10 @@ function_type_diff::ensure_lookup_tables_populated()
} }
} }
sort_string_fn_parm_diff_sptr_map(priv_->subtype_changed_parms_,
priv_->sorted_subtype_changed_parms_);
sort_string_fn_parm_diff_sptr_map(priv_->changed_parms_by_id_,
priv_->sorted_changed_parms_by_id_);
sort_string_parm_map(priv_->deleted_parms_, sort_string_parm_map(priv_->deleted_parms_,
priv_->sorted_deleted_parms_); priv_->sorted_deleted_parms_);
@ -11616,12 +11622,9 @@ function_type_diff::report(ostream& out, const string& indent) const
// this shouldn't be as straightforward. // this shouldn't be as straightforward.
// //
// Report about the parameter types that have changed sub-types. // Report about the parameter types that have changed sub-types.
vector<fn_parm_diff_sptr> sorted_fn_parms;
sort_string_fn_parm_diff_sptr_map(priv_->subtype_changed_parms_,
sorted_fn_parms);
for (vector<fn_parm_diff_sptr>::const_iterator i = for (vector<fn_parm_diff_sptr>::const_iterator i =
sorted_fn_parms.begin(); priv_->sorted_subtype_changed_parms_.begin();
i != sorted_fn_parms.end(); i != priv_->sorted_subtype_changed_parms_.end();
++i) ++i)
{ {
diff_sptr d = *i; diff_sptr d = *i;
@ -11632,11 +11635,9 @@ function_type_diff::report(ostream& out, const string& indent) const
// compatible -- otherwise they would have changed the mangled name // compatible -- otherwise they would have changed the mangled name
// of the function and the function would have been reported as // of the function and the function would have been reported as
// removed. // removed.
sorted_fn_parms.clear(); for (vector<fn_parm_diff_sptr>::const_iterator i =
sort_string_fn_parm_diff_sptr_map(priv_->changed_parms_by_id_, priv_->sorted_changed_parms_by_id_.begin();
sorted_fn_parms); i != priv_->sorted_changed_parms_by_id_.end();
for (vector<fn_parm_diff_sptr>::const_iterator i = sorted_fn_parms.begin();
i != sorted_fn_parms.end();
++i) ++i)
{ {
diff_sptr d = *i; diff_sptr d = *i;
@ -11686,18 +11687,18 @@ function_type_diff::chain_into_hierarchy()
if (diff_sptr d = return_type_diff()) if (diff_sptr d = return_type_diff())
append_child_node(d); append_child_node(d);
for (string_fn_parm_diff_sptr_map::const_iterator i = for (vector<fn_parm_diff_sptr>::const_iterator i =
subtype_changed_parms().begin(); priv_->sorted_subtype_changed_parms_.begin();
i != subtype_changed_parms().end(); i != priv_->sorted_subtype_changed_parms_.end();
++i) ++i)
if (diff_sptr d = i->second) if (diff_sptr d = *i)
append_child_node(d); append_child_node(d);
for (unsigned_fn_parm_diff_sptr_map::const_iterator i = for (vector<fn_parm_diff_sptr>::const_iterator i =
priv_->changed_parms_by_id_.begin(); priv_->sorted_changed_parms_by_id_.begin();
i != priv_->changed_parms_by_id_.end(); i != priv_->sorted_changed_parms_by_id_.end();
++i) ++i)
if (diff_sptr d = i->second) if (diff_sptr d = *i)
append_child_node(d); append_child_node(d);
} }