mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-18 07:54:36 +00:00
Bug 18904 - Fix support for C++ rvalue references
* src/abg-comparison.cc (reference_diff::has_changes): Just compare the references, rather than assuming that the change can only be on underlying types. (reference_diff::report): Describe lvalue/rvalue changes for references. * src/abg-ir.cc (reference_type_def::reference_type_def): Properly set the name for an rvalue reference. (equals): For references, compare lvalue-ness too. (reference_type_def::get_qualified_name): Properly set rvalue reference names. * tests/data/test-diff-filter/test30-pr18904-rvalueref-liba.so: New test input. * tests/data/test-diff-filter/test30-pr18904-rvalueref-libb.so: New test input. * tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: New test reference output. * tests/data/Makefile.am: Add the new files to source distribution. * tests/test-diff-filter.cc (in_out_specs): Run the new tests. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
3b6bada297
commit
49759d3be8
@ -7229,9 +7229,7 @@ reference_diff::get_pretty_representation() const
|
||||
bool
|
||||
reference_diff::has_changes() const
|
||||
{
|
||||
return underlying_type_diff()
|
||||
? underlying_type_diff()->has_changes()
|
||||
: false;
|
||||
return first_reference() != second_reference();
|
||||
}
|
||||
|
||||
/// @return true iff the current diff node carries local changes.
|
||||
@ -7255,6 +7253,28 @@ reference_diff::report(ostream& out, const string& indent) const
|
||||
if (!to_be_reported())
|
||||
return;
|
||||
|
||||
reference_type_def_sptr f = first_reference(), s = second_reference();
|
||||
assert(f && s);
|
||||
|
||||
|
||||
if (f->is_lvalue() != s->is_lvalue())
|
||||
{
|
||||
string f_repr = f->get_pretty_representation(),
|
||||
s_repr = s->get_pretty_representation();
|
||||
|
||||
out << indent;
|
||||
if (f->is_lvalue())
|
||||
out << "lvalue reference type '" << f_repr
|
||||
<< " became an rvalue reference type: '"
|
||||
<< s_repr
|
||||
<< "'";
|
||||
else
|
||||
out << "rvalue reference type '" << f_repr
|
||||
<< " became an lvalue reference type: '"
|
||||
<< s_repr
|
||||
<< "'\n";
|
||||
}
|
||||
|
||||
if (diff_sptr d = underlying_type_diff())
|
||||
{
|
||||
RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2(d, "referenced type");
|
||||
|
@ -6497,6 +6497,8 @@ reference_type_def::reference_type_def(const type_base_sptr pointed_to,
|
||||
{
|
||||
decl_base_sptr pto = dynamic_pointer_cast<decl_base>(pointed_to);
|
||||
string name = pto->get_name() + "&";
|
||||
if (!is_lvalue())
|
||||
name += "&";
|
||||
set_name(name);
|
||||
}
|
||||
catch (...)
|
||||
@ -6525,6 +6527,13 @@ reference_type_def::reference_type_def(const type_base_sptr pointed_to,
|
||||
bool
|
||||
equals(const reference_type_def& l, const reference_type_def& r, change_kind* k)
|
||||
{
|
||||
if (l.is_lvalue() != r.is_lvalue())
|
||||
{
|
||||
if (k)
|
||||
*k |= LOCAL_CHANGE_KIND;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool result = (l.get_pointed_to_type() == r.get_pointed_to_type());
|
||||
if (!result)
|
||||
if (k)
|
||||
@ -6592,7 +6601,10 @@ reference_type_def::get_qualified_name() const
|
||||
get_type_declaration(type_or_void(get_pointed_to_type()));
|
||||
string name;
|
||||
td->get_qualified_name(name);
|
||||
set_qualified_name(name + "&");
|
||||
if (is_lvalue())
|
||||
set_qualified_name(name + "&");
|
||||
else
|
||||
set_qualified_name(name + "&&");
|
||||
}
|
||||
return peek_qualified_name();
|
||||
}
|
||||
|
@ -447,6 +447,9 @@ test-diff-filter/test29-finer-redundancy-marking-v0.o \
|
||||
test-diff-filter/test29-finer-redundancy-marking-v1.cc \
|
||||
test-diff-filter/test29-finer-redundancy-marking-v0.cc \
|
||||
test-diff-filter/test29-finer-redundancy-marking-v1.o \
|
||||
test-diff-filter/test30-pr18904-rvalueref-liba.so \
|
||||
test-diff-filter/test30-pr18904-rvalueref-libb.so \
|
||||
test-diff-filter/test30-pr18904-rvalueref-report0.txt \
|
||||
\
|
||||
test-diff-suppr/test0-type-suppr-v0.cc \
|
||||
test-diff-suppr/test0-type-suppr-v1.cc \
|
||||
|
BIN
tests/data/test-diff-filter/test30-pr18904-rvalueref-liba.so
Executable file
BIN
tests/data/test-diff-filter/test30-pr18904-rvalueref-liba.so
Executable file
Binary file not shown.
BIN
tests/data/test-diff-filter/test30-pr18904-rvalueref-libb.so
Executable file
BIN
tests/data/test-diff-filter/test30-pr18904-rvalueref-libb.so
Executable file
Binary file not shown.
1611
tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt
Normal file
1611
tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -369,6 +369,13 @@ InOutSpec in_out_specs[] =
|
||||
"data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt",
|
||||
"output/test-diff-filter/test29-finer-redundancy-marking-report-0.txt",
|
||||
},
|
||||
{
|
||||
"data/test-diff-filter/test30-pr18904-rvalueref-liba.so",
|
||||
"data/test-diff-filter/test30-pr18904-rvalueref-libb.so",
|
||||
"--no-linkage-name --no-redundant",
|
||||
"data/test-diff-filter/test30-pr18904-rvalueref-report0.txt",
|
||||
"output/test-diff-filter/test30-pr18904-rvalueref-report0.txt",
|
||||
},
|
||||
// This should be the last entry
|
||||
{NULL, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user