mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-02 14:51:49 +00:00
f0bf868022
The XML writer has a few different styles of new line handling in different places. Some functions are responsible for line termination, others are not and there is bespoke logic and state variables in a few places. Extra or missing newlines should have no impact on the semantics of any given ABI file but they do affect textual diffs and diff statistics. By insisting the XML emitted should have exactly one XML tag (or comment) per line, we can simplify the code and make it more composable. This commit does this, yielding a modest reduction in code size and eliminating all blank lines in XML output (7127 blank lines in current tests). The commit also fixes some code whitespace. * src/abg-writer.cc (annotate): In the function_decl::parameter_sptr overload, fix code whitespace. (write_decl_in_scope): Remove wrote_context state variable and associated logic; emit new line unconditionally after end of XML tags and nowhere else. (write_canonical_types_of_scope): Emit new line after end of XML comment and nowhere else. (write_translation_unit): Emit new line after end of XML tags and nowhere else. (write_type_decl): Likewise. (write_namespace_decl): Likewise. (write_qualified_type_def): Emit new line after end of XML tag. (write_pointer_type_def): Likewise. (write_reference_type_def): Likewise. (write_array_type_def): Emit new line after end of XML tags and nowhere else. (write_enum_type_decl): Emit new line after end of XML tag. (write_elf_symbol): Likewise. (write_elf_symbols_table): Emit no new lines. (write_elf_needed): Emit new line unconditionally after end of XML tags. (write_typedef_decl): Emit new line after end of XML tag. (write_var_decl): Emit new line after end of XML tag. (write_function_decl): Likewise. (write_function_type): Fold two output statements into one; emit new line after end of XML tag. (write_class_decl_opening_tag): Emit new line unconditionally after end of XML tags and simplify empty element tag logic. (write_union_decl_opening_tag): Likewise. (write_class_decl): Emit new line after end of XML tag and nowhere else. (write_union_decl): Likewise. (write_member_type_opening_tag): Emit new line after end of XML tag. (write_member_type): Emit new lines only after XML tags. (write_type_tparameter): Emit new line after XML tag. (write_non_type_tparameter): Likewise. (write_template_tparameter): Emit new line after XML tag and nowhere else. (write_type_composition): Likewise. (write_template_parameters): Emit no new lines. (write_function_tdecl): Emit new line after XML tag and nowhere else. (write_class_tdecl): Likewise. (write_corpus): Emit new lines only after XML tags. (dump): In the decl_base_sptr overload, don't emit final new line as this is now done by write_decl. In the var_decl_sptr overload, don't emit final new line (mistakenly done to cerr instead of o) as this is now done by write_var_decl. In the translation_unit overload, don't emit final new line as this doubles that emitted by write_translation_unit. * tests/data/test-annotate/libtest23.so.abi: Delete all blank lines. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Ditto. * tests/data/test-annotate/test1.abi: Ditto. * tests/data/test-annotate/test13-pr18894.so.abi: Ditto. * tests/data/test-annotate/test14-pr18893.so.abi: Ditto. * tests/data/test-annotate/test15-pr18892.so.abi: Ditto. * tests/data/test-annotate/test17-pr19027.so.abi: Ditto. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-annotate/test21-pr19092.so.abi: Ditto. * tests/data/test-annotate/test7.so.abi: Ditto. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Ditto. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Ditto. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Ditto. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Ditto. * tests/data/test-read-dwarf/libtest23.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Ditto. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Ditto. * tests/data/test-read-dwarf/test1.abi: Ditto. * tests/data/test-read-dwarf/test1.hash.abi: Ditto. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Ditto. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Ditto. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Ditto. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Ditto. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Ditto. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Ditto. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Ditto. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Ditto. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Ditto. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Ditto. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Ditto. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Ditto. * tests/data/test-read-dwarf/test7.so.abi: Ditto. * tests/data/test-read-dwarf/test7.so.hash.abi: Ditto. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Ditto. * tests/data/test-read-write/test10.xml: Ditto. * tests/data/test-read-write/test15.xml: Ditto. * tests/data/test-read-write/test21.xml: Ditto. * tests/data/test-read-write/test25.xml: Ditto. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Ditto. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Ditto. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
51 lines
2.9 KiB
XML
51 lines
2.9 KiB
XML
<abi-instr version='1.0' address-size='64' path='data/text-read-write/test25.xml'>
|
|
<type-decl name='char' size-in-bits='8' alignment-in-bits='8' id='type-id-1'/>
|
|
<array-type-def dimensions='1' type-id='type-id-2' size-in-bits='448' alignment-in-bits='64' id='type-id-3'>
|
|
<subrange length='7' id='type-id-4'/>
|
|
</array-type-def>
|
|
<array-type-def dimensions='1' type-id='type-id-1' size-in-bits='infinite' alignment-in-bits='8' id='type-id-5'>
|
|
<subrange length='infinite' id='type-id-6'/>
|
|
</array-type-def>
|
|
<class-decl name='S' size-in-bits='2240' is-struct='yes' visibility='default' id='type-id-7'>
|
|
<data-member access='public' layout-offset-in-bits='0'>
|
|
<var-decl name='a' type-id='type-id-8' visibility='default'/>
|
|
</data-member>
|
|
<data-member access='public' layout-offset-in-bits='192'>
|
|
<var-decl name='b' type-id='type-id-3' visibility='default'/>
|
|
</data-member>
|
|
<data-member access='public' layout-offset-in-bits='640'>
|
|
<var-decl name='c' type-id='type-id-9' visibility='default'/>
|
|
</data-member>
|
|
<data-member access='public' layout-offset-in-bits='1600'>
|
|
<var-decl name='d' type-id='type-id-10' visibility='default'/>
|
|
</data-member>
|
|
<data-member access='public' layout-offset-in-bits='2240'>
|
|
<var-decl name='f' type-id='type-id-5' visibility='default'/>
|
|
</data-member>
|
|
</class-decl>
|
|
<type-decl name='double' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/>
|
|
<array-type-def dimensions='2' type-id='type-id-11' size-in-bits='960' alignment-in-bits='64' id='type-id-9'>
|
|
<subrange length='5' id='type-id-12'/>
|
|
<subrange length='3' id='type-id-13'/>
|
|
</array-type-def>
|
|
<type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-14'/>
|
|
<array-type-def dimensions='1' type-id='type-id-15' size-in-bits='256' alignment-in-bits='64' id='type-id-16'>
|
|
<subrange length='4' id='type-id-17'/>
|
|
</array-type-def>
|
|
<array-type-def dimensions='1' type-id='type-id-18' size-in-bits='640' alignment-in-bits='64' id='type-id-10'>
|
|
<subrange length='10' id='type-id-19'/>
|
|
</array-type-def>
|
|
<array-type-def dimensions='1' type-id='type-id-14' size-in-bits='160' alignment-in-bits='32' id='type-id-8'>
|
|
<subrange length='5' id='type-id-12'/>
|
|
</array-type-def>
|
|
<reference-type-def kind='lvalue' type-id='type-id-7' size-in-bits='64' alignment-in-bits='64' id='type-id-20'/>
|
|
<qualified-type-def type-id='type-id-20' const='yes' id='type-id-21'/>
|
|
<pointer-type-def type-id='type-id-1' size-in-bits='64' alignment-in-bits='64' id='type-id-2'/>
|
|
<pointer-type-def type-id='type-id-14' size-in-bits='64' alignment-in-bits='64' id='type-id-15'/>
|
|
<pointer-type-def type-id='type-id-16' size-in-bits='64' alignment-in-bits='64' id='type-id-18'/>
|
|
<function-decl name='foo' size-in-bits='64'>
|
|
<parameter type-id='type-id-21'/>
|
|
<return type-id='type-id-14'/>
|
|
</function-decl>
|
|
</abi-instr>
|