[03/27] ir: decl-only classes don't equal fully defined classes under ODR

Message ID 87wmjzmihe.fsf@seketeli.org
State New
Headers
Series Implement type hashing & fix self-comparing gcc-gnat in fc37 |

Commit Message

Dodji Seketeli Aug. 29, 2024, 3:55 p.m. UTC
  Hello,

Until now, when the One Definition Rule is in effect (when analyzing
C++, for instance) we assume that a decl-only class equals all the
fully-defined classes of the same name.  Now that we are using type
hashing to determine type equality during type canonicalization, we
cannot keep that assumption, because the hash of a decl-only class
does not necessarily equals the hash of its definition.  Actually,
decl-only classes don't have hashes.  So this patch removes that
assumption.

Note that even with this patch, "make check" still yields 3 failures
that are still XFAILed in the test suite.

	* src/abg-ir.cc (equals): In language supporting the ODR (just
	like in all other languages), consider that a decl-only class is
	different from its defined class counterpart.
	* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt:
	Adjust.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc                                                 | 4 +---
 tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt | 3 +++
 tests/data/test-diff-filter/test41-report-0.txt               | 4 ++--
 3 files changed, 6 insertions(+), 5 deletions(-)
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index bdb110cd..826dea4c 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -23920,9 +23920,7 @@  equals(const class_or_union& l, const class_or_union& r, change_kind* k)
 	    // change.
 	    return true;
 
-	  if ((l.get_environment().decl_only_class_equals_definition()
-	       || ((odr_is_relevant(l) && !def1)
-		   || (odr_is_relevant(r) && !def2)))
+	  if (l.get_environment().decl_only_class_equals_definition()
 	      && !is_anonymous_or_typedef_named(l)
 	      && !is_anonymous_or_typedef_named(r))
 	    {
diff --git a/tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt b/tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt
index 6076c92b..d64a87b1 100644
--- a/tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt
+++ b/tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt
@@ -15,6 +15,9 @@  Variable symbols changes summary: 0 Removed, 3 Added variable symbols not refere
   [C] 'method void S::bar()' has some indirect sub-type changes:
     method void S::bar() is now declared virtual
       note that this is an ABI incompatible change to the vtable of struct S
+    implicit parameter 0 of type 'S*' has sub-type changes:
+      in pointed to type 'struct S':
+        type struct S was a declaration-only type and is now a defined type
 
 3 Added variable symbols not referenced by debug info:
 
diff --git a/tests/data/test-diff-filter/test41-report-0.txt b/tests/data/test-diff-filter/test41-report-0.txt
index faffbbc1..d5c7f181 100644
--- a/tests/data/test-diff-filter/test41-report-0.txt
+++ b/tests/data/test-diff-filter/test41-report-0.txt
@@ -1,4 +1,4 @@ 
-Functions changes summary: 8 Removed, 4 Changed (6 filtered out), 16 Added functions
+Functions changes summary: 8 Removed, 4 Changed (7 filtered out), 16 Added functions
 Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
 Function symbols changes summary: 1 Removed, 0 Added function symbol not referenced by debug info
 Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info
@@ -52,7 +52,7 @@  Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referen
       in pointed to type 'const abigail::xml_writer::write_context':
         in unqualified underlying type 'class abigail::xml_writer::write_context' at abg-writer.cc:155:1:
           type size hasn't changed
-          5 data member changes (4 filtered):
+          5 data member changes (7 filtered):
             type of 'abigail::config m_config' changed:
               type size hasn't changed
               no data member changes (4 filtered);