Bug 27236 - Pointer comparison wrongly fails because of typedef change
Commit Message
Hello,
Suppose we have a type struct S and a type T defined as:
typedef struct S T;
Today, Libabigail considers that the two pointers "struct S*" and "T*"
are different.
The problem is that this can cause spurious change reports (as
reported by (abidw --abidiff) in binaries where we have the same type
defined more than once, each time using a different various around
this theme.
This patch make libabigail to now consider that "struct S*" and "T*"
are equal. It does the same for references and arrays.
* src/abg-ir.cc (equals): In the overloads for pointer_type_def,
reference_type_def and array_type_def, compare the pointed-to-type
modulo typedefs.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Adjust.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
Adjust.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
src/abg-ir.cc | 12 +++++++++---
.../test42-PR21296-clanggcc-report0.txt | 2 --
...4.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt | 2 +-
....4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt | 11 +----------
4 files changed, 11 insertions(+), 16 deletions(-)
@@ -14101,7 +14101,9 @@ pointer_type_def::pointer_type_def(const type_base_sptr& pointed_to,
bool
equals(const pointer_type_def& l, const pointer_type_def& r, change_kind* k)
{
- bool result = (l.get_pointed_to_type() == r.get_pointed_to_type());
+ // Compare the pointed-to-types modulo the typedefs they might have
+ bool result = (peel_typedef_type(l.get_pointed_to_type())
+ == peel_typedef_type(r.get_pointed_to_type()));
if (!result)
if (k)
{
@@ -14406,7 +14408,9 @@ equals(const reference_type_def& l, const reference_type_def& r, change_kind* k)
return false;
}
- bool result = (l.get_pointed_to_type() == r.get_pointed_to_type());
+ // Compare the pointed-to-types modulo the typedefs they might have
+ bool result = (peel_typedef_type(l.get_pointed_to_type())
+ == (peel_typedef_type(r.get_pointed_to_type())));
if (!result)
if (k)
{
@@ -15226,7 +15230,9 @@ equals(const array_type_def& l, const array_type_def& r, change_kind* k)
return false;
}
- if (l.get_element_type() != r.get_element_type())
+ // Compare the element types modulo the typedefs they might have
+ if (peel_typedef_type(l.get_element_type())
+ != peel_typedef_type(r.get_element_type()))
{
result = false;
if (k)
@@ -55,8 +55,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
[C] 'function std::remove_reference<STR&>::type&& std::move<STR&>(STR&)' has some indirect sub-type changes:
'function std::remove_reference<STR&>::type&& std::move<STR&>(STR&) {_ZSt4moveIR3STREONSt16remove_referenceIT_E4typeEOS3_}' now becomes 'function std::remove_reference<STR &>::type&& std::move<STR &>(STR&) {_ZSt4moveIR3STREONSt16remove_referenceIT_E4typeEOS3_}'
return type changed:
- in referenced type 'typedef std::remove_reference<STR&>::type':
- typedef name changed from std::remove_reference<STR&>::type to std::remove_reference<STR &>::type
[C] 'function void tpl<std::tuple<STR&&> >(std::tuple<STR&&>)' has some indirect sub-type changes:
'function void tpl<std::tuple<STR&&> >(std::tuple<STR&&>) {_Z3tplISt5tupleIJO3STREEEvT_}' now becomes 'function void tpl<std::tuple<STR &&> >(std::tuple<STR &&>) {_Z3tplISt5tupleIJO3STREEEvT_}'
@@ -15,7 +15,7 @@
underlying type '_IceConn*' changed:
in pointed to type 'struct _IceConn' at ICEconn.h:131:1:
type size hasn't changed
- 2 data member changes (3 filtered):
+ 2 data member changes (2 filtered):
type of 'IceListenObj _IceConn::listen_obj' changed:
underlying type '_IceListenObj*' changed:
in pointed to type 'struct _IceListenObj' at ICElibint.h:120:1:
@@ -303,16 +303,7 @@
type of 'CommonChannel CursorChannel::common' changed, as reported earlier
type of 'QXLInstance* RedWorker::qxl' changed:
in pointed to type 'typedef QXLInstance' at spice-qxl.h:34:1:
- underlying type 'struct QXLInstance' at spice.h:259:1 changed:
- type size hasn't changed
- 1 data member change:
- type of 'QXLState* QXLInstance::st' changed:
- in pointed to type 'typedef QXLState' at spice-qxl.h:35:1:
- underlying type 'struct QXLState' at reds.h:93:1 changed:
- type size hasn't changed
- 1 data member change:
- type of 'RedDispatcher* QXLState::dispatcher' changed:
- pointed to type 'struct RedDispatcher' changed, as being reported
+ underlying type 'struct QXLInstance' changed, as being reported
type of 'RedDispatcher* RedWorker::red_dispatcher' changed:
in pointed to type 'typedef RedDispatcher':
entity changed from 'typedef RedDispatcher' to compatible type 'struct RedDispatcher'