Commit Graph

283 Commits

Author SHA1 Message Date
Dodji Seketeli
c4a29d5dd8 Do not report added/removed type_decls
* src/abg-comparison.cc (scope_diff::report): Do not report
	added/removed type_decls.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:21 +01:00
Dodji Seketeli
950bc5f402 Fix string representation for variables and methods
* src/abg-ir.cc (var_decl::get_pretty_representation): Don't use
	the pretty representation for the type of the variable; just use
	its qualified name.
	(method_type::set_class_type): I wonder what I was thinking when
	setting the first parameter's type to being the type of the
	class.  Remove this.
	(function_decl::get_pretty_representation): Use the "method "
	prefix for methods.  Avoid printing the first parameter of
	methods.  Use the qualified name of the parameter type, rather
	than its pretty representation.
	* src/abg-writer.cc (write_class_decl): Do not skip the first
	function parameter when serializing the method.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:17 +01:00
Dodji Seketeli
581ddd9c6e Support reporting removed types/decls
* include/abg-comparison.h (scope_diff::{removed_types,
	removed_decls, added_types, added_decls}): New accessor methods
	declarations.
	* src/abg-comparison.cc (scope_diff::{removed_types,
	removed_decls, added_types, added_decls}): New accessor methods
	definitions.
	(scope_diff::report): Report removed & added types/decls.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:10 +01:00
Dodji Seketeli
2e8b15871f Fix erratic reporting of changed types & decls in scopes
* src/abg-comparison.cc
	(scope_diff::ensure_lookup_tables_populated): A changed type/decl
	is not only one that has been both deleted and inserted (as is a
	type/decl with a given name N has been deleted and a type/decl
	with that same name N has been inserted), but we must also ensure
	that both inserted and deleted type/decl are not the same.
	Otherwise, it might has been a type/decl that has been shuffled
	around.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:26:36 +01:00
Dodji Seketeli
58cd876aaf Fix some class & scope diff reports formatting glitchs
* src/abg-comparison.cc (class_diff::report): Quote data members.
	(scope_diff::report): Simplify how we report changed types. Avoid
	unnecessary vertical spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:26:30 +01:00
Dodji Seketeli
8ac9973a1e Pretty representation for variables and types by default
* include/abg-ir.h (var_decl::get_pretty_representation): New
	method declaration.
	* src/abg-ir.cc (decl_base::get_pretty_representation): Prefix
	types with the "type " string.
	(var_decl::get_pretty_representation): New method definition.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:26:24 +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
259b46d88d Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
	function_decl}::get_pretty_representation): New virtual member to
	get a pretty string name for decls & types.
	(class_decl::parameter): Add an index to the parameter type.
	(class_decl::parameter::parameter): Update the constructor for the
	change above.
	(class_decl::parameter::{get_index, set_index}): Accessors for the
	new index.
	(class_decl::parameter::operator==): Take in account the index.
	(function_type::append_parameter): Set the index of the parameter
	here.
	* include/abg-fwd.h (get_type_name): New declaration.
	* src/abg-ir.cc (get_type_name): New definition.
	({decl_base, function_decl,
	class_decl}::get_pretty_representation): New implementations.
	(method_type::set_class_type): Update this to set function
	parameter's index by default.
	(function_decl::append_parameters): Use the append_parameter
	method from function_type.
	* include/abg-comparison.h (class function_decl_diff): New type
	declaration.
	* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
	New definitions.
	({pointer_diff, class_diff, scope_diff}::report): Use the new
	get_pretty_representation.  Output a prettier report.
	(function_decl_diff::priv): New type.
	(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
	ensure_lookup_tables_populated, function_decl_diff,
	first_function_decl, second_function_decl, changed_parms,
	removed_parms, added_parms, length, report}): New member function
	definitions.
	* src/abg-hash.cc (function_decl::parameter::hash): Update this to
	take the index in account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:39 +01:00
Dodji Seketeli
059bb2fbfd Misc style & white space fixes
* include/abg-fwd.h (is_global_scope, is_at_global_scope)
	(is_at_class_scope, is_at_template_scope, is_template_parameter)
	(is_type, is_var_decl, is_template_parm_composition_type)
	(is_template_decl, is_function_template_pattern)
	(add_decl_to_scope, get_global_scope, get_translation_unit):
	Remove parameter names from declarations.
	* include/abg-ir.h (decl_base::set_location): Remove useless white
	space.
	(struct type_shared_ptr_equal): Fix comment filling.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:36 +01:00
