Correctly write the name of a const reference type

* src/abg-dwarf-reader.cc (maybe_strip_qualification): Define new
	function.
	(build_ir_node_from_die): Use the maybe_strip_qualification when
	building a qualified type.
	* src/abg-ir.cc (qualified_type_def::build_name): Fix the
	representation of the name of a reference that is const.
	* tests/data/test-read-dwarf/test1.abi: Adjust.
	* tests/data/test-diff-dwarf/test0-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test1-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test6-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test7-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test8-report.txt: Likewise.
	* tests/data/test-diff-filter/test0-report.txt: Likewise.
	* tests/data/test-diff-filter/test01-report.txt: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test3-report.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Likewise.
	* tests/data/test-diff-filter/test10-report.txt: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-0-report.txt: Likewise.
	* tests/data/test-diff-filter/test14-1-report.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-07-18 18:55:23 +02:00
parent fe6b9fb61b
commit 3b6d0ec0a9
17 changed files with 161 additions and 153 deletions

View File

@ -4526,6 +4526,30 @@ build_qualified_type(read_context& ctxt,
return result;
}
/// Strip qualification from a qualified type, when it makes sense.
///
/// DWARF constructs "const reference". This is redundant because a
/// reference is always const. The issue is these redundant type then
/// leaks into the IR and makes for bad diagnostics.
///
/// This function thus strips qualified type in that case. It might
/// contain code to strip other cases like this in the future.
///
/// @param t the type to strip qualification from.
///
/// @return the stripped type or just return @p t.
static decl_base_sptr
maybe_strip_qualification(const qualified_type_def_sptr t)
{
if (!t)
return t;
if (dynamic_pointer_cast<reference_type_def>(t->get_underlying_type()))
return get_type_declaration(t->get_underlying_type());
return t;
}
/// Build a pointer type from a DW_TAG_pointer_type DIE.
///
/// @param ctxt the read context to consider.
@ -5074,7 +5098,7 @@ build_ir_node_from_die(read_context& ctxt,
build_qualified_type(ctxt, die, called_from_public_decl,
where_offset);
if (q)
result = add_decl_to_scope(q, scope);
result = add_decl_to_scope(maybe_strip_qualification(q), scope);
}
break;

View File

@ -3269,7 +3269,8 @@ qualified_type_def::build_name(bool fully_qualified) const
name = td->get_qualified_name();
else
name = td->get_name();
if (dynamic_pointer_cast<pointer_type_def>(underlying_type_))
if (dynamic_pointer_cast<pointer_type_def>(underlying_type_)
|| dynamic_pointer_cast<reference_type_def>(underlying_type_))
{
name += " ";
name += quals;

View File

@ -3,20 +3,19 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
2 functions with some indirect sub-type change:
[C]'function void foo(const S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'const S0&' has sub-type changes:
in unqualified underlying type 'S0&':
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int B0S0::m2', at offset 64 (in bits)
[C]'function void foo(S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'S0&' has sub-type changes:
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int B0S0::m2', at offset 64 (in bits)
1 data member change:
'int S0::m0' offset changed from 64 to 96, access changed from 'private' to 'protected'
1 data member change:
'int S0::m0' offset changed from 64 to 96, access changed from 'private' to 'protected'
[C]'method void S0::member0()' has some indirect sub-type changes:
'method void S0::member0()' access changed from 'private' to 'public'

View File

@ -3,15 +3,14 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member change:
'int S::m1' offset changed from 32 to 64
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member change:
'int S::m1' offset changed from 32 to 64
1 data member insertion:
'unsigned int S::m01', at offset 32 (in bits)
1 data member insertion:
'unsigned int S::m01', at offset 32 (in bits)

View File

@ -3,11 +3,10 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S0&)' has some indirect sub-type changes:
parameter 0 of type 'const S0&' has sub-type changes:
in unqualified underlying type 'S0&':
in referenced type 'struct S0':
1 data member change:
'char S0::m2' name changed to 'S0::m12'
[C]'function void foo(S0&)' has some indirect sub-type changes:
parameter 0 of type 'S0&' has sub-type changes:
in referenced type 'struct S0':
1 data member change:
'char S0::m2' name changed to 'S0::m12'

View File

@ -3,12 +3,11 @@ Variables changes summary: 0 Removed, 0 Changed, 1 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
1 data member insertion:
'static char S::m0'
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
1 data member insertion:
'static char S::m0'
1 Added variable:
'static char S::m0'

View File

@ -3,25 +3,24 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
1 base class change:
'struct B0' changed:
1 data member change:
'char B0::m0' access changed from 'public' to 'private'
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 64 to 96 bits
1 base class change:
'struct B0' changed:
1 data member change:
'char B0::m0' access changed from 'public' to 'private'
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64, access changed from 'public' to 'private'
and its type 'int' changed:
name changed from 'int' to 'char'
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64, access changed from 'public' to 'private'
and its type 'int' changed:
name changed from 'int' to 'char'
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
1 Added function:

View File

@ -3,23 +3,22 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'const S0&' has sub-type changes:
in unqualified underlying type 'S0&':
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member change:
'char B0S0::m1' offset changed from 32 to 64
[C]'function void foo(S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'S0&' has sub-type changes:
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member change:
'char B0S0::m1' offset changed from 32 to 64
1 data member insertion:
'unsigned int B0S0::m2', at offset 32 (in bits)
1 data member insertion:
'unsigned int B0S0::m2', at offset 32 (in bits)
1 data member change:
'int S0::m0' offset changed from 64 to 96
1 data member change:
'int S0::m0' offset changed from 64 to 96
1 Added function:

View File

