Commit Graph

74 Commits

Author SHA1 Message Date
Dodji Seketeli
b6c3e9ec0a Fix a missing new line in the reports
* src/abg-comparison.cc (represent(class_decl::method_decl_sptr,
	ostream&)): Add a missing new line.
	* tests/data/test-bidiff/test-struct1-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-15 11:32:21 +02:00
Dodji Seketeli
0112c5619a Don't compare non-virtual member functions in class comparison
* 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>
2014-04-14 21:48:00 +02:00
Dodji Seketeli
305f18e91e Filter non-virtual member fns insertions/deletions from class changes
* 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>
2014-04-13 23:09:02 +02:00
Dodji Seketeli
7ac2fe072d Make class_decl pimpl and harden comparison infloop prevention
* 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>
2014-04-13 22:09:24 +02:00
Dodji Seketeli
f02768e7a7 Represent a removed+added data member at a given offset as changed
* 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>
2014-04-11 21:55:08 +02:00
Dodji Seketeli
dce487d39c Properly place opening quote and add missing closing quote in report
* src/abg-comparison.cc (corpus_diff::report): Move the [{A,D}]
	marker before the opening quote.  And add a closing quote.
	* tests/data/test-diff-dwarf/test0-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/test2-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 15:08:06 +02:00
Dodji Seketeli
23b7fa9ac2 Add a new DECL_NAME_CHANGE_CATEGORY change category
* 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>
2014-04-06 15:59:38 +02:00
Dodji Seketeli
96edc0b08c Really compare return types for function types
* 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>
2014-04-05 12:42:24 +02:00
Dodji Seketeli
2c03fdda8a Add missing tests for previous commits
* 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>
2014-04-05 12:40:28 +02:00
Dodji Seketeli
8801da4eb9 Categorize through compatible distinct type diffs
* 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>
2014-04-05 12:24:25 +02:00
Dodji Seketeli
e9ce9ef352 Do not hook type diff nodes to a parent
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>
2014-04-04 14:44:50 +02:00
Dodji Seketeli
6a57f61497 Fix off-by one comparison bug in comparing function parameters
* 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>
2014-04-04 11:39:41 +02:00
Dodji Seketeli
712320ab4c Do not forget parm sub-type changes as opposed to parm changes
* 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>
2014-04-03 16:52:14 +02:00
Dodji Seketeli
64bbb5ccef Add a COMPATIBLE_TYPE_CHANGE_CATEGORY to bidiff --no-harmless
* 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>
2014-04-02 17:23:56 +02:00
Dodji Seketeli
28304c9439 Don't emit local filtered-out changes
* 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>
2014-04-01 16:08:30 +02:00
Dodji Seketeli
70d5afdaa2 Compact & intuitive reporting for changed function parameters
* 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>
2014-04-01 12:38:51 +02:00
Dodji Seketeli
847c9e8166 Fix thinko class_diff traversing.
* 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>
2014-03-31 13:17:28 +02:00
Dodji Seketeli
33be9938be Add forgotten test output adjustment
* tests/data/test-diff-filter/test0-report.txt: Adjust for the
	commit "a8d5284 Fix diff report indentation issue"
	* tests/data/test-diff-dwarf/test{0,1}-report.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 13:17:00 +02:00
Dodji Seketeli
b53edd3fcd Add forgotten source file for binary test input
* tests/data/test-diff-dwarf/test1-v0.cc: New file.
	* tests/data/test-diff-dwarf/test1-v1.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 11:27:32 +02:00
Dodji Seketeli
67e6971005 Take filtering in account in diff stats & better categorizing
* 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>
2014-03-29 10:26:45 +01:00
Dodji Seketeli
e55a7e3397 Fix var_diff length determination
* src/abg-comparison.cc (var_diff::length):  Just compare the two
	diff subjects.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-29 10:26:45 +01:00
Dodji Seketeli
ec53393fb1 Add a missing apostrophe to access reporting
* 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>
2014-03-27 13:01:18 +01:00
Dodji Seketeli
ec6d70500d Fix diff emptiness detection for function_decl_diff nodes
* src/abg-comparison.cc (function_decl_diff::length): Just compare
	the two functions here, damit.
	* tests/data/test-diff-dwarf/test0-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:18 +01:00