Dodji Seketeli
1adfd24e44 Avoid useless hashing during serialization
* src/abg-writer.cc (write_context::get_id_for_type): Avoid the
	useless hashing incurred by the [] operator on the map, when we
	already have the value we want.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:28 +01:00
Dodji Seketeli
b03f170d91 Add more IR nodes dumping routines
* include/abg-fwd.h (dump): Declare 4 overloads for the dumping
	routines.
	* include/abg-ir.h (var_decl_sptr): New typedef.
	* src/abg-writer.cc (dump(const decl_base_sptr)): Add comments.
	(dump(const type_base_sptr)): New dumping routines.
	(dump(const var_decl_sptr)): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:21 +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
ad0a293672 On going white space cleanups
* include/abg-ir.h: Remove useless white spaces.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:03 +01:00
Dodji Seketeli
2a0d8fa4e2 Finish reporting about class_diff
* src/abg-comparison.cc (report_num_dels_or_ins): Factorize out
	the header of each of inserted/deleted parts of the class into
	this new function.
	(class_diff::report): Use the new report_num_dels_or_ins.  Cleanup
	the code.  Add support for reporting about member functions,
	member function templates and member class templates.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:56 +01:00
Dodji Seketeli
1a647b4321 White space cleanup in abg-ir.h
* include/abg-ir.h
	(class_decl::member_function_template::member_function_template):
	Remove useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:51 +01:00
