mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-17 15:34:34 +00:00
Sort reported changed declarations & types in a given scope
* src/abg-comparison.cc (struct changed_type_or_decl_comp, struct changed_vars_comp): New comparison functors. (sort_changed_type_or_decl, sort_changed_vars): New static functions. (scope_diff::report): Use the above to sort changed declarations, and types in a given scope. (corpus_diff::report): Likewise for the changed variables. * tests/data/test-abidiff/test-struct1-report.txt: Adjust. * tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Likewise. * tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
0dd5f64279
commit
3be48230b7
@ -7920,6 +7920,49 @@ scope_diff::has_local_changes() const
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Functor to compare two instance of @ref changed_type_or_decl.
|
||||
struct changed_type_or_decl_comp
|
||||
{
|
||||
/// Return true if the first parm is less than the second one.
|
||||
///
|
||||
/// @param f the first changed type or decl to consider.
|
||||
///
|
||||
/// @param s the second changed type of decl to consider.
|
||||
///
|
||||
/// @return true if @p f is less than @p s.
|
||||
bool
|
||||
operator()(const changed_type_or_decl& f,
|
||||
const changed_type_or_decl& s)
|
||||
{
|
||||
decl_base_sptr first_decl = f.first;
|
||||
decl_base_sptr second_decl = s.first;
|
||||
|
||||
return (first_decl->get_qualified_name()
|
||||
< second_decl->get_qualified_name());
|
||||
}
|
||||
}; // end struct changed_type_or_decl_comp
|
||||
|
||||
/// Sort an instance of @ref string_changed_type_or_decl_map map.
|
||||
///
|
||||
/// @param map the input map to sort.
|
||||
///
|
||||
/// @param sorted the resulting sorted vector of @ref
|
||||
/// changed_type_or_decl_comp. This vector is populated with the
|
||||
/// sorted content.
|
||||
static void
|
||||
sort_changed_type_or_decl(const string_changed_type_or_decl_map& map,
|
||||
vector<changed_type_or_decl>& sorted)
|
||||
{
|
||||
sorted.reserve(map.size());
|
||||
for (string_changed_type_or_decl_map::const_iterator i = map.begin();
|
||||
i != map.end();
|
||||
++i)
|
||||
sorted.push_back(i->second);
|
||||
|
||||
changed_type_or_decl_comp comp;
|
||||
std::sort(sorted.begin(), sorted.end(), comp);
|
||||
}
|
||||
|
||||
/// Report the changes of one scope against another.
|
||||
///
|
||||
/// @param out the out stream to report the changes to.
|
||||
@ -7940,18 +7983,18 @@ scope_diff::report(ostream& out, const string& indent) const
|
||||
else
|
||||
out << indent << num_changed_types << " changed types:\n";
|
||||
|
||||
for (string_changed_type_or_decl_map::const_iterator i =
|
||||
changed_types().begin();
|
||||
i != changed_types().end();
|
||||
vector<changed_type_or_decl> sorted_changed_types;
|
||||
sort_changed_type_or_decl(changed_types(), sorted_changed_types);
|
||||
for (vector<changed_type_or_decl>::const_iterator i =
|
||||
sorted_changed_types.begin();
|
||||
i != sorted_changed_types.end();
|
||||
++i)
|
||||
{
|
||||
out << indent << " '"
|
||||
<< i->second.first->get_pretty_representation()
|
||||
<< i->first->get_pretty_representation()
|
||||
<< "' changed:\n";
|
||||
|
||||
diff_sptr diff = compute_diff_for_types(i->second.first,
|
||||
i->second.second,
|
||||
context());
|
||||
diff_sptr diff = compute_diff_for_types(i->first, i->second, context());
|
||||
if (diff)
|
||||
diff->report(out, indent + " ");
|
||||
}
|
||||
@ -7965,19 +8008,19 @@ scope_diff::report(ostream& out, const string& indent) const
|
||||
else
|
||||
out << indent << num_changed_decls << " changed declarations:\n";
|
||||
|
||||
for (string_changed_type_or_decl_map::const_iterator i=
|
||||
changed_decls().begin();
|
||||
i != changed_decls().end ();
|
||||
vector<changed_type_or_decl> sorted_changed_decls;
|
||||
sort_changed_type_or_decl(changed_decls(), sorted_changed_decls);
|
||||
for (vector<changed_type_or_decl>::const_iterator i=
|
||||
sorted_changed_decls.begin();
|
||||
i != sorted_changed_decls.end ();
|
||||
++i)
|
||||
{
|
||||
out << indent << " '"
|
||||
<< i->second.first->get_pretty_representation()
|
||||
<< i->first->get_pretty_representation()
|
||||
<< "' was changed to '"
|
||||
<< i->second.second->get_pretty_representation()
|
||||
<< i->second->get_pretty_representation()
|
||||
<< "':\n";
|
||||
diff_sptr diff = compute_diff_for_decls(i->second.first,
|
||||
i->second.second,
|
||||
context());
|
||||
diff_sptr diff = compute_diff_for_decls(i->first, i->second, context());
|
||||
if (diff)
|
||||
diff->report(out, indent + " ");
|
||||
}
|
||||
@ -9995,6 +10038,45 @@ sort_string_changed_function_ptr_map(const string_changed_function_ptr_map& map,
|
||||
std::sort(sorted.begin(), sorted.end(), comp);
|
||||
}
|
||||
|
||||
/// Functor to sort instances of @ref changed_var_ptr.
|
||||
struct changed_vars_comp
|
||||
{
|
||||
/// Return true if the first argument is less than the second one.
|
||||
///
|
||||
/// @param f the first argument to consider.
|
||||
///
|
||||
/// @param s the second argument to consider.
|
||||
///
|
||||
/// @return true if @p f is less than @p s.
|
||||
bool
|
||||
operator()(const changed_var_ptr& f,
|
||||
const changed_var_ptr& s)
|
||||
{
|
||||
return (f.first->get_qualified_name()
|
||||
< s.first->get_qualified_name());
|
||||
}
|
||||
}; // end struct changed_vars_comp
|
||||
|
||||
/// Sort of an instance of @ref changed_var_ptr_map map.
|
||||
///
|
||||
/// @param map the input map to sort.
|
||||
///
|
||||
/// @param sorted the ouptut sorted vector of @ref changed_var_ptr.
|
||||
/// It's populated with the sorted content.
|
||||
static void
|
||||
sort_changed_vars(const string_changed_var_ptr_map& map,
|
||||
vector<changed_var_ptr>& sorted)
|
||||
{
|
||||
sorted.reserve(map.size());
|
||||
for (string_changed_var_ptr_map::const_iterator i = map.begin();
|
||||
i != map.end();
|
||||
++i)
|
||||
sorted.push_back(i->second);
|
||||
|
||||
changed_vars_comp comp;
|
||||
std::sort(sorted.begin(), sorted.end(), comp);
|
||||
}
|
||||
|
||||
/// For a given symbol, emit a string made of its name and version.
|
||||
/// The string also contains the list of symbols that alias this one.
|
||||
///
|
||||
@ -10251,13 +10333,16 @@ corpus_diff::report(ostream& out, const string& indent) const
|
||||
out << indent << num_changed
|
||||
<< " Changed variables:\n\n";
|
||||
string n1, n2;
|
||||
for (string_changed_var_ptr_map::const_iterator i =
|
||||
priv_->changed_vars_.begin();
|
||||
i != priv_->changed_vars_.end();
|
||||
|
||||
vector<changed_var_ptr> sorted_changed_vars;
|
||||
sort_changed_vars(priv_->changed_vars_, sorted_changed_vars);
|
||||
for (vector<changed_var_ptr>::const_iterator i =
|
||||
sorted_changed_vars.begin();
|
||||
i != sorted_changed_vars.end();
|
||||
++i)
|
||||
{
|
||||
var_decl_sptr f(i->second.first, noop_deleter());
|
||||
var_decl_sptr s(i->second.second, noop_deleter());
|
||||
var_decl_sptr f(i->first, noop_deleter());
|
||||
var_decl_sptr s(i->second, noop_deleter());
|
||||
diff_sptr diff = compute_diff_for_decls(f, s, context());
|
||||
|
||||
if (!diff)
|
||||
|
@ -17,15 +17,15 @@
|
||||
alignment changed from 32 to 8 bits
|
||||
'unsigned int s0::m2' offset changed from 128 to 192
|
||||
|
||||
's0*' changed:
|
||||
pointed to type 'class s0' changed, as reported earlier
|
||||
'const s0*' changed:
|
||||
in pointed to type 'const s0':
|
||||
unqualified underlying type 'class s0' changed, as reported earlier
|
||||
'class s0' changed:
|
||||
details were reported earlier
|
||||
's0&' changed:
|
||||
referenced type 'class s0' changed, as reported earlier
|
||||
'const s0*' changed:
|
||||
in pointed to type 'const s0':
|
||||
unqualified underlying type 'class s0' changed, as reported earlier
|
||||
's0*' changed:
|
||||
pointed to type 'class s0' changed, as reported earlier
|
||||
'function int bar(s0&)' was removed
|
||||
|
||||
'function int baz(s0&)' was added
|
||||
|
@ -3,15 +3,6 @@ Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
|
||||
|
||||
2 Changed variables:
|
||||
|
||||
'S1* var1' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S1':
|
||||
size changed from 32 to 64 bits
|
||||
1 data member insertion:
|
||||
'char S1::inserted_member', at offset 0 (in bits)
|
||||
1 data member change:
|
||||
'int S1::m0' offset changed from 0 to 32
|
||||
|
||||
'S0* var0' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S0':
|
||||
@ -21,4 +12,13 @@ Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
|
||||
1 data member change:
|
||||
'int S0::m0' offset changed from 0 to 32
|
||||
|
||||
'S1* var1' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S1':
|
||||
size changed from 32 to 64 bits
|
||||
1 data member insertion:
|
||||
'char S1::inserted_member', at offset 0 (in bits)
|
||||
1 data member change:
|
||||
'int S1::m0' offset changed from 0 to 32
|
||||
|
||||
|
||||
|
@ -3,15 +3,6 @@ Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
|
||||
|
||||
2 Changed variables:
|
||||
|
||||
'S1* var1' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S1':
|
||||
size changed from 32 to 64 bits
|
||||
1 data member insertion:
|
||||
'char S1::inserted_member', at offset 0 (in bits)
|
||||
1 data member change:
|
||||
'int S1::m0' offset changed from 0 to 32
|
||||
|
||||
'S0* var0' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S0':
|
||||
@ -21,4 +12,13 @@ Variables changes summary: 0 Removed, 2 Changed, 0 Added variables
|
||||
1 data member change:
|
||||
'int S0::m0' offset changed from 0 to 32
|
||||
|
||||
'S1* var1' was changed:
|
||||
type of variable changed:
|
||||
in pointed to type 'struct S1':
|
||||
size changed from 32 to 64 bits
|
||||
1 data member insertion:
|
||||
'char S1::inserted_member', at offset 0 (in bits)
|
||||
1 data member change:
|
||||
'int S1::m0' offset changed from 0 to 32
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user