Commit Graph

216 Commits

Author SHA1 Message Date
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
bd1af4cd52 Initial support of reading an ABI Corpus from DWARF
* configure.ac: Check the presence of libdw.so and
	elfutils/libdwfl.h headers from elfutils and define the necessary
	linking flags.
	* include/abg-dwarf-reader.h: New header file
	* include/Makefile.am: Add the new header file to the source
	distribution.
	* src/abg-dwarf-reader.cc:: New file.
	* src/Makefile.am: Add the new file to the source distribution.
	* include/abg-fwd.h (dump): Add declarations for several overloads
	to allow dumping to a given output stream.
	* include/abg-ir.h (class translation_unit): Use a pimpl idiom for
	this now.
	(translation_unit::canonicalize_type): Declare new method.
	* src/abg-ir.cc (struct translation_unit::priv): New private type
	for the pimpl idiom for translation_unit.
	(translation_unit::{translation_unit, get_global_scope, get_path,
	set_path, get_loc_mgr}): Adjust for pimpl idiom.
	(translation_unit::canonicalize_type): Define this new method and
	one overload.
	* src/abg-writer.cc (dump): Define several overloads to dump IR
	nodes to given output streams.
	* tools/bidw.cc: New file for the new bidw tool.
	* tools/Makefile.am: Define rules to build the new bidw tools.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 08:07:54 +01:00
