DWARF: look up DW_AT_declaration non-recursively

Bug 26297: Possible misinterpretation of DW_AT_declaration via DW_AT_specification

The DWARF attribute DW_AT_declaration indicates that a DIE is
"declaration only". DWARF DIEs can be linked with DW_AT_specification
and DW_AT_abstract_origin attributes, effectively combining them. A
lone DW_AT_declaration in a chain of such DIEs should not render the
whole chain declaration only.

The function die_is_declaration_only currently traverses such links in
search of the attribute which precludes being able to check for the
attribute at each DIE in the chain and some DIEs are mistakenly
treated as declaration-only by the DWARF reader.

This commit changes die_is_declaration_only to examine the given DIE
only. It extends the die_flag_attribute function so that it can
perform a direct as well as a recursive attribute search. The function
die_die_attribute's 'look_thru_abstract_origin' argument is renamed to
'recursively' to match.

A following commit will change the DWARF reader to ensure it takes
note of the declaration-only status of all DIEs in a chain.

	* src/abg-dwarf-reader.cc (die_die_attribute): Rename
	'look_thru_abstract_origin' argument to 'recursively' and
	mention DW_AT_specification in its doc comment. Remove stale
	comment for non-existent argument. Simplify code with the help
	of the ternary operator.  (die_flag_attribute): Add
	recursively argument, defaulted to true. If this is false,
	look for attribute using dwarf_attr rather than
	dwarf_attr_integrate.  (die_is_declaration_only): Call
	die_flag_attribute specifying non-recursive attribute search.
	* tests/data/test-annotate/test15-pr18892.so.abi: Update
	tests. This is mostly the removal of unreachable parts of the type
	graph and type id renumbering.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt:
	Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.

Signed-off-by: Giuliano Procida <gprocida@google.com>
9 files changed