]> sourceware.org Git - libabigail.git/commit
abg-ir.cc: Improve types_have_similar_structure.
authorGiuliano Procida <gprocida@google.com>
Wed, 25 Mar 2020 14:18:59 +0000 (14:18 +0000)
committerDodji Seketeli <dodji@redhat.com>
Thu, 26 Mar 2020 10:45:03 +0000 (11:45 +0100)
commit9cf76b1175716b36502e759ca03661407e6131f5
tree08eaa8e84cf5a3dd608dea38495c304c4b1f7917
parent7b485c8271dd31a1fe15a93d03751d6e245aa3c3
abg-ir.cc: Improve types_have_similar_structure.

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.

Signed-off-by: Giuliano Procida <gprocida@google.com>
include/abg-fwd.h
src/abg-ir.cc
tests/data/Makefile.am
tests/data/test-abidiff-exit/test-leaf-peeling-report.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc [new file with mode: 0644]
tests/data/test-abidiff-exit/test-leaf-peeling-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc [new file with mode: 0644]
tests/data/test-abidiff-exit/test-leaf-peeling-v1.o [new file with mode: 0644]
tests/test-abidiff-exit.cc
This page took 0.044985 seconds and 5 git commands to generate.