@ -5,23 +5,22 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
[C]'method void S1::member0()' has some indirect sub-type changes:
'method void S1::member0()' access changed from 'private' to 'public'
[C]'function void foo(const S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'const S0&' has sub-type changes:
in unqualified underlying type 'S0&':
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member change:
'char B0S0::m1' offset changed from 32 to 64
[C]'function void foo(S0&, S1*)' has some indirect sub-type changes:
parameter 0 of type 'S0&' has sub-type changes:
in referenced type 'class S0':
size changed from 96 to 128 bits
1 base class change:
'class B0S0' changed:
size changed from 64 to 96 bits
1 data member change:
'char B0S0::m1' offset changed from 32 to 64
1 data member insertion:
'unsigned int B0S0::m2', at offset 32 (in bits)
1 data member insertion:
'unsigned int B0S0::m2', at offset 32 (in bits)
1 data member change:
'int S0::m0' offset changed from 64 to 96, access changed from 'private' to 'protected'
1 data member change:
'int S0::m0' offset changed from 64 to 96, access changed from 'private' to 'protected'
[C]'method void S0::member0()' has some indirect sub-type changes:
'method void S0::member0()' access changed from 'private' to 'public'

View File

@ -8,13 +8,12 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 32 to 8 bits
1 data member deletion:
'unsigned int S::m', at offset 0 (in bits)
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 32 to 8 bits
1 data member deletion:
'unsigned int S::m', at offset 0 (in bits)

View File

@ -3,19 +3,18 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
no base class change (1 filtered);
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64
and its type 'int' changed:
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 64 to 96 bits
no base class change (1 filtered);
1 base class insertion:
class B1
1 data member change:
'int S::m0' offset changed from 32 to 64
and its type 'int' changed:
size changed from 32 to 8 bits
alignment changed from 32 to 8 bits
1 Added function:

View File

@ -3,12 +3,11 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void bar(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int S::m2', at offset 64 (in bits)
[C]'function void bar(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int S::m2', at offset 64 (in bits)

View File

@ -3,16 +3,14 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
2 functions with some indirect sub-type change:
[C]'function void bar(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int S::m2', at offset 64 (in bits)
[C]'function void bar(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 64 to 96 bits
1 data member insertion:
'unsigned int S::m2', at offset 64 (in bits)
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
referenced type 'struct S' changed, as reported earlier
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
referenced type 'struct S' changed, as reported earlier

View File

@ -3,25 +3,23 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
2 functions with some indirect sub-type change:
[C]'function void foo(const C0&)' has some indirect sub-type changes:
parameter 0 of type 'const C0&' has sub-type changes:
in unqualified underlying type 'C0&':
in referenced type 'struct C0':
size changed from 16 to 24 bits
2 data member changes:
'E0 C0::m0' offset changed from 0 to 8
'E1 C0::m1' offset changed from 8 to 16
[C]'function void foo(C0&)' has some indirect sub-type changes:
parameter 0 of type 'C0&' has sub-type changes:
in referenced type 'struct C0':
size changed from 16 to 24 bits
2 data member changes:
'E0 C0::m0' offset changed from 0 to 8
'E1 C0::m1' offset changed from 8 to 16
1 data member insertion:
'char C0::m2', at offset 0 (in bits)
1 data member insertion:
'char C0::m2', at offset 0 (in bits)
[C]'function void bar(const C1&)' has some indirect sub-type changes:
parameter 0 of type 'const C1&' has sub-type changes:
in unqualified underlying type 'C1&':
in referenced type 'class C1':
size changed from 8 to 64 bits
1 data member insertion:
'int C1::m1', at offset 32 (in bits)
[C]'function void bar(C1&)' has some indirect sub-type changes:
parameter 0 of type 'C1&' has sub-type changes:
in referenced type 'class C1':
size changed from 8 to 64 bits
1 data member insertion:
'int C1::m1', at offset 32 (in bits)
1 Added function:

View File

@ -3,15 +3,14 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void bar(int, const S&)' has some indirect sub-type changes:
parameter 1 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 8 to 64 bits
1 data member change:
'char S::m1' offset changed from 0 to 32
[C]'function void bar(int, S&)' has some indirect sub-type changes:
parameter 1 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 8 to 64 bits
1 data member change:
'char S::m1' offset changed from 0 to 32
1 data member insertion:
'int S::m0', at offset 0 (in bits)
1 data member insertion:
'int S::m0', at offset 0 (in bits)

View File

@ -3,13 +3,12 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
size changed from 8 to 32 bits
1 data member insertion:
'int S::m0', at offset 0 (in bits)
[C]'function void foo(S&)' has some indirect sub-type changes:
parameter 0 of type 'S&' has sub-type changes:
in referenced type 'struct S':
size changed from 8 to 32 bits
1 data member insertion:
'int S::m0', at offset 0 (in bits)
2 Added functions:

View File

@ -100,9 +100,8 @@
<type-decl name='unsigned char' size-in-bits='8' alignment-in-bits='8' id='type-id-10'/>
<pointer-type-def type-id='type-id-6' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/>
<reference-type-def kind='lvalue' type-id='type-id-6' size-in-bits='64' alignment-in-bits='64' id='type-id-12'/>
<qualified-type-def type-id='type-id-12' const='yes' id='type-id-13'/>
<function-decl name='foo' mangled-name='_Z3fooR2s0' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64' elf-symbol-id='_Z3fooR2s0'>
<parameter type-id='type-id-13' name='s' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1'/>
<parameter type-id='type-id-12' name='s' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='42' column='1'/>
</function-decl>
<function-decl name='main' mangled-name='main' filepath='/home/dodji/git/libabigail/dwarf/tests/data/test-read-dwarf/test1.cc' line='48' column='1' visibility='default' binding='global' size-in-bits='64' alignment-in-bits='64' elf-symbol-id='main'>
<return type-id='type-id-8'/>