From aecfa368a5af8a6b20b6ce16500e031dc9cee0ef Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Mon, 13 Jun 2022 15:45:01 +0200 Subject: [PATCH] ir, test-read-ctf: Remove uncertainty in sorting anonymous types For a reason, I am seeing changes in the test-read-ctf output. Those are related to sorting anonymous structs that have no (internal) name. The CTF reader emits such types. This patch thus considers the flat representation of an anonymous class/union when it doesn't have an internal name. The patch also updates the test-read-ctf output tests accordingly. * src/abg-ir.cc ({class_decl, union_decl}::get_pretty_representation): If the anonymous class has no internal name, use its flat representation as internal representation. * tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise. * tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise. * tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise. * tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise. * tests/data/test-read-ctf/test0.hash.abi: Likewise. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 4 ++-- tests/data/test-read-ctf/test-PR26568-1.o.abi | 16 ++++++------- tests/data/test-read-ctf/test-PR26568-2.o.abi | 16 ++++++------- .../test-read-ctf/test-anonymous-fields.o.abi | 24 +++++++++---------- tests/data/test-read-ctf/test0.hash.abi | 4 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 4e907620..717c195d 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -22119,7 +22119,7 @@ class_decl::get_pretty_representation(bool internal, // it has a name, which is the typedef name. if (get_is_anonymous()) { - if (internal) + if (internal && !get_name().empty()) return cl + get_type_name(this, qualified_name, /*internal=*/true); return get_class_or_union_flat_representation(this, "", /*one_line=*/true, @@ -23929,7 +23929,7 @@ union_decl::get_pretty_representation(bool internal, string repr; if (get_is_anonymous()) { - if (internal) + if (internal && !get_name().empty()) repr = string("union ") + get_type_name(this, qualified_name, /*internal=*/true); else diff --git a/tests/data/test-read-ctf/test-PR26568-1.o.abi b/tests/data/test-read-ctf/test-PR26568-1.o.abi index 832dc1bd..1b19fd9a 100644 --- a/tests/data/test-read-ctf/test-PR26568-1.o.abi +++ b/tests/data/test-read-ctf/test-PR26568-1.o.abi @@ -8,24 +8,24 @@ - + - + - + - + - - + + - + - + diff --git a/tests/data/test-read-ctf/test-PR26568-2.o.abi b/tests/data/test-read-ctf/test-PR26568-2.o.abi index 70e0772f..c6f3fbbb 100644 --- a/tests/data/test-read-ctf/test-PR26568-2.o.abi +++ b/tests/data/test-read-ctf/test-PR26568-2.o.abi @@ -3,24 +3,24 @@ - + - + - + - + - - + + - + - + diff --git a/tests/data/test-read-ctf/test-anonymous-fields.o.abi b/tests/data/test-read-ctf/test-anonymous-fields.o.abi index 2134a86d..783b6982 100644 --- a/tests/data/test-read-ctf/test-anonymous-fields.o.abi +++ b/tests/data/test-read-ctf/test-anonymous-fields.o.abi @@ -3,31 +3,31 @@ - + - + - + - + - + - + - - + + - + - + - - + + diff --git a/tests/data/test-read-ctf/test0.hash.abi b/tests/data/test-read-ctf/test0.hash.abi index eff32228..fa1daebc 100644 --- a/tests/data/test-read-ctf/test0.hash.abi +++ b/tests/data/test-read-ctf/test0.hash.abi @@ -24,7 +24,7 @@ - + @@ -46,7 +46,7 @@ - + -- 2.43.5