From c496019a387b6e9066048151cabb2eb2dfc24ce3 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 22 Jul 2022 09:56:17 +0200 Subject: [PATCH] ir: Disambiguate sorting of array element types When using non-internal pretty representation of array types (e.g, for sorting of types in a given scope for the purpose of serialization), some array element types might have the same name, even though they don't have the same qualified name. In those cases, the serialized abixml output is not stable. This patches uses qualified names for array element names for type sorting purposes. However, this patch uncovers a problem that shows up in the tests outputs for test-abidiff-exit and test-diff-filter, where emitting qualified names of qualified types shows that there can be redundant qualifiers in the serialized output. This issue will be fixed separately in a later commit. For now, the output of these tests is temporarily updated to have the tests pass. * src/abg-ir.cc (get_type_representation): In the overload for array_type_def, use qualified names for element types. * tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt: Adjust. * tests/data/test-annotate/test15-pr18892.so.abi: Adjust. * tests/data/test-annotate/test17-pr19027.so.abi: Adjust. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust. * tests/data/test-diff-filter/test-PR26739-2-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 2 +- .../qualifier-typedef-array-report-1.txt | 20 ++-- .../data/test-annotate/test15-pr18892.so.abi | 32 +++--- .../data/test-annotate/test17-pr19027.so.abi | 104 +++++++++--------- ...19-pr19023-libtcmalloc_and_profiler.so.abi | 14 +-- .../test-PR26739-2-report-0.txt | 2 +- 6 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 07736db9..5c1ac35b 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -17066,7 +17066,7 @@ get_type_representation(const array_type_def& a, bool internal) + a.get_subrange_representation(); else r = (e_type - ? get_type_name(e_type, /*qualified=*/false, /*internal=*/false) + ? get_type_name(e_type, /*qualified=*/true, /*internal=*/false) : string("void")) + a.get_subrange_representation(); } diff --git a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt index e9bf3d46..13949efc 100644 --- a/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt +++ b/tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt @@ -50,36 +50,36 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable entity changed from 'typedef C' to compatible type 'const volatile void* const[7]' array element type 'void* const' changed: 'void* const' changed to 'const volatile void* const' - type name changed from 'void* const[7]' to 'volatile void* const[7]' + type name changed from 'void* const[7]' to 'const volatile void* const[7]' type size hasn't changed type of 'C r_c' changed: - entity changed from 'typedef C' to compatible type 'restrict void* const[7]' + entity changed from 'typedef C' to compatible type 'restrict const void* const[7]' array element type 'void* const' changed: 'void* const' changed to 'restrict const void* const' - type name changed from 'void* const[7]' to 'restrict void* const[7]' + type name changed from 'void* const[7]' to 'restrict const void* const[7]' type size hasn't changed type of 'D v_d' changed: entity changed from 'typedef D' to compatible type 'const volatile void* const[7]' array element type 'void* const' changed: 'void* const' changed to 'const volatile void* const' - type name changed from 'void* const[7]' to 'volatile void* const[7]' + type name changed from 'void* const[7]' to 'const volatile void* const[7]' type size hasn't changed type of 'D r_d' changed: - entity changed from 'typedef D' to compatible type 'restrict void* const[7]' + entity changed from 'typedef D' to compatible type 'restrict const void* const[7]' array element type 'void* const' changed: 'void* const' changed to 'restrict const void* const' - type name changed from 'void* const[7]' to 'restrict void* const[7]' + type name changed from 'void* const[7]' to 'restrict const void* const[7]' type size hasn't changed type of 'E r_e' changed: - entity changed from 'typedef E' to compatible type 'restrict const volatile void* const[7]' + entity changed from 'typedef E' to compatible type 'restrict const volatile volatile void* const[7]' array element type 'const volatile void* const' changed: 'const volatile void* const' changed to 'restrict const volatile volatile void* const' - type name changed from 'volatile void* const[7]' to 'restrict const volatile void* const[7]' + type name changed from 'const volatile void* const[7]' to 'restrict const volatile volatile void* const[7]' type size hasn't changed type of 'F r_f' changed: - entity changed from 'typedef F' to compatible type 'restrict const volatile void* const[7]' + entity changed from 'typedef F' to compatible type 'restrict const volatile volatile void* const[7]' array element type 'const volatile void* const' changed: 'const volatile void* const' changed to 'restrict const volatile volatile void* const' - type name changed from 'volatile void* const[7]' to 'restrict const volatile void* const[7]' + type name changed from 'const volatile void* const[7]' to 'restrict const volatile volatile void* const[7]' type size hasn't changed diff --git a/tests/data/test-annotate/test15-pr18892.so.abi b/tests/data/test-annotate/test15-pr18892.so.abi index bbabb567..dbcdb390 100644 --- a/tests/data/test-annotate/test15-pr18892.so.abi +++ b/tests/data/test-annotate/test15-pr18892.so.abi @@ -4588,7 +4588,7 @@ - + @@ -10820,17 +10820,17 @@ - + - + - + @@ -10907,7 +10907,7 @@ - + @@ -27650,42 +27650,42 @@ - + - + - + - + - + - + - + - + @@ -35556,12 +35556,12 @@ - + - + @@ -40807,7 +40807,7 @@ - + diff --git a/tests/data/test-annotate/test17-pr19027.so.abi b/tests/data/test-annotate/test17-pr19027.so.abi index a303267b..a9f7b565 100644 --- a/tests/data/test-annotate/test17-pr19027.so.abi +++ b/tests/data/test-annotate/test17-pr19027.so.abi @@ -528,7 +528,7 @@ - + @@ -3931,12 +3931,12 @@ - + - + @@ -10736,52 +10736,52 @@ - + - + - + - + - + - + - + - + - + - + @@ -12894,162 +12894,162 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -13059,17 +13059,17 @@ - + - + - + @@ -29612,7 +29612,7 @@ - + @@ -30055,12 +30055,12 @@ - + - + @@ -31395,7 +31395,7 @@ - + diff --git a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi index 44e1db28..8cb8aeba 100644 --- a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi +++ b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi @@ -2841,7 +2841,7 @@ - + @@ -22310,12 +22310,12 @@ - + - + @@ -25418,22 +25418,22 @@ - + - + - + - + diff --git a/tests/data/test-diff-filter/test-PR26739-2-report-0.txt b/tests/data/test-diff-filter/test-PR26739-2-report-0.txt index a98473b4..999d9614 100644 --- a/tests/data/test-diff-filter/test-PR26739-2-report-0.txt +++ b/tests/data/test-diff-filter/test-PR26739-2-report-0.txt @@ -12,6 +12,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable entity changed from 'const volatile const int[5]' to compatible type 'typedef array_type1' at test-PR26739-2-v1.c:3:1 array element type 'const volatile const int' changed: 'const volatile const int' changed to 'const int' - type name changed from 'volatile const int[5]' to 'const int[5]' + type name changed from 'const volatile const int[5]' to 'const int[5]' type size hasn't changed -- 2.43.5