Dodji Seketeli
fcd2ef9d4e Initial regression test for dwarf diffing
* 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>
2014-03-27 13:01:17 +01:00
Dodji Seketeli
04a1e27258 Follow DW_AT_abstract_origin and add missing mangled name
* 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>
2014-03-24 12:22:05 +01:00
Dodji Seketeli
ed5cd14a34 Get rid of class_decl::data_member
* 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>
2014-03-19 21:18:38 +01:00
Dodji Seketeli
661f76c8f4 Better base class diff reporting
* 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>
2014-03-18 11:27:02 +01:00
Dodji Seketeli
42aaa3124e Do not declare classes before defining them anymore
* 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>
2014-03-11 13:55:35 +01:00
Dodji Seketeli
1c6f62bad7 Tell struct and class apart
* 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>
2014-03-10 10:04:34 +01:00
Dodji Seketeli
5ff3176ad1 Skip artificial (member) functions from DWARF
* 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>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
a97dd610f6 Insert reference, pointers and qual types at their declaration point
* 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>
2014-02-26 12:40:59 +01:00
Dodji Seketeli
fa3815a9e6 Avoid comparing member types and class templates
* 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>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
2c3dbbdb62 Fix the pretty representation for member functions
* src/abg-ir.cc (function_decl::get_pretty_representation): Fix
	this to properly display the representation of member functions.
	* tests/data/test-bidiff/test-enum0-report.txt: Update this.
	* tests/data/test-bidiff/test-enum1-report.txt: Likewise.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Likewise.
	* 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>
2014-02-11 16:17:50 +01:00
Dodji Seketeli
593629100f Fix typo in report
* src/abg-comparison.cc (reference_diff::report): Fix typo
	refereneced -> referenced.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
9905d847d2 Support looking through decl-only classes and update diff reports
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>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
b219598e7b Fix further reaching reverse path calculation in core diff algo
* 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>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
b152fa74b4 Just add decls sequentially when reading from DWARF
* 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>
2014-01-20 10:32:37 +01:00
Dodji Seketeli
3045c0aef2 Tweak dwarf reading test to detect more namespace linking-fu
* 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>
2014-01-13 17:36:20 +01:00
Dodji Seketeli
8f9b8e76a0 Add regression tests for dwarf reading
* tests/test-read-dwarf.cc: New dwarf reading regression test.
	* tests/data/test-read-dwarf/test0: New test input.
	* data/test-read-dwarf/test0: Likewise.
	* data/test-read-dwarf/test0.abi: Likewise.
	* data/test-read-dwarf/test0.cc: Likewise.
	* data/test-read-dwarf/test1: Likewise.
	* data/test-read-dwarf/test1.abi: Likewise.
	* data/test-read-dwarf/test1.cc: Likewise.
	* tests/Makefile.am: Build the new tests/test-read-dwarf.cc file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 15:51:52 +01:00
Dodji Seketeli
2c9fb3e70d Support new 'abi-corpus' native XML format (.abi)
* 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>
2014-01-07 14:12:26 +01:00
Dodji Seketeli
d3929eaf23 Support the "address-size" attribute for <abi-instr> elements
* 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>
2013-12-11 12:30:19 +01:00
Dodji Seketeli
61b13cc9db Support variadic arguments in function decls
* src/abg-reader.cc (build_function_parameter): Support reading
	the "is-variadic" attribute.
	* src/abg-writer.cc (write_function_decl): Support writing the
	"is-variadic" attribute.
	* tests/data/test-read-write/test22.xml: New test input.
	* tests/test-read-write.cc (in_out_specs): Add the new test to the
	list of files to read and write back.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-11 12:17:55 +01:00
Dodji Seketeli
c5b81de47d Add support for bidiff regression testing
* tests/data/test-bidiff/test-enum0-v0.cc.bi: New input file.
	* tests/data/test-bidiff/test-enum0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum0-report.diff: Likewise.
	* tests/data/test-bidiff/test-enum1-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum1-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum1-report.txt: Likewise.
	* tests/data/test-bidiff/test-qual-type0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-qual-type0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Likewise.
	* tests/data/test-bidiff/test-struct0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
	* tests/data/test-bidiff/test-struct1-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct1-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
	* tests/data/test-bidiff/test-var0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-var0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-var0-report.txt: Likewise.
	* tests/test-bidiff.cc: New file.
	* tests/Makefile.am: Build the new runtestbidiff regression test
	and add the above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-29 14:32:30 +01:00