Dodji Seketeli
894df5bf01 Progress on diffing pointers, references and classes
* include/abg-comparison.h (diff::{first_subject,second_subject): Changed
	first_scope/second_scope into these; so that this diff class now works on
	stuff that are not scope.  Changed the type of these to
	decl_base_sptr
	(diff::diff): Update for the change above.
	(diff::{length, report}): New virtual pure methods.
	(class pointer_diff, reference_diff): New classes declarations.
	(compute_diff): New overloads for the new classes above.  Make the
	existing overloads take shared_pointers instead of references.
	Also make them return shared pointers of the computed diff, rather
	than just populating diff references passed in parameter.
	(class class_diff): Renamed class class_decl_diff into this.
	(report_changes): Change these functions into member functions.
	* src/abg-comparison.cc (compute_diff_for_types): New static
	function.
	(pointer_diff::pointer_diff, pointer_diff::first_pointer)
	(pointer_diff::second_pointer, pointer_diff::length)
	(pointer_diff::underlying_type_diff)
	(pointer_diff::underlying_type_diff, pointer_diff::report)
	(pointer_diff::report, compute_diff)
	(reference_diff::reference_diff, reference_diff::first_reference)
	(reference_diff::second_reference)
	(reference_diff::underlying_type_diff)
	(reference_diff::underlying_type_diff, reference_diff::length)
	(reference_diff::report, compute_diff): New functions.
	(class_diff::class_diff, class_diff::length)
	(class_diff::first_class_decl, class_diff::second_class_decl)
	(class_diff::base_changes, class_diff::base_changes)
	(class_diff::member_types_changes)
	(class_diff::member_types_changes)
	(class_diff::data_members_changes)
	(class_diff::data_members_changes, class_diff::member_fns_changes)
	(class_diff::member_fns_changes)
	(class_diff::member_fn_tmpls_changes)
	(class_diff::member_class_tmpls_changes)
	Update wrt class_decl_diff -> class_diff renaming.
	(class_diff::report): Make the report function be a member
	function.  Add an indentation parameter. Add support for member
	types and data members.
	(compute_diff): New overload for class_decl_sptr.
	(scope_diff::first_scope, scope_diff::second_scope)
	(scope_diff::length, scope_diff::report): New member functions.
	(scope_diff::{deleted_member_at, inserted_member_at}): Update wrt
	first_scope -> first_subject change.
	(compute_diff): New overload for scope_decl_sptr.
	(translation_unit_diff::report): Change the report function into
	this member function.
	(compute_diff): Change the overload for translation_unit to take a
	translation_unit_sptr rather than a reference.
	* tools/bidiff.cc (main): Update this wrt the change of the
	signature of compute_diff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:44 +01:00
Dodji Seketeli
e480399ce0 Fix construction of class_decl::member_type
* include/abg-ir.h (class_decl::member_type::member_type): Remove
	inline body from here.
	* src/abg-ir.cc (class_decl::member_type::member_type): Move
	implementation here.  Also, properly set the name of the the
	member_type at construction time.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:25 +01:00
Dodji Seketeli
8b3a227ba6 Few typedef additions to abg-ir.h
* include/abg-ir.h (pointer_type_def_sptr)
	(reference_type_def_sptr): New typedefs.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:20 +01:00
Dodji Seketeli
d1e110889c Add debugging routines for decl_base_sptr and translation_unit
* src/abg-writer.cc (dump): Add two version of this; on for
	decl_base_sptr, one for translation_unit&.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:10 +01:00
Dodji Seketeli
749611d2e8 Initial implementation of tu diffing & bidiff cmd line program
* include/abg-comparison.h (class translation_unit_diff): New type.
	(compute_diff): Make this take class_decl&, rather than
	class_decl_sptr.  Add new overloads for scope_decl& and
	translation_unit&.
	(report_changes): New overload for scope_diff& and
	translation_unit&.
	* src/abg-comparison.cc (struct class_decl_diff::priv): New type.
	(class class_decl_diff): Add comments to methods.
	(class translation_unit_diff): Implement methods.
	(compute_diff, report_changes): Implement the new overloads.
	(scope_diff::ensure_lookup_tables_populated): Fix a thinko here.
	* src/abg-ir.cc (is_var_decl): Add new predicate.
	* tools/abg-tools-utils.h (file_exists, is_regular_file)
	(check_file): Declare new functions.
	* tools/abg-tools-utils.cc (get_stat, file_exists, check_file)
	(is_regular_file): Define new functions.
	(is_dir): Use the new get_stat.
	* tools/bidiff.cc: New file.
	* tools/Makefile.am: Add tools/bidiff.cc to the build system; make it
	produce the bidiff tool.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:24:01 +01:00
Dodji Seketeli
a21e0a3442 Fix inheritance of operator== on decl_base and type_base
* include/abg-ir.h (*lots of descendants of decl_base, type_decl)
	(template_decl, class_decl::member_base): Replace the previous classical
	*::operator==(*&) with an overload of decl_base::operator==(const
	decl_base&), type_base::operator==(const type_base),
	template_decl::operator==(const template_decl&) or
	class_decl::member_base::operator==(const
	class_decl::member_base&).  This makes the descendant operator be
	the one called when a comparison involves references the parent
	class.
	* src/abg-ir.cc: Write the implementation of the above.  Remove
	the useless static_casts from the previous operator== code.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:23:50 +01:00
Dodji Seketeli
5f2b66d22e On going misc white spaces and style fixes
* include/abg-ir.h: Add author.  Remove many useless white
	spaces.  Add missing end-of-class comments.  Move function
	declaration comments from here to their definition point.
	* include/abg-fwd.h: Remove useless indentation.  Also move
	doxygen comments to *definition* points in src/abg-ir.cc.
	* src/abg-ir.cc: Remove many useless white spaces.  Move comments
	from declaration points to here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:23:12 +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
6e590b2a45 Initial un-debugged implementation of scope diffing
* include/abg-comparison.h (class scope_diff): New type.
	(compute_diff(scope_decl_sptr, scope_decl_sptr, scope_diff)): New
	declaration.
	(report_changes): New declaration.
	* src/abg-comparison.cc (struct scope_diff::priv): Define.
	(scope_diff::{clear_lookup_tables, lookup_tables_empty,
	ensure_lookup_tables_populated, scope_diff, member_changes,
	deleted_member_at, inserted_member_at, changed_types,
	changed_decls}): Define these new member functions.
	(compute_diff): Define.
	* include/abg-ir.h (decl_base_sptr): New typedef.
	(operator==(decl_base_sptr, decl_base_sptr)): Declare new
	operator.
	* src/abg-ir.cc (operator==(decl_base_sptr, decl_base_sptr)):
	Define.
	(scope_decl::{operator==, traverse}): Adjust for using vectors to
	store scope members now, rather than lists.
	(scope_decl::{declarations, scopes}): Make these types be vector.
	This makes the members of a scopes be vector, rather than lists.
	This enables them to be diffed.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:22:45 +01:00
Dodji Seketeli
dca9690970 Simplify & cleanup compute_diff core api
* include/abg-diff-utils.h (insertion::inserted_): Changed the
	type of this from vector<int> to vector<unsigned>.
	(insertion::{insertion, inserted_indexes}): Adjust.
	(compute_diff): Add two new simpler overloads.  Implement them in
	term of the former more complex overload.
	(compute_lcs): Adjust for the vector<int> -> vector<unsigned>
	change.
	* src/abg-diff-utils.cc (compute_lcs, compute_ses): Adjust for the
	compute_diff change above.
	* src/abg-comparison.cc (compute_diff, report_changes): Adjust for
	the compute_diff & vector<unsigned> changes above..

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:22:05 +01:00
Dodji Seketeli
63587eca30 Misc white space, style and comments cleanup
* include/abg-ir.h (class scope_decl): Add end of class comment.
	(class type_base): Add a _sptr typedef and end of class comment.
	* src/abg-ir.cc (operator==(class_decl_sptr, class_decl_sptr)):
	Fix comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:21:53 +01:00
Dodji Seketeli
eb6339835f Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
	declaration.
	(class_decl::{base_specs, member_types, data_members,
	member_functions, member_function_templates,
	member_class_templates}): Make all these containers be vectors,
	rather than list.  This makes these containers (like
	class_decl::base_specs, class_decl::member_types, etc) be suitable
	to be used by the core diffing algorithms to diff their content.
	(operator==(class_decl_sptr, class_decl_sptr))
	(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
	(operator==(class_decl::base_spec_sptr,
	            class_decl::base_spec_sptr))
	(operator==(class_decl::data_member_sptr,
	            class_decl::data_member_sptr))
	(operator==(class_decl::member_function_sptr,
	            class_decl::member_function_sptr))
	(operator==(class_decl::member_function_template_sptr,
	            class_decl::member_function_template_sptr))
	(operator==(class_decl::member_class_template_sptr,
		    class_decl::member_class_template_sptr)): Declare
	these new equality operators.  These are to be used by the core
	diffing algorithms when comparing two vectors of shared pointers
	of members of class_decls.
	* src/abg-ir.cc (decl_base::get_qualified_name): Define.
	(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
	containers type change to a vector.
	(operator==(class_decl_sptr, class_decl_sptr))
	(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
	(operator==(class_decl::base_spec_sptr,
	            class_decl::base_spec_sptr))
	(operator==(class_decl::data_member_sptr,
	            class_decl::data_member_sptr))
	(operator==(class_decl::member_function_sptr,
	            class_decl::member_function_sptr))
	(operator==(class_decl::member_function_template_sptr,
	            class_decl::member_function_template_sptr))
	(operator==(class_decl::member_class_template_sptr,
		    class_decl::member_class_template_sptr)): Define
	these.
	* include/abg-comparison.h (diff::scope_): Remove
	(diff::{first_scope_, second_scope_}): New members.
	(class_decl_diff::class_decl_diff): Pass the new scopes to this
	constructor.
	(class_decl_diff::{first_class_decl, second_class_decl})
	(report_changes): New declarations.
	* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
	as per the declaration.
	(class_decl_diff::{first_class_decl, second_class_decl}): Define
	as per the declaration.
	(compute_diff): Initial implementation for this.
	(report_changes): Define.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:21:37 +01:00
Dodji Seketeli
9b89a16a8b Change the diff::changes_type back to just edit_script
* include/abg-comparison.h (diff::changes_type):
	Remove this typedef.
	(class_decl_diff::data_members_changes): Rename
	class_decl_diff::data_member_changes into this.
	(class_decl_diff::member_fn_tmpls_changes): Renamed
	class_decl_diff::member_fn_tmpl_changes into this.
	(class_decl_diff::member_class_tmpls_changes): Renamed
	class_decl_diff::member_class_tmpl_changes into this.
	(class_decl_diff::{base_changes, member_types_changes,
	data_members_changes, member_fns_changes, member_fn_tmpls_changes,
	member_fn_tmpls_changes, member_class_tmpls_changes}): Adjust
	these declarations for the use of edit_script.
	* src/abg-comparison.cc (class_decl_diff::priv::*): Likewise.
	(class_decl_diff::{base_changes, member_types_changes,
	data_members_changes, member_fns_changes, member_fn_tmpls_changes,
	member_fn_tmpls_changes, member_class_tmpls_changes}): Adjust
	these definitions for the above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:21:11 +01:00
Dodji Seketeli
b92e29a396 Misc white space, style and comment fixes
* include/abg-ir.h: Lots of useless white space removals and
	comments adding.
	(class class_decl::member_base): Fix comment.
	* src/abg-hash.cc: Lots of useless white space removals too.
	* src/abg-ir.cc: Remove useless white space too.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:28 +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
fd8f8f1af2 Initial command line testing facility for core diff algorithms
* tests/test-diff2.cc: New command line testing facility.
	* tests/Makefile.am: Add this to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:51 +01:00
Dodji Seketeli
0b199ebe03 Fix core diff algorithms for negative deltas
* diff2.h (point::point): New copy constructor.
	(point::{operator+=, operator=}):  Use point::set.
	(point::{operator--, operator++,}): New operators.
	(d_path_vec::{a_size_, b_size_}): New members.
	(d_path_vec::max_d_): Remove this member.
	(d_path_vec::max_d): Compute this, now that max_d_ was removed.
	(point_is_valid_in_graph): Declare this new function.
	(end_of_fr_d_path_in_k, ): Return
	a bool when the end of furthest reaching past found is within the
	bounds of the edit graph.  Add comments.
	(end_of_frr_d_path_in_k_plus_delta): Likewise.  Also, delta can be
	negative; support that.  Do not cross the boundaries of the edit
	graph when following a diagonal edge.
	(find_last_snake_in_path): New function.
	(compute_middle_snake): Make forward/reverse d_path_vec be big
	enough to hold paths for M+N differences.  Normally M+N/2 should
	be enough, but we were getting weird out of bound errors.  Let's
	handle it this way for now.  Do not require that we check for
	overlap only when we are on a diagonal edge.  Once we detected an
	overlap, use the new find_last_snake_in_path to find the
	boundaries of the snake.
	(ses_len): Delta can be negative.
	(display_edit): Small minor English nit.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:34 +01:00
Dodji Seketeli
f54ad28548 Lay down the foundations of computing the diff between two class_decl
* include/abg-diff-utils.h: New file.
	* src/abg-diff-utils.cc: Likewise.  Implement the code diffing
	algorithms from Eugene Myers.
	* include/abg-comparison.h: New file. First short at defining the
	basic APIs to compute the diff of two classes.
	* src/abg-comparison.cc: New file.  Start the implementation of
	the above header.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:21 +01:00
Dodji Seketeli
628911ee5f Prepare node visitors to be usable on things other than IR nodes
* include/abg-fwd.h (node_visitor_base): Renamed ir_node_visitor
	into this.
	* include/abg-traverse.h (struct node_visitor_base): New base for
	the visitors.
	(struct traversable_base): Update comments.
	(traversable_base::traverse): Change this into non-pure virtual.
	Make it take a reference to node_visitor_base, rather than a
	reference to ir_node_visitor.
	* src/abg-traverse.cc (traversable_base::traverse): New empty
	default implementation.
	* include/abg-ir.h: Make ir_node_visitor inherit from new
	node_visitor_base.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:12 +01:00
Dodji Seketeli
23d69b405c Renamed data members from m_something to something_
* src/abg-ir.{cc,h}: Renamed data members from m_something to
	something_ and update their usage.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:18:26 +01:00
Dodji Seketeli
0d738e2b95 Initial version of an archive manipulation program: biar
* tests/test-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Move these directories manipulation
	utilities from here to ...
	* tools/abg-tools-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Declare these new functions.
	* tests/test-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Likewise, move these to ...
	* tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Define these.
	* tools/Makefile.am: New file.  Create a new libtoolsutils.la
	static library with stuff from tools/abg-tools-utils.cc in it.
	Also create a new 'biar' program with the stuff from the new
	tools/biar.cc in it.
	* tools/biar.cc: New file.  Contains the code for the new "biar"
	archive manipulation command line utility.
	* tests/test-read-write.cc (main): Adjust for the change about
	ensure_parent_dir_created above.
	* tests/test-write-read-archive.cc (main): Likewise.
	* Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the
	build system.
	* configure.ac (AC_CONFIG_FILES): Generate tools/Makefile.
	* tests/Makefile.am: Make libtestutils.la link with the new
	libtoolsutils.la.  Make sure to express the dependencies between
	libtestutils.la and the binaries that depend on it.  Otherwise
	parallel builds can go awry.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 17:08:47 +02:00
Dodji Seketeli
0b8a16ef39 Define translation_unit{_sptr,s} types in abigail::
* include/abg-corpus.h (abigail::corpus::{translation_unit_sptr,
	translation_units):  Do not define these typedefs here.  Rather)
	(define them ...
	* include/abg-ir.h
	(abigail::{translation_units,translation_unit_sptr): ... here.
	This is because a translation unit can be manipulated
	independently from an abi corpus.
	* src/abg-corpus.cc (corpus::get_translation_units): Adjust return
	type to comply with the change above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 16:45:55 +02:00
Dodji Seketeli
4989519a33 Fix header inclusion in abg-corpus.h
* include/abg-corpus.h: Drop incomplete abg-traverse.h and
	abg-fwd.h.  Use abg-ir.h proper and be done with it.  Users of the
	library will just have to use abg-corpus.h to manipulate and the
	archives and the IR they contain.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 16:38:24 +02:00
Dodji Seketeli
b9577015df Add error message to translation_unit::write
* src/abg-writer.cc (translation_unit::write): Add an error
	message to stderr if something ultimately went wrong.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 16:36:17 +02:00
Dodji Seketeli
5767379648 Rename abigail::corpus::{get_file_path --> get_path}
* include/abg-corpus.h (corpus::{get_path, set_path): Renamed
	corpus::get_file_path and corpus::set_file_path into these as
	get_path/set_path is what is used elsewhere as well.
	* src/abg-corpus.cc (corpus::{get_path, set_path}): Likewise.
	* tests/test-write-read-archive.cc (main): Adjust for the change
	above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 16:29:25 +02:00
Dodji Seketeli
67ff0340be Cleanup src/Makefile.am
* src/Makefile.am: Fix library naming and remove useless trailing
	space from directory path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 16:23:41 +02: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
Dodji Seketeli
8884b58638 Fix & add missing API documentation
* src/abg-ir.cc (location_manager::create_new_location): Fix
	documentation comment.  (translation_unit::translation_unit)
	(translation_uni::get_global_scope, translation_unit::get_path)
	(translation_unit::traverse, translation_unit::get_loc_mgr)
	(translation_unit::is_empty, translation_unit::traverse): Add
	missing documentation comments.
	* src/abg-libxml-utils.cc (new_reader_from_file): Fix comment.
	* src/abg-reader.cc (translation_unit::read): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:41 +02:00
Dodji Seketeli
ea129b5a7c Remove useless header inclusion
* include/abg-traverse.h: Remove useless #include <tr1/memory>

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:40 +02:00
Dodji Seketeli
e90467e69b Misc white space cleanups
* include/abg-corpus.h: Cleanup white spaces.
	* include/abg-fwd.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:40 +02:00
Dodji Seketeli
6a2204fa0d Small cleanup in abg-config.cc
* src/abg-config.cc: Include auto-generated
	$(top_builddir)/config.h file.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:40 +02:00
Dodji Seketeli
81c496dfe3 Pass absolute paths to the compiler during the build
* src/Makefile.am: Pass absolute file paths to the compiler during
	the build.  This helps in e.g in emacs' compilation mode, when the
	output shows an error reported by GCC's diagnostics, setting point
	to the error line and hitting 'enter' transports the user to the
	file location where the error happened; as the file path is nows
	absolute, emacs can always find it.  Otherwise, finding it depends
	on $PWD and whatnot.
	* tests/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:00 +02:00
Dodji Seketeli
10ed52ca7c Misc cleanups in abg-fwd.h
* include/abg-fwd.h: Move location, location_manager and
	translation_unit in the ir section.  Remove stuff that was
	commented out anyway.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:27:35 +02:00
Dodji Seketeli
6d5f7c1223 Move location, location_manager & translation_unit back into abg-ir.h
* include/abg-corpus.h: Move location location_manager,
	translation_unit from here ...
	* include/abg-ir.h: ... to here.  The reason being that these are
	really constructs of the Internal Representation of the ABI/API of
	a translation unit.  What is left in abg-corpus is really
	exclusively related to an ABI Corpus, which I see more as a
	"packaging" construct that abstracts the bundling of several
	translation units together.  Also, I fixed some comments about the
	location/location_manger types; now a location is made specific to
	a translation unit; to an abi corpus.  A location of a given
	translation unit has to be decoded by the location manager of that
	same translation unit.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:21:26 +02:00