Dodji Seketeli
96fba7d95f Pass a string by reference rather than by value
* tools/bilint.cc (display_usage): Pass program name by reference.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 07:26:06 +01:00
Dodji Seketeli
98681a9327 Misc style fixes
* src/abg-ir.cc (location_manager::location_manager)
	(translation_unit::{is_empty, traverse, ~translation_unit): Remove
	useless vertical white spaces.
	* tools/bilint.cc (parse_command_line): Fix indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-07 07:22:57 +01:00
Dodji Seketeli
6258b5f824 Prepare serialization API for multiple backends
* include/abg-reader.h: New file with abigail::xml_reader APIs.
	* include/abg-writer.h: New file with abigail::xml_writer APIs.
	* include/Makefile.am: Add the new files above to the source
	distribution.
	* src/abg-reader.cc: Update top-file comments.
	(namespace xml_reader): Rename namespace
	reader into this.
	(read_to_translation_unit, read_corpus_from_archive): New static
	functions.
	(read_translation_unit_from_file)
	(read_translation_unit_from_file, read_corpus_from_file): New
	entry points.
	(struct array_deleter): New functor.
	(translation_unit::read): Remove this.
	* src/abg-writer.cc: Update top file comments.
	(namespace xml_writer): Rename namespace
	writer into this.
	(struct archive_write_ctxt): New internal type.
	(create_archive_write_context, write_translation_unit_to_archive)
	(write_translation_unit, write_corpus_to_archive): New low level
	static functions overloads.
	(write_corpus_to_archive, write_translation_unit): Public higher
	level overloads.
	(translation_unit::write): Remove.
	(dump): Update for new xml_writer namespace.
	* include/abg-ir.h (translation_unit::{read, write}): Remove these
	serialization methods.
	* include/abg-corpus.h (corpus_sptr): New convenience typedef.
	(corpus::{read, write}): Remove these methods.
	* src/abg-corpus.cc (corpus::{read, write})
	(corpus::impl::{serialized_tus, archive}): Remove these members.
	(corpus::impl::{get_archive, close_archive, write_tu_to_archive,
	read_to_translation_unit}): Remove these methods.
	* tests/test-bidiff.cc (main): Update for usage of the new
	xml_reader API.
	* tests/test-read-write.cc (main): Likewise. Update for the usage
	of the new xml_writer API, too.
	* tests/test-walker.cc (main): Update for the usage of the new
	xml_reader API.
	* tests/test-write-read-archive.cc (main): Likewise.  And for the
	xml_writer API, too.
	* tools/biar.cc (add_tus_to_archive, extract_tus_from_archive): Likewise.
	* tools/bidiff.cc (main): Likewise, for xml_reader APIs.
	* tools/bilint.cc (main): Likewise, for xml_writer APIs, too.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-04 20:26:38 +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
d8882b850c Add missing test inputs to source distribution
* tests/Makefile.am (data/test-read-write/test{17, 18, 19, 20,
	21}.xml): Add these test input files to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-29 13:37:58 +01:00
Dodji Seketeli
0d9ade8ce8 Add diff support for var_decl
* include/abg-comparison.h (class var_diff): New declaration.
	(var_diff_sptr): New convenience typedef.
	(compute_diff): New overloads for var_diff, decl_base and
	type_base.
	* src/abg-comparison.cc (try_to_diff): Renamed try_to_diff_types
	into this.
	(compute_diff_for_types): Adjust for the try_to_diff_types
	renaming.  Fix comments.
	(compute_diff_for_decls): Re-use try_to_diff.  Update for
	var_decl.
	(compute_diff): Define overloads for decl_base, type_base and
	var_decl.
	(diff_length_of_decl_bases, diff_length_of_type_bases): New static
	help functions.
	(report_name_size_and_alignment_changes): Renamed
	report_size_and_alignment_changes into this.  Make it report name
	changes as well.
	(var_diff::priv): New struct.
	(var_diff::{var_diff, first_var, second_var, type_diff, length,
	report}): Define methods.
	({qualified_type_diff, enum_diff, class_diff, scope_diff,
	function_decl_diff}::report): Do not report
	anything if the diff is empty.
	(type_decl_diff::length): Fix this.
	(type_decl_diff::report): Adjust for renaming to
	report_name_size_and_alignment_changes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-28 15:05:30 +01:00
Dodji Seketeli
0b0dd479d1 Add enum_type_decl::get_pretty_representation()
* include/abg-ir.h (enum_type_decl::get_pretty_representation):
	Declare new virtual method override.
	* src/abg-ir.cc (enum_type_decl::get_pretty_representation):
	Define it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-28 14:58:11 +01:00
Dodji Seketeli
2e704277e7 Change return type of abigail::is_type()
* include/abg-fwd.h (is_type): Change the return type from bool to
	type_base_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-28 14:51:23 +01:00
Dodji Seketeli
d186189b43 Support diff for enum_type_decl
* include/abg-ir.h (enum_type_decl_sptr): New typedef.
	(enum_type_decl::enumerator::enumerator): Make default constructor
	public so that enumerators can be stored in vectors.  Maybe I
	should have made stored pointers to enumerators instead ...
	(enum_type_decl::enumerator::get_qualified_name): Define new
	method.
	* include/abg-comparison.h (string_enumerator_map)
	(changed_enumerator, string_changed_enumerator_map)
	(enum_diff_sptr): New convenience typedefs.
	(class enum_diff): Declare new class.
	(compute_diff): New overload for enum_type_decl.
	* src/abg-comparison.cc (enum diff_kind, report_mem_header): Move
	these at the beginning of the file.
	(struct enum_diff::priv): Define this.
	(enum_diff::{clear_lookup_tables, lookup_tables_empty,
	ensure_lookup_tables_populated, enum_diff, first_enum,
	second_enum, underlying_type_diff, deleted_enumerators,
	inserted_enumerators, changed_enumerators, length, report}):
	Define these new methods.
	(compute_diff): New overload for enum_diff.
	(compute_diff_for_types): Add support enum_type_decl here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-27 11:47:19 +01:00
Dodji Seketeli
cb05c8b3d9 Fix equality operator for enum_type_decl
* src/abg-ir.cc (enum_type_decl::operator==(const type_base& o)):
	This was comparing just the decl_base and type_base part of the
	enum.  Now re-use the enum_type_decl::operator==(const decl_base)
	that compares the entirety of the types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-27 11:41:51 +01:00
Dodji Seketeli
2340e94a6f Fix indentation and wording of some existing diff reports
* src/abg-comparison.cc (class_diff::report): Fix report wording.
	Change indentation space from 4 white spaces to two.
	(scope_diff::report): Fix logic indentation generation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-27 10:51:59 +01:00
Dodji Seketeli
abfc86ca6a Change enum_type_decl::enumerators from a list to a vector
* include/abg-ir.h (enum_type_decl::enumerators): Change this from
	a list to a vector.
	* src/abg-hash.cc (enum_type_decl:#️⃣:operator()): Use the
	typedef enum_type_decl::enumerators rather than std::list<blah>.
	* src/abg-ir.cc (enum_type_decl::get_enumerators): Use
	the enum_type_decl::enumerators typedef.
	(enum_type_decl::operator==): Likewise.
	* src/abg-reader.cc (build_enum_type_decl): Likewise.
	* src/abg-writer.cc (write_enum_type_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-26 09:30:22 +01:00
Dodji Seketeli
6f897574f6 Fix thinko in qualified_type_diff::length
* src/abg-comparison.cc (qualified_type_diff::length): Fix thinko.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-25 23:29:36 +01:00
Dodji Seketeli
5ac1090324 Support diff between qualified types
* include/abg-ir.h (qualified_type_def_sptr): Declare new typedef.
	(class qualified_type_def): Add comment at the end.
	(operator<<(std::ostream&, qualified_type_def::CV)): Declare new
	streaming operator.
	* src/abg-ir.cc (operator<<(std::ostream&,
	qualified_type_def::CV)): Define this new streaming operator.
	* include/abg-comparison.h (class qualified_type): Declare new
	class.
	(compute_diff): Declare new overload for qualified_type_def_sptr.
	* src/abg-comparison.cc (struct qualified_type_diff::priv): Define
	new type.
	(qualified_type_diff::{qualified_type_diff, first_qualified_type,
	second_qualified_type, underlying_type_diff, length}):
	Define new methods.
	(get_leaf_type): Define new static function.
	(compute_diff): Define overload for qualified_type_def_sptr.
	(compute_diff_for_types): Add support for
	diffing qualified_type_def here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-25 23:25:13 +01:00
Dodji Seketeli
f2a44cebe1 Cleanup header of changes of underlying types of pointers/references
* src/abg-comparison.cc ({pointer_diff, reference_diff}::report):
	Unify header of changes in the referenced type.
	* src/abg-ir.cc (decl_base::get_pretty_representation): By
	default, do not prefix types with "type ", for consistency sake.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-25 23:25:13 +01:00
Dodji Seketeli
76a6b8b5bc Ensure diff types can only be created by compute_diff
* include/abg-comparison.h (diff::diff): Make constructor
	protected.
	(pointer_diff::pointer_diff): Likewise.
	(pointer_diff::{first_pointer, second_pointer}): Constify the
	return type.
	(compute_diff): Make this a friend of class pointer_diff.
	(reference_diff::reference_diff): Make this constructor protected.
	(compute_diff): Make this a friend of class reference_diff.
	(class_diff::class_diff): Make this constructor protected.
	(compute_diff): Make this a friend of class class_diff.
	(scope_diff::scope_diff): Make this constructor protected.
	(compute_diff): Make this a friend of class scope_diff.
	(function_decl_diff::function_decl_diff): Make this constructor
	protected.
	(type_decl_diff::type_decl_diff): Likewise.
	(typedef_diff::typedef_diff): Likewise.
	(translation_unit_diff::translation_unit_diff): Likewise.
	(compute_diff): Make this a friend of class translation_unit_diff.
	* src/abg-comparison.cc (pointer_diff::{first_pointer,
	second_pointer}): Constify return type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-25 23:25:05 +01:00
Dodji Seketeli
7b76446f04 Add size/alignment info to class diff report
* src/abg-comparison.cc (represent): Move these static overloads
	to the beginning of the file.
	(report_size_and_alignment_changes): New function.  It has been
	factorized out of ...
	(type_decl_diff::report): ... this.
	(class_diff::report): Use the new
	report_size_and_alignment_changes to report size/alignment info
	for classes.
2013-11-21 15:50:34 +01:00
Dodji Seketeli
77d6e638ff Style fix
* src/abg-comparison.cc (class_diff::report): Rename first_class
	into first and second_class into second.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-21 15:48:47 +01:00
Dodji Seketeli
d0de718c14 Misc diff reporting nits
* include/abg-ir.h (type_decl::get_pretty_representation): New
	overload.
	* abg-ir.cc (type_decl::get_pretty_representation): Implement it.
	* src/abg-comparison.cc (represent, class_diff::report): Quote the
	pretty representation of abi artifacts in the report.
	(type_decl_diff::report): Better wording to express type_decl
	change.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-21 15:41:39 +01:00
Dodji Seketeli
663c455521 Support reporting changed data member in class
* include/abg-ir.h (operator<<(std::ostream&, decl_base::binding))
	(operator<<(std::ostream&, class_decl::access_specifier)): Declare
	new streaming operators.
	(class_decl::member_type::get_pretty_representation): New virtual
	overload.
	* src/abg-ir.cc (operator<<(std::ostream&, decl_base::binding)):
	(operator<<(std::ostream&, class_decl::access_specifier)): Define
	new streaming operators.
	(class_decl::member_type::get_pretty_representation): Define new method.
	* src/abg-comparison.cc (represent): Make the existing overloads
	end by a newline. Add a new overload that represents the changes
	that happened a given data member.
	(enum diff_kind): New.
	(report_mem_header): Renamed report_num_dels_or_ins into this.
	Make it support introducing changed members as well as
	deletions/insertions.
	(class_diff::report): Adjust for the report_num_dels_or_ins ->
	report_mem_header change.  Use the new represent() overload to
	report about changed data members.  Adjust logic now that
	represent() emits a newline at its end.  Also adjust logic as far
	as representing base classes and member types changes is
	concerned.
	(type_decl_diff::report): Remove useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-20 19:27:36 +01:00
Dodji Seketeli
c1274d3db1 Ensure that *::report adds just one empty line to its content
* include/abg-comparison.h (diff::report): Add a comment saying
	that each the diff::report interface must leave one empty line at
	the end of the report.
	* src/abg-comparison.cc ({pointer_diff, reference_diff,
	class_diff, scope_diff, function_decl_diff, type_decl_diff,
	typedef_diff}::report): Leave just one
	empty line after content.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-20 12:47:29 +01:00
Dodji Seketeli
e78cf50a39 Various doxygen doc additions and fixes
* include/abg-comparison.h: Lots of doc string additions & fixes,
	especially for typedefs.
	* include/abg-ir.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-ir.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-20 10:54:15 +01:00
Dodji Seketeli
1473506850 Better support changed base classes and member types
* include/abg-comparison.h (class_diff::{clear_lookup_tables,
	lookup_tables_empty, ensure_lookup_tables_populated}): Declare new
	methods.
	(compute_diff): Make this a friend of class_diff.
	* src/abg-comparison.cc (class_diff::priv::{deleted_bases_,
	inserted_bases_, changed_bases_, deleted_member_types_,
	inserted_member_types_, changed_member_types_,
	deleted_data_members_, inserted_data_members_,
	changed_data_members_, deleted_member_class_tmpls_,
	inserted_member_class_tmpls_, changed_member_class_tmpls_}):
	Define new members.
	(class_diff::priv::{base_has_changed, member_type_has_changed,
	data_member_has_changed}): Declare and define new methods.
	(class_diff::{clear_lookup_tables, lookup_tables_empty,
	ensure_lookup_tables_populated}): Define new methods.
	(class_diff::report): Detect and report when a base class or a
	member type has changed, as opposed to just saying that it has
	been removed and inserted.  Fix the rest of the function to avoid
	emitting useless vertical space and avoid saying that the class
	has "zero" insertion/deletion of a given kind of member.
	(scope_diff::report): avoid saying that the scope has "zero"
	insertion/deletion of a given kind of member.  Avoid useless
	vertical spaces.
	(type_decl_diff::report): Avoid useless vertical spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-20 09:34:54 +01:00
Dodji Seketeli
80b753e85d Add bilint tool to validate bi files somewhat.
* tools/bilint.cc: New file.
	* tools/Makefile.am: Build and install the new file above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:04 +01:00
Dodji Seketeli
1cdc283b1d Add diff support for typedef_decl and type_decl
* include/abg-ir.h (operator<<(std::ostream&,
	decl_base::visibility)): Declare new streaming operator.
	* src/abg-ir.cc (operator<<(std::ostream&,
	decl_base::visibility)): Define it.
	(type_decl::{operator==, get_pretty_representation}): Likewise,
	define these new overloads.
	(decl_base::{operator==, get_pretty_representation}): New overloads.
	* include/abg-comparison.h (type_decl_diff type_decl_diff_sptr,
	typedef_diff, typedef_diff_sptr): Declare new classes and
	typedefs.
	* src/abg-comparison.cc (type_decl_diff::{type_decl_diff,
	first_type_decl, second_type_decl, length, report}): New methods
	definitions.
	(compute_diff): New function definition that takes pointers of
	type_decl.
	(typedef_diff::{typedef_diff, first_typedef_decl,
	second_typedef_decl, underlying_type_diff, length, report}): New
	methods.
	(compute_diff): New function definition that takes pointers of
	typedef_decl.
	(try_to_diff_types): New template function, factorized out of ...
	(compute_diff_for_types): ... this.  Add support diffing type_decl
	and typedef_decl.
	(pointer_diff::report): Fix indentation of emitted report.
	* tools/bidiff.cc (parse_command_line): Fix style.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:00 +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
e34a610c2e Avoid tabs and add const/virtual/offsets to class member diff reports
* include/abg-ir.h (class_decl::get_num_virtual_functions): New
	declaration.
	* src/abg-ir.cc (class_decl::get_num_virtual_functions): New
	definition.
	(function_decl::get_pretty_representation): Represent
	destructors and const member functions.
	* src/abg-writer.cc (write_cdtor_const_static): Take a new bool
	parm for constness and serialize it.
	(write_class_decl): Serialize member functions & function template
	const-ness.
	* src/abg-reader.cc (read_cdtor_const): Read the "const" xml
	attribute, rather than "is_const".

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:44 +01:00
Dodji Seketeli
3dcf52e7a6 Fix num insertions reporting in member functions
* src/abg-comparison.cc (class_diff::report): Fix num insertions
	reporting.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:36 +01:00
Dodji Seketeli
2095a79319 Serialize vtable offset for virtual functions
* include/abg-ir.h
	(class_decl::member_function::get_vtable_offset): Renamed
	class_decl::member_function::get_vtable_offset_in_bits into this.
	The offset is an index into a table; it's not a value in bits.
	* src/abg-hash.cc (class_decl::member_function::hash): Update wrt
	function name change above.
	* src/abg-ir.cc (class_decl::member_function::operator==):
	Likewise.
	* src/abg-reader.cc (build_class_decl): Rename the attribute
	vtable-offset-in-bits into vtable-offset.
	* src/abg-writer.cc (write_voffset): New function.
	(write_class_decl): Use the new write_voffset.  Cleanup.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:32 +01:00
Dodji Seketeli
d506105c68 White space and style fixes
* include/abg-ir.h (class_decl::member_function::member_function):
	Align function parameters.
	* src/abg-ir.cc (type_decl::operator==): Remove useless white spaces

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:27:27 +01:00
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