Dodji Seketeli
a03d9c0e64 Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
	* include/abg-ir.h (class decl_base): Add class_decl as a friend.
	This to be able to call decl_base::set_scope from class_decl.
	(scope_decl::add_member_decl): Make this virtual protected, so
	that it can be called (virtually) from e.g, class_decl.
	(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
	(class_decl::add_member_decl): New virtual overload for
	scope_decl::add_member_decl.
	(class_decl::{add_member_type, add_data_member,
	add_member_function}): New overloads.
	* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
	(get_type_declaration): Define new function.
	(class_decl::add_member_decl): New method.
	(class_decl::add_member_type): Avoid silently added a new member
	type when that member type has already been (perhaps
	inadvertently) added to a scope already.  Rather, put a strict
	assert in place there.  Also add a new overload that constructs
	the member type out of a classic type and adds it to the class.
	(class_decl::{add_data_member, add_member_function}): Likewise.
	(class_decl::{add_member_function_template,
	add_member_class_template}): Avoid silently added a new member
	template when that template has already been (perhaps
	inadvertently) added to a scope already.  Rather, put a strict
	assert in place there.
	* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
	flag saying if the current decl should be added to the current
	scope as well (in addition to being pushed onto the stack of
	scopes maintained in the reader context).
	(push_and_key_type_decl): Likewise, take that extra flag and pass
	it to push_decl_to_current_scope.
	(build_function_decl, build_var_decl, build_type_decl)
	(build_qualified_type_decl, build_pointer_type_def)
	(build_reference_type_def, build_enum_type_decl, build_typedef_decl)
	(build_function_tdecl, build_class_tdecl): Likewise.
	(build_class_decl): Likewise.  When building member data, types,
	and functions, make sure /not/ to add the data, type of function to
	the current scope before adding it to the class_decl.  This was
	making the member not being added to the class because it already
	had a scope.
	(build_type_tparameter, build_type_composition)
	(build_non_type_tparameter, build_template_tparameter)
	(build_type): Adjust to add the template parm to the current scope
	explicitly, like previously.
	(handle_type_decl): Use build_type_decl function. Add the
	type_decl to the current scope, like previously.
	(handle_namespace_decl, handle_qualified_type_decl)
	(handle_pointer_type_def, handle_reference_type_def)
	(handle_enum_type_decl, handle_typedef_decl, handle_var_decl)
	(handle_function_decl, handle_class_decl, handle_function_tdecl)
	(handle_class_tdecl): Adjust to add the decl to the current scope,
	like previously.
	* tests/data/test-read-write/test21.xml: New test input with
	member type(def).

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:49 +01:00
Dodji Seketeli
9be945584a Re-write middle snakes management in core diff algorithms
* include/abg-diff-utils.h (point::set): New overload..
	(point::{add, operator<, operator>, operator<=, operator>=}): New
	methods.
	(point::operator!=): Constify.
	(point::operator==): Constify. Cleanup.
	(point::operator=): Keep emptiness.
	(class snake): New class definition
	(d_path_vec::{over_bounds, offset}): New methods.
	(d_path_vec::check_index_against_bound): Don't take a bound
	parameter anymore.  Use the new over_bound method above.  Fix up
	error reporting.
	(d_path_vec::d_path_vec): Fix d_path_vec size allocation.
	(d_path_vec::operator[]): Use the d_path_vec::at method to check
	all accesses against the bounds.  This is slower, but at least we
	can expect to have something that is more robust.  We can remove
	the bound checking later when we are sure the code has been tested
	enough.  Also use the new offset() method.
	(d_path_vec::at): Take long long.
	(ends_of_furthest_d_paths_overlap): Constify input parameters.
	(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Take
	an instance of the new snake in parameter, rather than a bare end
	point that wasn't carrying enough information about the snake.
	Record the snake which consists of up to four points: a begin
	point, an intermediate point, a diagonal start point and an end
	point.  Return that snake upon successful completion.
	(compute_middle_snake): Take an instance of snake, rather than the
	two points that were supposed to represent a snake and with which
	we were loosing information before.  Revisit/simplify the logic of
	this function; this literally goes forward or in reverse, gets the
	resulting snake returned by the end_of_fr_d_path_in_k and
	end_of_frr_d_path_in_k_plus_delta functions, detect if these snakes
	overlap and just return the current snake.  Much simpler.  The
	caller now gets a snake, which has much more information than the
	previous snake approximation made of just two points.  Bonus
	point, this follows almost to the word, what the paper says.
	(maybe_record_match_point, find_snake_start_point): Remove these
	as there are not used by compute_middle_snake anymore.
	(print_snake, ses_len): Update these to take/handle a snake.
	(snake_end_points): New declaration.
	(compute_diff): When we are getting an empty first sequence, this
	means that we are inserting the second sequence *before* the
	beginning of the first sequence; keep this information by setting
	the insertion point index to -1, rather than zero.  Update this to
	get/handle snakes, rather than free points vaguely representing
	snakes.  Now that compute_middle_snake returns real snakes, handle
	the information we are getting.  Basically for edit scripts of
	length equal to 1, as the snake carries all the necessary
	information about the non-diagonal edge (as well as the diagonal
	edges), we (can) now precisely update the current edit script (as
	well as the longest common sub-sequence).  For edit scripts of
	length greater than 1, better at which points to divide the
	problem and consequently, at which points to conquer it back --
	better following The Paper to the letter.
	(display_edit_script): Update this for the use of instances of
	snake.
	* src/abg-diff-utils.cc (ends_of_furthest_d_paths_overlap): Update
	for constification of inputs.
	(snake_end_points): Define new function.
	(compute_middle_snake): Adapt for the taking an instance of snake.
	* tests/test-diff2.cc (main): Update for using instances of snake.
	* tests/test-core-diff.cc: Add new tests.
	* tests/data/test-core-diff/report0.txt: Update for output
	adaptation.
	* tests/data/test-core-diff/report6.txt: Likewise.
	* tests/data/test-core-diff/report7.txt: Likewise.
	* tests/data/test-core-diff/report8.txt: New test data.
	* tests/data/test-core-diff/report9.txt: Likewise.
	* tests/data/test-core-diff/report10.txt: Likewise.
	* tests/data/test-core-diff/report11.txt: Likewise.
	* tests/data/test-core-diff/report12.txt: Likewise.
	* tests/data/test-core-diff/report3.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:47 +01:00
Dodji Seketeli
ee2d8c9196 Fix IR node comparison bugs
* include/abg-ir.h (type_shared_ptr_equal::operator()): Fix thinko
	in checking for the boolean value of the pointers to types.
	* src/abg-ir.cc (type_decl::operator==(const decl_base&)): Do not
	forget to compare the decl_base part of the type too.
	(type_decl::operator==(const type_base&)): To ease maintenance,
	re-use the equality operator that takes a decl_base.
	(scope_type_decl::operator==(const type_base&)): Likewise.
	(qualified_type_def::operator==(const type_base&)): Likewise.
	(compare_function_types): New sub-routine to compare function
	types.  It fixes an infinite recursion when comparing two methods
	of the same class.
	(function_type::operator==(const type_base&)): Use the new
	compare_function_types function.
	(class_decl::operator==(const decl_base&)): Fix a thinko in the
	first test of the function.  Use a dedicated scope for each class
	section comparison; that way, there won't be any chance to misuse
	the variables pertaining to a different section.  Fix the member
	function sections; we were mistakenly using the variables for the
	*data* section there.
	(class_decl::operator==(const type_base&)): Re-use the operator
	that takes a decl_base.
	(class_decl::operator==(const class_decl&)): Don't remove
	const-ness during the static cast.
	(class_decl::member_function::operator==(const member_function&)):
	Do not remove the reference from the static cast.
	(class_decl::member_class_template::operator==(const
	member_base&)): Likewise.
	(type_tparameter::operator==(const template_parameter&)):
	Likewise.
	(template_tparameter::operator==(const template_parameter&)):
	Likewise.
	(function_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const class_tdecl&)): Likewise.
	* tests/data/test-read-write/test12.xml: Update this because the
	test now correctly considers two type template parameters at the
	same index as being equivalent.
	* tests/data/test-read-write/test13.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:09 +01:00
Dodji Seketeli
997e2d9328 Fix middle snake determination & ses len computation for d == 1
* include/abg-diff-utils.h (compute_middle_snake): After the
	overlap determination happened, finding the middle snake can
	require keep on building the current path until the "end".  The
	end meaning reaching the max of D.  And that max is (M + N)/2 + 1.
	In the extreme cases were middle snake was on the very last step
	(M + N) + 1, we were not finding the middle snake.  Fix this.
	(compute_diff): When d == 1 and the first edge on the edit graph
	is a non-diagonal edge and when a_base != a_begin, we were failing
	to properly initialize x,y to find that non-diagonal edge.  Also
	we were failing to correctly compute the size of the sequence.
	Fix these.
	* tests/test-core-diff.cc: Add a new regression test for the two
	cases above.
	* tests/data/test-core-diff/report7.txt: New reference data for
	the new regression test.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:22:56 +01:00
Dodji Seketeli
fe1b7062eb Fix middle snake determination
* include/abg-diff-utils.h (point::{operator!=,operator==}): New
	operators.
	(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Allow
	the initial point (-1,-1) that is not a point addressing elements
	of the input sequences, but that is the starting point of the
	forward paths and the ending point of reverse paths in the "Linear
	Refinement" of the algorithm.
	(is_match_point, maybe_record_match_point)
	(find_snake_start_point): New functions.
	(find_last_snake_in_path): Remove this.  It's not used anymore.
	(compute_middle_snake): Allow checking for overlapping paths even
	on points that are outside of the edit graph boundaries.  Once the
	overlap is detected, if a non-empty snake has been seen already,
	report it as the middle snake.  Otherwise, keep building the path
	until the end and report the last snake encountered as the middle
	snake.  Add comments.
	(compute_diff): For the d == 1 case, fix the logic of the finding
	the non-diagonal edge.  Fix typos.  Add comments.
	(display_edit_script): Fix report glitches.
	* tests/data/test-core-diff/report3.txt: Update as per the report
	glitch above.
	* tests/data/test-core-diff/report4.txt: Likewise.
	* tests/data/test-core-diff/report5.txt: Likewise.
	* tests/data/test-core-diff/report6.txt: New reference report for
	a new test.
	* tests/test-core-diff.cc: Add a new test for negative delta.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:19 +01:00
Dodji Seketeli
90467f10f2 Initial regression test facility for core diff algorithms
* tests/data/test-core-diff/report0.txt: New test reference data.
	* tests/data/test-core-diff/report1.txt: Likewise.
	* tests/data/test-core-diff/report2.txt: Likewise.
	* tests/data/test-core-diff/report3.txt: Likewise.
	* tests/data/test-core-diff/report4.txt: Likewise.
	* tests/data/test-core-diff/report5.txt: Likewise.
	* tests/test-core-diff.cc: New regression test program.
	* tests/Makefile.am: Add these new files to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:03 +01:00
Dodji Seketeli
c57e950ec7 Initial writing/reading of an ABI corpus to an archive
* configure.ac: Support detection of libzip dependency. Define
        new DEPS_CFLAGS and DEPS_LIBS variables for use in
        Makefile.am to refer to the dependency headers and
        libraries.
	* doc/website/mainpage.txt: Update this to talk about the new
	libzip dependency.
	* include/Makefile.am: Add abg-libzip-utils.h to the build system.
	* include/abg-corpus.h (corps): Hide abigail::corpus's private behind a
	pimpl idiom.
	(corpus::{drop_translation_units, get_file_path, set_file_path,
	write, read}): New methods.
	* include/abg-libxml-utils.h (new_reader_from_buffer): Declare new
	function.
	* include/abg-libzip-utils.h: New file.
	* src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to
	the build system.  Refer to the library and headers dependencies
	via the new DEPS_LIBS and DEPS_CFLAGS variables.
	* src/abg-corpus.cc: New file.
	* src/abg-ir.cc (translation::set_path): New method.
	* src/abg-libxml-utils.cc (new_reader_from_buffer): Define new
	function.
	* src/abg-libzip-utils.cc: New file.
	* src/abg-reader.cc (translation_unit::read): New overload.
	* src/abg-writer.cc: Inject the names from the std namespace into
	the abigail namespace, rather than into abigail::writer.
	(abigail::translation_unit::write): New overload.  This can now
	use ofstream and the other stuff from std that are injected in the
	abigail:: namespace.
	* tests/Makefile.am: Add tests/test-write-read-archive.cc to the
	build system; use that to build runtestwritereadarchive.  Also add
	the input test data from
	tests/data/test-write-read-archive/test[0-4].xml.
	* /tests/data/test-write-read-archive/test[0-4].xml: New test
	input data files.
	* tests/test-write-read-archive.cc: New test for this archive
	write/read support.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:41 +02:00