* include/abg-comparison.h
(diff_category::STATIC_DATA_MEMBER_CHANGE_CATEGORY): New category.
(diff_category::EVERYTHING_CATEGORY): Update
* src/abg-comp-filter.cc (static_data_member_type_size_changed)
(static_data_member_added_or_removed): Define new static
functions.
(harmless_filter::visit): Categorize changes to static data
members as STATIC_DATA_MEMBER_CHANGE_CATEGORY.
* tools/bidiff.cc (set_diff_context_from_opts):
STATIC_DATA_MEMBER_CHANGE_CATEGORY is falls into the harmless
group.
* tests/data/test-diff-filter/test12-report.txt: New test input.
* tests/data/test-diff-filter/test12-v0.cc: Likewise.
* tests/data/test-diff-filter/test12-v0.o: Likewise.
* tests/data/test-diff-filter/test12-v1.cc: Likewise.
* tests/data/test-diff-filter/test12-v1.o: Likewise.
* tools/bidiff.cc: Run this test with the additional input data
above.
* tests/Makefile.am: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Let's
consider that a data member being not laid out (i.e, not having a
data_member_location) is is a static data member. Otherwise, we
were not detecting static data members at all. Well we were only
inferring their presence from seeing the static variable
definition later on. That means we were missing most of the
static variables. Woops.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that we
are really seeing static data members, let's be prepare to the
fact that we can the same static data member being declared
several times in a corpus.
* tests/data/test-diff-dwarf/test7-report.txt: New test input file.
* tests/data/test-diff-dwarf/test7-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test7-v0.o: Likewise.
* tests/data/test-diff-dwarf/test7-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test7-v1.o: Likewise.
* tests/test-diff-dwarf.cc: Update this to consume the new test
input files.
* tests/Makefile.am: Update this to add the missing test files to
the source distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Use the virtual
member functions here, not the member functions in general.
(compute_diff): Consider virtual member functions only, not
non-virtual ones.
* src/abg-ir.cc (class_decl::operator==): Do not compare
non-virtual member functions. Only compare virtual member
functions.
* tests/data/test-bidiff/test-struct1-report.txt: New test input.
* tests/data/test-diff-dwarf/test0-report.txt: New test input.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test01-report.txt: New test input.
* tests/data/test-diff-filter/test10-report.txt: New test input.
* tests/data/test-diff-filter/test11-report.txt: New test input.
* tests/data/test-diff-filter/test2-report.txt: New test input.
* tests/data/test-diff-filter/test9-report.txt: New test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (member_function_is_virtual): Declare new
function.
* include/abg-comparison.h
(diff_category::{NON_VIRT_MEM_FUN_CHANGE_CATEGORY,
VIRTUAL_MEMBER_CHANGE_CATEGORY}): New enumerators.
(diff_category::EVERYTHING_CATEGORY): Adjust.
(class_diff::{changed, deleted, inserted}_member_fns): Declare new
member functions.
* src/abg-comp-filter.cc (data_member_added_or_removed): Add
missing comments.
(has_non_virtual_mem_fn_change): New static predicate function.
(harmless_filter::visit): Categorize non-virtual member function
changes in a diff into NON_VIRT_MEM_FUN_CHANGE_CATEGORY.
* src/abg-comparison.cc
(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY): New macro.
(report_mem_header): Count filtered functions for added/deleted
functions as well.
(class_diff::priv::count_filtered_changed_mem_fns): Renamed
priv::count_filtered_member_functions into this. Filter out
changes to non-virtual member functions here.
(class_diff::priv::count_filtered_{inserted, deleted}_mem_fns):
New member functions.
(class_diff::{deleted, inserted, changed}_member_fns): Define new
member functions.
(class_diff::report): Adjust count for filtered inserted/deleted
member functions. Do not report NON_VIRT_MEM_FUN_CHANGE_CATEGORY
if it's disallowed.
(class_diff::traverse): Propagate only
VIRTUAL_MEMBER_CHANGE_CATEGORY from member functions to their
enclosing class.
* src/abg-ir.cc (member_function_is_virtual): Define new
functions.
* tools/bidiff.cc (set_diff_context_from_opts): Adjust to add
NON_VIRT_MEM_FUN_CHANGE_CATEGORY into the harmless group and
VIRTUAL_MEMBER_CHANGE_CATEGORY into the harmful one.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test10-report.txt: Likewise.
* tests/data/test-diff-filter/test10-v0.cc: Likewise.
* tests/data/test-diff-filter/test10-v0.o: Likewise.
* tests/data/test-diff-filter/test10-v1.cc: Likewise.
* tests/data/test-diff-filter/test10-v1.o: Likewise.
* tests/data/test-diff-filter/test11-report.txt: Likewise.
* tests/data/test-diff-filter/test11-v0.cc: Likewise.
* tests/data/test-diff-filter/test11-v0.o: Likewise.
* tests/data/test-diff-filter/test11-v1.cc: Likewise.
* tests/data/test-diff-filter/test11-v1.o: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Likewise.
* tests/data/test-diff-filter/test9-report.txt: Likewise.
* tests/data/test-diff-filter/test9-v0.cc: Likewise.
* tests/data/test-diff-filter/test9-v0.o: Likewise.
* tests/data/test-diff-filter/test9-v1.cc: Likewise.
* tests/data/test-diff-filter/test9-v1.o: Likewise.
* tests/test-diff-filter.cc: Consume the test input above to run
more tests.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (get_data_member_offset): Declare new overload for
decl_base_sptr.
* include/abg-comparison.h (unsigned_decl_base_sptr_map)
(unsigned_changed_type_or_decl_map): New typedefs.
* src/abg-ir.cc (get_data_member_offset): Define new overload for decl_base_sptr.
* src/abg-comparison.cc (diff_kind::subtype_change_kind): New
enumerator for a change about a type or sub-type of a member of a
structure/enum.
(report_mem_header): Handle the new enumerator above.
(class_diff::priv::{deleted_dm_by_offset_, inserted_dm_by_offset_,
changed_dm_}): New data members.
(class_diff::priv::subtype_changed_dm_): Renamed
class_diff::priv::changed_data_members_ into this.
(class_diff::priv::subtype_changed_dm): Renamed
class_diff::priv::data_member_has_changed into this. Adjust.
(class_diff::count_filtered_subtype_changed_dm): Renamed
count_filtered_data_members into this. Adjust.
(class_diff::priv::count_filtered_changed_dm): New member
function.
(class_diff::lookup_tables_empty): Adjust.
(class_diff::ensure_lookup_tables_populated): Adjust. Detect when
a data member is deleted and added back to offset N, and be
prepared to present that as a change of data member at offset N.
(class_diff::report): Adjust. Report data members of a given
offset that have changed.
* tests/data/test-diff-dwarf/test6-report.txt: New reference
report for new test input.
* tests/data/test-diff-dwarf/test6-v0.cc: Source code for new test
input binary.
* tests/data/test-diff-dwarf/test6-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test6-v1.cc: Source code for new test
input binary.
* tests/data/test-diff-dwarf/test6-v1.o: New test input binary.
* tests/test-diff-dwarf.cc: Adjust to include the new test inputs above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (enum
diff_category::DECL_NAME_CHANGE_CATEGORY): New enumerator.
* src/abg-comparison.cc (report_name_size_and_alignment_changes)
({enum, typedef}_diff::report): Adjust to avoid emitting name
change report if the DECL_NAME_CHANGE_CATEGORY category of change
is currently disallowed.
* abg-comp-filter.cc (decl_name_changed): New static function.
(harmless_filter::visit): Detect that the decl name changed and
put the current diff node (and its parents) into the
DECL_NAME_CHANGE_CATEGORY category.
* tools/bidiff.cc (set_diff_context_from_opts): Set the new
DECL_NAME_CHANGE_CATEGORY category into the harmless_changes group
of categories.
* tests/data/test-diff-filter/test6-report.txt: New test input file.
* tests/data/test-diff-filter/test6-v0.cc: Likewise.
* tests/data/test-diff-filter/test6-v0.o: Likewise.
* tests/data/test-diff-filter/test6-v1.cc: Likewise.
* tests/data/test-diff-filter/test6-v1.o: Likewise.
* tests/data/test-diff-filter/test7-report.txt: Likewise.
* tests/data/test-diff-filter/test7-v0.cc: Likewise.
* tests/data/test-diff-filter/test7-v0.o: Likewise.
* tests/data/test-diff-filter/test7-v1.cc: Likewise.
* tests/data/test-diff-filter/test7-v1.o: Likewise.
* tests/test-diff-filter.cc: Take the new inputs above to run new tests.
* tests/Makefile.am: Add the new files above to the distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (compare_function_types): Compare return types,
unless this is a method and the return type is the same type as
the containing class type.
* tests/data/test-diff-dwarf/test5-report.txt: Reference report
for the comparison of the two input binaries below.
* tests/data/test-diff-dwarf/test5-v0.cc: Source code for the
input binary below.
* tests/data/test-diff-dwarf/test5-v0.o: Test input binary.
* tests/data/test-diff-dwarf/test5-v1.cc: Source code for the
input binary below.
* tests/data/test-diff-dwarf/test5-v1.o: Test input binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-diff-dwarf/test4-report.txt: Adjust.
* tests/test-diff-dwarf.cc: Run tests for
data/test-diff-dwarf/test3-report.txt" and
data/test-diff-dwarf/test4-report.txt.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (report_size_and_alignment_changes): Split
this static function out of ...
(report_name_size_and_alignment_changes): ... this one.
(distinct_diff::report): If the typedef-stripped variants of the
diff subjects are of the same kind, display their diff.
Otherwise, tell explicitly is the distinct type diff involves a
type size change.
(distinct_diff::traverse): If the typedef-stripped variants of the
diff subjects are of the same kind, traverse that underlying diff
sub-tree and propagate the categorizing possibly resulting from
that traversal.
* tests/data/test-diff-dwarf/test4-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test4-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-dwarf/test4-v1.o: New test input binary.
* tests/data/test-diff-dwarf/test4-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-dwarf/test4-report.txt: Reference report
for the difference between the two binaries above.
* tests/data/test-diff-filter/test5-v0.o: New test input binary.
* tests/data/test-diff-filter/test5-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test5-v1.o: New test input binary.
* tests/data/test-diff-filter/test5-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test5-report.txt: Reference report
for the difference between the two binaries above.
* tests/test-diff-filter.cc: Adjust to produce a filtered diff for
the two input binaries above.
* tests/Makefile.am: Adjust to add missing test files to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
A given diff node for a type can be hung off of several contexts: a
function parameter type node, another type diff node, etc. For that
reason, a type diff node should not have a parent node. Thus, it's
should be the job of the context containing the type diff node to
propagate its categories to the context nodes. This actually fixes a bug
about category propagation.
* abg/comparison.cc (var_diff::var_diff): Do not set parent node
for the type diff of the var_diff.
(var_diff::traverse): Handle category propagation from the
type diff node to the var_diff node.
(pointer_diff::underlying_type_diff)
(reference_diff::underlying_type_diff)
(qualified_type_diff::underlying_type_diff, enum_diff::enum_diff)
(base_diff::get_underlying_class_diff)
(typedef_diff::underlying_type_diff): Do not set the parent node
here.
({pointer_diff, reference_diff, qualified_type, enum_diff,
class_diff, base_diff, function_decl_diff,
typedef_diff}::traverse): Handle category propagation here.
* tests/data/test-diff-filter/test4-v0.o: New input binary.
* tests/data/test-diff-filter/test4-v0.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test4-v1.o: New input binary.
* tests/data/test-diff-filter/test4-v1.cc: Source code for the
input binary above.
* tests/data/test-diff-filter/test4-report.txt: Reference diff
report for the input binaries above.
* tests/test-diff-filter.cc:: Run bidiff --no-harmless on the
binaries above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(function_decl_diff::ensure_lookup_tables_populated): Function
parameters that are diff'ed start at the first non-implicit
parameter, not at the first parameter. Oops.
* tests/data/test-diff-dwarf/test3-v0.o: New test input binary.
* tests/data/test-diff-dwarf/test3-v0.cc: Source code for the
binary above.
* tests/data/test-diff-dwarf/test3-v1.o: New test input binary.
* tests/data/test-diff-dwarf/test3-v1.cc: Source code for the
binary above.
* tests/data/test-diff-dwarf/test3-report.txt: Reference report
for the diff of the new test inputs.
* tests/test-diff-dwarf.cc: Use the test inputs above to run new
tests.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(function_decl_diff::ensure_lookup_tables_populated): A parm
change is valid only when the added parm has a different name from
the removed parm. Both have the same index, of course. In that
case, do not try to remove the corresponding parm sub-type change.
* tests/data/test-bidiff/test-enum0-report.txt: Adjust.
* tests/data/test-bidiff/test-enum1-report.txt: Adjust.
* tests/data/test-bidiff/test-qual-type0-report.txt: Adjust.
* tests/data/test-bidiff/test-struct0-report.txt: Adjust.
* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
* tests/data/test-diff-dwarf/test1-report.txt: Adjust.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* tests/data/test-diff-filter/test01-report.txt: Adjust.
* tests/data/test-diff-filter/test1-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test3-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::COMPATIBLE_TYPE_CHANGE_CATEGORY): New enumerator.
(operator|=(diff_category&, diff_category)): New declaration.
* include/abg-fwd.h (is_typedef, strip_typedef)
(types_are_compatible): New declarations.
* include/abg-ir.h (operator==(const decl_base_sptr, const
decl_base_sptr)): Added the consts here.
(operator==(const type_base_sptr, const type_base_sptr)): New
declaration.
* src/abg-comp-filter.cc (is_compatible_change): New static
function.
(harmless_filter::visit): Detect compatible changes and add the
sub-tree into the new COMPATIBLE_TYPE_CHANGE_CATEGORY if
applicable. Cleanup the logic.
* src/abg-comparison.cc (operator|=(diff_category&,
diff_category)): Define new function.
(operator==(const decl_base_sptr l, const decl_base_sptr r)): Add
consts.
(operator==(const type_base_sptr l, const type_base_sptr r)):
Define new operator.
(is_typedef, strip_typedef, types_are_compatible): New function
definitions.
* tests/data/test-diff-filter/test3-report.txt: New test report
reference.
* tests/data/test-diff-filter/test3-v0.cc: Source code for new
test input.
* tests/data/test-diff-filter/test3-v0.o: New test input.
* tests/data/test-diff-filter/test3-v1.cc: Source code for new
test input.
* tests/data/test-diff-filter/test3-v1.o: New test input.
* tests/test-diff-filter.cc: Adjust to consume the new tests
inputs above.
* tools/bidiff.cc: Add the new COMPATIBLE_TYPE_CHANGE_CATEGORY
into the --harmless group.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): For var_decl, do not emit
filtered-out local size/offset/access changes.
(report_name_size_and_alignment_changes): Take the diff context.
Do not report filtered-out local size/offset changes.
({var_diff, enum_diff, class_diff, type_decl_diff}::report):
Adjust.
* test0-report.txt: Adjust.
* test01-report.txt: New reference report for the same inputs
test0-v{1,0}.o, but called without the --no-harmless command line.
* tests/data/test-diff-filter/test2-v0.cc: Source code for new test input.
* tests/data/test-diff-filter/test2-v1.cc: Likewise.
* tests/data/test-diff-filter/test2-v0.o: New test input.
* tests/data/test-diff-filter/test2-v1.o: Likewise.
* tests/data/test-diff-filter/test2-report.txt: Reference report
for new test input.
* tests/test-diff-filter.cc: Consume the test inputs above.
* tests/Makefile.am: Add the new test inputs above to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (unsigned_changed_parm_map)
(unsigned_parm_map): New typedefs.
* src/abg-comparison.cc
(function_decl_diff::subtype_changed_parms): Renamed this from
changed_parms.
(function_decl_diff::priv::subtype_changed_parms_}): Renamed this
from changed_parms_;
(function_decl_diff::priv::{deleted_parms_by_id_,
added_parms_by_id_, changed_parms_by_id_}): New members.
(function_decl_diff::ensure_lookup_tables_populated): Update the
new priv::changed_parms_by_id_ member to contain the parameters
that got changed, as opposed to the subtype_changed_parms_ member
that contain parameters that got a sub-type change. The other
priv::*_by_id_ members are helpers for this. Update them too.
(function_decl_diff::subtype_changed_parms): Renamed this from
::changed_parms.
(function_decl_diff::report): Report separately about parameters
having a sub-type change, and parameters that got changed. Note
that in both cases, the change is necessarily to a compatible
type.
* data/test-diff-dwarf/test2-v0.cc: New test file.
* data/test-diff-dwarf/test2-v0.o: Likewise.
* data/test-diff-dwarf/test2-v1.cc: Likewise.
* data/test-diff-dwarf/test2-v1.o: Likewise.
* data/test-diff-dwarf/test2-report.txt: Likewise.
* tests/Makefile.am: Add the new test files above to the
distribution.
* tests/test-diff-dwarf.cc: Consume the input files above to
actually perform a regression test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (class_diff::traverse): Fix thinking in
introduced by commit "6709478 Fix infinite loop when traversing
classes and their members"
* tests/data/test-diff-filter/test1-v{0,1}.o: New test binary input files.
* tests/data/test-diff-filter/test1-v{0,1}.cc: Source code for the
above.
* tests/data/test-diff-filter/test1-report.txt: Reference report
for the diffing of the two binary input files above.
* tests/test-diff-filter.cc: Make the test run on the new input above.
* tests/Makefile.am: Add the new material to the distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_category::ACCESS_CHANGE_CATEGORY): Renamed
ACCESS_CHANGED_CATEGORY into this.
(diff_category::SIZE_OR_OFFSET_CHANGE_CATEGORY): Renamed
SIZE_CHANGED_CATEGORY into this. Changed its semantics to
incorporate offset changes as well.
* src/abg-comparison.cc (struct noop_deleter): Move this up.
(represent): Do not report filtered out data members.
(report_mem_header): Add a new num_filtered parameter to take
filtered-out members in account in members report headers.
Adjust.
(class_diff::priv::{count_filtered_bases,
count_filtered_data_members, count_filtered_member_functions}):
New member functions. When a member is filtered, do not report
it all.
({enum_diff, class_diff}::report): Adjust. Take filtered members
into account in headers.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): New
member function.
(corpus_diff::priv::emit_diff_stats): Renamed
emit_corpus_diff_stats into this. Change it to take the stats in
parameter.
(corpus_diff::report): Adjust to re-use the above. Filter
varibles as well. Take the filtered functions & variables in
account in the stats. Do not report filtered-out functions &
variables at all.
* src/abg-comp-filter.cc (type_size_changed, access_changed)
(data_member_offset_changed): New predicates.
({harmless, harmful}_filter::visit): Adjust to use the new
predicates above. Update the harmful variant for the new
SIZE_OR_OFFSET_CHANGE_CATEGORY category.
* tools/bidiff.cc (set_diff_context_from_opts): Adjust for the
categories name changes.
* tests/data/test-diff-filter/test0-report.txt: New test input.
* tests/data/test-diff-filter/test0-v0.cc: Likewise.
* tests/data/test-diff-filter/test0-v0.o: Likewise.
* tests/data/test-diff-filter/test0-v1.cc: Likewise.
* tests/data/test-diff-filter/test0-v1.o: Likewise.
* tests/test-diff-filter.cc: New test harness.
* tests/Makefile.am: Add the new test files above to the
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): For member var_decls, add a
missing apostrophe after the access.
* tests/data/test-diff-dwarf/test0-report.txt: Update test report.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-diff-dwarf.cc: New dwarf diffing regression test
harness.
* tests/data/test-diff-dwarf/test0-report.txt: New test input.
* tests/data/test-diff-dwarf/test0-v0.cc: Likewise.
* tests/data/test-diff-dwarf/test0-v0.o: Likewise.
* tests/data/test-diff-dwarf/test0-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test0-v1.o: Likewise.
* tests/Makefile.am: Add the new test inputs from
tests/test-diff-dwarf.cc and tests/data/test-diff-dwarf/* to
the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/test-ir-walker.cc: Renamed test-walker.cc into this.
* tests/Makefile.am: Adjust. The generated binary is now testirwalker.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-traverse.h (traversable_base::traversable): Change
the signature of this to return a boolean.
* include/abg-ir.h (ir_traversable_base::traverse): Change the
signature of this to return a boolean.
(*::traverse): Adjust.
(ir_node_visitor::visit): Change the signature of this to return a
boolean.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Adjust.
* src/abg-ir.cc (::traverse): Adjust.
* tests/test-walker.cc (name_printing_visitor::visit): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_function_decl): Change signature
to take function_decl to which one shall add properties that got
added by subsequent DIEs later.
(build_class_type_and_add_to_ir): Adjust.
(build_function_decl): Allow adding new properties to an existing
function_decl. Add the mangled name in particular.
* tests/data/test-read-dwarf/test1.abi: Update test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl:#️⃣:operator()): Adjust.
(class_decl::data_member:#️⃣:operator()): Remove.
(decl_base:#️⃣:operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}:#️⃣:operator()): Adjust.
(class_decl::member_function:#️⃣:operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (class base_diff): New.
* include/abg-ir.h (function_decl::get_first_non_implicit_parm):
New member function.
(function_type::get_first_non_implicit_parm): Likewise.
* src/abg-comparison.cc (base_has_changed): Change parm to take
class_decl::base_spec_sptr.
(class_diff::ensure_lookup_tables_populated): Compare the base
specs not just the base classes.
(class_diff::report): Adjust. Report sub-type changes in the
member functions.
(base_diff::*): Define member functions.
(compute_diff): Define an overload for base_diff_sptr.
* src/abg-hash.cc ({function_type,
method_type}:#️⃣:operator()): Do not hash the implicit parm of
member functions.
(class_decl:#️⃣:operator()): Do not hash member types.
* src/abg-ir.cc (decl_base::decl_base): Initialize the
hashing_started_ member that got moved here from class_decl.
(decl_base::get_hash): Do not set the hash if it's being set b/c
we are in a class_decl.
(decl_base::operator==) Do not compare hashes for now. Two decls
can have different hashes and compare equal; think about an
incomplete type foo, that compares equal with a complete foo.
Their hashes will be different though. So for now, just avoid
comparing these.
(compare_function_types): Avoid comparing the implicit parameter
for member functions.
({function, method}_type::get_first_non_implicit_parm): New
definition.
* tests/data/test-read-write/test20.xml: Update.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not
declare classes before defining them because both the declaration
and the definition now compare equal.
* tests/data/test-read-dwarf/test1.abi: Update test.
* tests/data/test-read-write/test20.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::is_struct_): New member.
(class_decl::class_decl): Take an additional is_struct member.
(class_decl::is_struct): New getter.
* src/abg-ir.cc (class_decl::class_decl): Initialize the new
is_struct_ data member.
(class_decl::get_pretty_representation): Tell struct and class
apart.
* abg-reader.cc (read_is_struct): New static function.
(build_class_decl): Capture the struct-ness of the class.
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
Likewise.
* src/abg-writer.cc (write_is_struct): New static function.
(write_class_decl): Write the struct-ness of the class.
* tests/data/test-read-dwarf/test1.abi: Update test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (die_is_artificial): New static
function.
(build_class_type_and_add_to_ir, build_ir_node_from_die): Use the
die_is_artificial function to test if the function DIE is
artificial and then skip it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Insert
reference, pointers and qualified types at the point where we see
them, in their scope, rather than under the scope of their
underlying type. This is because their might be first declared as
member types and we don't want to loose that information.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.h (compute_diff): For class_decl_sptr, do not
compare member types and member class templates. This adds a lots
of noise that is not necessarily useful for now.
* tests/data/test-bidiff/test-qual-type0-report.txt: Update tests.
* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
accordingly
* include/abg-comparison.h (class diff_context): New class.
(class diff::{ctxt_, reported_once_, currently_reporting_}): New
data members.
(diff::diff): Initialize the new data members above.
(diff::{context, currently_reporting, reported_once}): New
accessors.
(compute_diff, var_diff::var_diff, pointer_diff::pointer_diff)
(reference_diff::reference_diff, qualified_type_diff)
(enum_diff:enum_diff, class_diff::class_diff)
(scope_diff::scope_diff, function_decl_diff::function_decl_diff)
(type_decl_diff::type_decl_diff, typedef_diff::typedef_diff)
(translation_unit_diff::translation_unit_diff, corpus_diff::corpus_diff):
Take an additional pointer to diff_context.
* abg-comparison.cc (diff_context::{has_diff_for,
has_diff_for_types, add_diff}): New methods.
(try_to_diff, compute_diff_for_types, compute_diff_for_decls)
(represent): Take an additional pointer to
diff_context in argument. In the later function, do not re-report
a diff if it has already been reported, or if it's being reported
already.
(var_diff::var_diff, pointer_diff::pointer_diff)
(reference_diff::reference_diff)
(qualified_type_diff::qualified_type_diff, enum_diff::enum_diff)
(class_diff::class_diff, scope_diff::scope_diff)
(function_decl_diff::function_decl_diff, type_decl::type_decl)
(typedef_diff::typedef_diff)
(translation_unit_diff::translation_unit_diff)
(corpus_diff::corpus_diff): Take an additional pointer to
diff_context in argument.
({pointer_diff, qualified_type_diff,
reference_type_diff}::report): do not re-report a diff about the
underlying type if it has already been reported, or if it's being
reported already.
(enum_diff::report): Fix this to properly use the populated lookup
tables.
(compute_diff): take an additional pointer to diff_context in
argument. For the var_decl, pointer_diff reference_type_diff,
qualified_type_diff enum_diff, scope_diff, function_decl_diff,
type_decl_diff and typedef_diff overloads, do not re-build a diff
object, if one exits already. Otherwise, record the new diff
object created so that it can be re-used later.
(enum_diff::ensure_lookup_tables_populated): Fix logic to avoid
one loop.
(class_decl::priv::{deleted_member_functions_,
inserted_member_functions_, changed_member_function_}): New
members to support reporting about member functions changes.
(class_decl::{lookup_tables_empty, clear_lookup_tables, length):
Update for the new additions above.
(class_decl::ensure_lookup_tables_populated): Likewise. Fix to
properly use the lookup tables and also avoid a going through
several loops to compute the changed members.
(class_decl::report): Flip a switch to make the beginning and end
of the reporting, in the context. Also, do not try to report
again, if we were already reporting this diff. Fix quite some
spots to properly use the lookup tables.
(scope_diff::ensure_lookup_tables_populated): Skip decl-only
classes during comparison. Fix some thinkos. Fix logic to avoid a
loop.
(scope_diff::report): Adjust to pass a context to
compute_diff_for_types.
(function_decl_diff::ensure_lookup_tables_populated): Fix logic to
avoid a loop.
(function_decl_diff::report): Adjust call to
compute_diff_for_types to pass the context.
(typedef::report): Avoid re-reporting the diff of the underlying
types, if we are already reporting it.
(corpus_diff::priv::ensure_lookup_tables_populated): Use the
pretty representation of the function rather than its name to key
the maps of deleted and added functions. Fix logic to avoid going
through an additional loop for the changed functions.
(corpus_diff::report): Add a title for removed/added/changed
functions. Fix indentation for added/removed/changed functions.
* include/abg-ir.h (class_decl::comparison_started_): New member
* src/abg-dwarf-reader.cc (is_public_decl): Style fix.
(is_declaration_only_): New static function.
(build_class_type_and_add_to_ir): Create decl-only classes (IR) for
classes flagged as declaration-only in the DWARF.
* src/abg-hash.cc (class_decl:#️⃣:operator()): Do not forget to
include the "is_declaration_only" flag into the hashing.
* src/abg-ir.cc (class_decl::operator==): Look through decl-only
classes to get their definitions and compare the definitions
instead. Avoid comparing member types and fns if the comparison
of this type has already started.
* src/abg-reader.cc (build_class_decl): Set the definition of a
declaration, when we see it.
* tests/data/test-bidiff/test-qual-type0-report.txt: Update.
* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (end_of_frr_d_path_in_k_plus_delta):
Favour moving left when the two abscissas at the previous steps
are equal.
(compute_diff): Update the length of the shortest edit script when
the size of one of the inputs is zero.
* tests/test-core-diff.cc (in_out_spec): Add a new input to diff
two sequences for regression testing.
* tests/data/test-core-diff/report13.txt: New reference for
the comparison of the new regression test above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (insert_decl_into_ir_under_scope)
(build_namespace_decl_and_add_to_ir, build_enum_type)
(build_class_type_and_add_to_ir, build_ir_node_from_die)
(build_ir_node_from_die): Remove.
* tests/data/test-read-dwarf/test0.abi: Update because now type
IDs can be used before they are defined.
* tests/data/test-read-dwarf/test1.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* tests/data/test-read-dwarf/test0.cc: Define a member function
out-of-line, outside of its namespace.
* tests/data/test-read-dwarf/test0.abi: Update the .abi file.
* tests/data/test-read-dwarf/test0: Update the resulting binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-reader.h (read_corpus_from_native_xml)
(read_corpus_from_native_xml_file): Declare new entry points.
* include/abg-writer.h (write_corpus_to_native_xml)
(write_corpus_to_native_xml_file): Likewise.
* src/abg-reader.cc (read_translation_unit_from_input): Renamed
read_input into this. Support new 'path' attribute for
'abi-instr' XML element.
(read_corpus_from_input): New static function.
(read_translation_unit_from_file)
(read_translation_unit_from_buffer)
(read_translation_unit_from_istream): Update wrt read_input ->
read_translation_unit_from_input.
(read_corpus_from_native_xml, read_corpus_from_native_xml)
(read_corpus_from_native_xml_file): Define new entry points.
* src/abg-writer.cc (write_translation_unit): Write 'path'
attribute into the 'abi-instr' xml element.
(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
Define new entry points.
* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
FILE_TYPE_ZIP_CORPUS}): New enumerators.
* tools/abg-tools-utils.cc (guess_file_type): Support detection of
the new xml file format containing a document root 'abi-corpus'
root element.
* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
corpus-es.
* tools/bidw.cc (main): Recognize elf files before reading them.
* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
* tests/data/test-read-write/test[0-23].xml: Update 'path'
attribute.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (ir_traversable_base): New type to be the base
of IR nodes that are to be traversed. Extends traversable_base.
Its ir_traversable_base::traversable() method takes an
ir_node_visitor&.
(ir_node_visitor::visit): Change these virtual overloads to take
pointers to IR nodes, rather than references. This will be useful
to e.g, store these IR nodes in containers on the side for some
algorithms to work. That is going to be useful later to,
e.g. build symbol tables on the side, using the visitor interface.
(class decl_base): Make this inherit ir_traversable_base.
* src/abg-ir.cc (*::traverse): Adjust comments and the call the
ir_node_visitor::visit call. Use the ir_traversable_base type
rather than traversable_base.
(ir_traversable_base::traverse): Define.
(ir_node_visitor::visit): Change these overloads to take pointers
rather than reference to ir nodes.
* tests/test-walker.cc (name_printing_visitor::visit): Adjust to
take pointers rather than references.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (translation_unit::translation_unit): Take an
address_size parameter.
(translation_unit::{get_address_size, set_address_size}): New
accessors.
* src/abg-ir.cc (translation_unit::priv::address_size_): New
private member.
(translation_unit::translation_unit): Take an address_size
parameter.
(translation_unit::{get_address_size, set_address_size}): Define
these new methods.
* src/abg-reader.cc (read_input): Read the "address-size"
attribute from the abi-instr element.
* src/abg-writer.cc (write_translation_unit): Write the
"address-size" attribute.
* tests/data/test-read-write/test23.xml: New test input.
* tests/test-read-write.cc (in_out_specs): Add the new test above
to the list of files to read and write back.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>