This function is used to determine whether or not type differences are
"local" and is primarily used in --leaf-changes-only mode. The logic
has some issues which are addressed by this patch:
- Any number of points-to (*) and refers-to (& and &&) components
are peeled off the types being compared, rather than checking
these match in number and kind.
- This peeling is done with peel_typedef_pointer_or_reference_type
which also peels any number of CV qualifiers (OK) and
array-of ([N]) type components (not OK).
- The function sets a state variable (was_indirect_type) to modify
the behaviour of downstream comparisons, but this cannot be
passed through recursive calls.
The effect of the indirect_type flag is to switch to comparisons by
name: identically named structs don't get introspected. Arguably, a
more useful behaviour for --leaf-changes-only mode would be to treat
any change to a named type as non-local, except in the context of the
definition of that type itself. This would be a more significant
change in behaviour.
* include/abg-fwd.h (types_have_similar_structure): In both
overloads, add an indirect_type argument, defaulting to
false.
* src/abg-ir.cc (reference_type_def constructor): Tabify.
(types_have_similar_structure): In both overloads, add an
indirect_type argument and update documentation text. In the
type_base_sptr overload, pass indirect_type in the tail
call. In the type_base* overload, replace was_indirect_type
with indirect_type; peel CV qualifiers and typedefs without
testing as the peel function does this; replace the
indiscriminate peeling of qualifier/pointer/reference/array
type components with code that checks the same
pointer/reference/array type component is used on each side
and makes recursive calls with indirect_type set to true; pass
the indirect_type argument recursively when comparing other
subtypes; move the typeid check earlier, document its purpose
and remove unneccessary checks after later dynamic casts;
remove an always-true conditional; add a TODO for comparing
array types more accurately.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: New
test case.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Ditto.
* tests/test-abidiff-exit.cc: Run new test case.