Commit Graph

391 Commits

Author SHA1 Message Date
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
9291712259 Fix typos in the test-diff-dwarf.cc source code
* tests/test-diff-dwarf.cc: Fix various typos.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-29 09:58:08 +01:00
Dodji Seketeli
802f7cbc92 Initial implementation of diff tree node filtering
* include/abg-comp-filter.h: New file.
	* include/Makefile.am: Add the new include/abg-comp-filter.h to
	the source distribution.
	* include/abg-comparison.h (enum visiting_kind, diff_category): New enums.
	(operator|): Declare new operator declaration for the new
	visiting_kind enum.
	(operator{|,^,&,~}): Declare new operator decl for the new
	diff_category enum.
	(diff_context::{get_allowed_category, set_allowed_category,
	switch_categories_on, switch_categories_off, diff_filters,
	add_diff_filter, maybe_apply_filters}): Declare new member functions.
	(diff::{parent_, category_}): New members.
	(diff::diff): Adjust.
	(diff::{get_parent, set_parent, get_category, add_to_category,
	is_filtered_out, to_be_reported}):  New members.
	(diff_node_visitor::{get_visiting_kind, set_visiting_kind}): New
	members.
	(diff_node_visitor::visit): Add a new flag to saying if the
	visitor is being called in post or pre children traversing mode.
	* src/abg-comparison.cc (operator|): Declare new operator
	declaration for the new visiting_kind enum.
	(operator{|,^,&,~}): Declare new operator decl for the new
	diff_category enum.
	(diff_context::priv::{allowed_category_, filters_}): New members.
	(diff_context::diff_context): Add all known filters.
	(diff_context::{get_allowed_category, set_allowed_category,
	switch_categories_on, switch_categories_off, diff_filters,
	add_diff_filter, maybe_apply_filters}): Define new member
	functions.
	(diff::{is_filtered_out, to_be_reported}): Define new members.
	(*::report): Use the new diff::to_be_reported function.
	(*::traverse): Adjust for pre/post visiting.
	(var_diff::var_diff): Chain the type diff node to its parent.
	({pointer_diff, reference_diff, qualified_type_diff,
	typedef_diff}::underlying_type_diff): Chain the underlying type
	diff node to its parent.
	(enum_diff::enum_diff): Likewise.
	(base_diff::underlying_class_diff): Likewise.
	({class_diff, corpus_diff}::report): Do not report changed
	(member) functions that have been filtered out.  Rather report
	that they have been filtered out.
	({function_decl_diff, class_diff}::traverse): Chain underlying
	type diff nodes to their parent.
	(diff_node_visitor::visit): Add a new flag to saying if the
	visitor is being called in post or pre children traversing mode.
	Make sure to call the default diff::visit overload.
	* src/abg-comp-filter.cc: New file.
	* src/Makefile.am: Add the new abg-comp-filter.cc to the source
	distribution.
	* tools/bidiff.cc (options::show_harm{ful,less}_changes): New
	members.
	(display_usage): Add usage strings for --no-harmless and
	--no-harmful options.
	(parse_command_line): Parse --no-harmless and --no-harmful command
	line options.
	(set_diff_context_from_opts): Populate the diff context
	accordingly.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:18 +01:00
Dodji Seketeli
d2ffdbffca Add missing headers double inclusion guards
* include/abg-comparison.h: Add a missing double inclusion guard.
	* include/abg-diff-utils.h: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:18 +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
7eecfa8a0c Fixlets in the bidiff regression testing harness
* tests/test-bidiff.cc (main): Fix a typo.  Fix the path to the
	output path.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:17 +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
29036c19ce Rename test-walker.cc into test-ir-walker.cc
* tests/test-ir-walker.cc: Renamed test-walker.cc into this.
	* tests/Makefile.am: Adjust.  The generated binary is now testirwalker.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:17 +01:00
Dodji Seketeli
9186de3dec Initial diff tree traversal infrastructure
* include/abg-comparison.h (struct diff_traversable_base, struct
	diff_node_visitor): New type.
	(class diff): Extends the new diff_traversable_base.
	({diff, distinct_diff, var_diff, pointer_diff, reference_diff,
	qualified_type_diff, enum_diff, class_diff, base_diff, scope_diff,
	function_decl_diff, type_decl_diff, typedef_diff,
	translation_unit_diff, corpus_diff}::traverse): New methods.
	(function_decl_diff::return_type_diff): New accessor.  Renamed
	return_diff into this.
	(translation_unit_diff::{first, second}_translation_unit): New
	accessors.
	(corpus_diff::{deleted, added, changed}_functions): New accessors.
	* src/abg-comparison.cc ({distinct_diff, var_diff,
	pointer_diff, reference_diff, qualified_type_diff, enum_diff,
	class_diff, base_diff, scope_diff, function_decl_diff,
	type_decl_diff, typedef_diff, translation_unit_diff,
	corpus_diff}::traverse): New function implementations.
	(maybe_report_diff_for_member): Renamed
	maybe_report_diff_for_class_members into this.
	(var_diff::report): Adjust.
	(struct translation_unit_diff::priv): New private type.
	(translation_unit_diff::translation_unit_diff): Instantiate the
	new priv_ member.
	(translation_unit_diff::{first,second}_translation_unit): New
	accessors.
	(corpus_diff::{deleted, added, changed}_functions): New function
	implementations.
	(diff_node_visitor::visit): New function implementations.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:17 +01:00
Dodji Seketeli
88741744e7 Make tree walking preemptive
* include/abg-traverse.h (traversable_base::traversable): Change
	the signature of this to return a boolean.
	* include/abg-ir.h (ir_traversable_base::traverse): Change the
	signature of this to return a boolean.
	(*::traverse): Adjust.
	(ir_node_visitor::visit): Change the signature of this to return a
	boolean.
	* src/abg-corpus.cc (symtab_build_visitor_type::visit): Adjust.
	* src/abg-ir.cc (::traverse): Adjust.
	* tests/test-walker.cc (name_printing_visitor::visit): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-27 13:01:17 +01:00
Jonathan Wakely
12b78c366d Fix comment typos
* include/abg-diff-utils.h (compute_diff): Fix typo in apidoc
	comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-26 15:06:32 +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
65b4779ffe Fix destructor naming.
* src/abg-ir.cc (function_decl::get_pretty_representation): In
	DWARF at least, the destructor function name already contains the
	'~'.  No need to add it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-20 13:38:02 +01:00
Dodji Seketeli
52a7991d5e Better static function determination heuristic
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Better
	heuristic.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-20 13:36:49 +01:00
Dodji Seketeli
5558174054 Dynamically wire class_decl::base_spec hashing
* include/abg-ir.h (decl_base::get_hash): Make this virtual.
	(class_decl::base_spec::get_hash): Declare a new virtual overload.
	* src/abg-ir.cc (class_decl::base_spec::get_hash): Define.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-20 13:34:00 +01:00
Dodji Seketeli
f0765e638a Slight indentation fix in the diff report
* src/abg-comparison.cc (class_diff::report): Indentation fix for
	member function changes report.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-20 12:27:05 +01:00
Dodji Seketeli
40a0d8c854 Get rid of class_decl::member_function
* include/abg-fwd.h (is_member_function)
	(get_member_function_is_{ctor,dtor,const})
	(get_member_function_vtable_offset): New function declarations.
	* include/abg-ir.h (class_decl::member_function): Remove.
	(class_decl::member_functions): Adjust.  This is now just a vector
	of method_decl_sptr.
	(class_decl::add_member_function): Remove the overload taking
	class_decl::member_function.  Adjust the other overload to take a
	method_decl_sptr.
	(class mem_fn_context_rel): New class.
	(class_decl::method_decl::set_scope): New virtual overload.
	(class_decl::member_function): Remove.
	(operator==): Remove the overload taking a
	class_decl::member_function.
	(class_decl::member_function::hash): Remove.
	(ir_node_visitor::visit): Remove the overload taking a
	class_decl::member_function.
	* include/abg-comparison.h (changed_member_function_sptr)
	(string_member_function_sptr_map): Adjust.
	* src/abg-comparison.cc (represent): Adjust the overload taking a
	class_decl::member_function to take a class_decl::method_decl.
	(class_diff::{report, ensure_lookup_tables_populated}): Adjust.
	* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
	overload taking a class_decl::member_function.
	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
	Adjust.
	* src/abg-hash.cc (decl_base:#️⃣:operator()): Use the fully
	qualified name of the decl in the hash, to increase the likelihood
	of avoiding hash collisions.
	(method_type:#️⃣:operator()): Likewise.
	(function_decl:#️⃣:operator()): Take member functions in
	account.
	(class_decl::member_function:#️⃣:operator()): Remove.
	(class_decl:#️⃣:operator()): Adjust.
	(type_base::dynamic_hash::operator()): Adjust.
	* src/abg-ir.cc (is_member_function)
	(get_member_function_is_{ctor,dtor,const})
	(get_member_function_vtable_offset): New function definitions.
	(function_decl::get_pretty_representation): Adjust.
	(function_decl::operator): Take member functions in account here.
	(class_decl::insert_member_decl): Adjust.
	(mem_fn_context_rel::~mem_fn_context_rel): New definition.
	(class_decl::member_function::*): Remove.
	(class_decl::method_decl::set_scope): New definition.
	(class_decl::get_num_virtual_functions): Adjust.
	(class_decl::add_member_function): Remove overload taking a
	class_decl::member_function.  Define a new overload taking a
	class_decl::method_decl.
	(ir_node_visitor::visit): Remove the overload taking a
	class_decl::member_function.
	* src/abg-reader.cc (build_class_decl): Adjust.
	* src/abg-writer.cc (write_voffset, write_class_decl): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-20 12:21:36 +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
86d319dc08 Do not report change in typedef underlying type is there is none
* src/abg-comparison.cc (typedef_diff::report): Do not forget to
	check the length of the diff of the underlying type before sending
	its diff report down the wire.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 13:59:33 +01:00
Dodji Seketeli
fe526e7430 Avoid hashing a access & static-ness of member types twice
* src/abg-hash.cc (class_decl:#️⃣:operator()): Do hash the
	'member' part of the member types here, it has been hashed
	already.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 11:44:59 +01:00
Dodji Seketeli
a27f5f2e92 Set class {size,loc} when adding members to a decl-only class
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not
	forget to set class size and location when adding members to a
	declaration-only class, turning it into a definition class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 11:43:33 +01:00
Dodji Seketeli
ca53b99c5a Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
	(as_non_member_type, as_non_member_class_decl): Remove.
	(has_scope, is_member_decl, is_member_type): New function
	declarations.  (get_member_is_static, set_member_is_static):
	Likewise.  * include/abg-ir.h (enum access_specifier): Move to
	the abigail:: namespace, from ...
	(class_decl::access_specifier): ... here.  (class
	context_rel): New type.  (decl_base::hash_as_member): New
	hasher.  (decl_base::context_): Change the type of this to
	context_rel_sptr.  (decl_base::get_context_rel): New protected
	getter.  (decl_base::get_scope): Move this out-of-line.
	(class_decl::member_type): Remove.
	(class_decl::member_types): Adjust this typedef.
	(class_decl::{insert,add}_member_type): Make these take a
	type_base_sptr now.  (class_decl::add_member_type): Change the
	overload that returned a member_type to return a
	type_base_sptr.  (get_member_access_specifier,
	set_member_access_specifier): New function declarations.  *
	include/abg-comparison.h (class member_type_diff): Remove.
	(compute_diff): Remove the overload for member_type_diff.  *
	src/abg-comparison.cc (compute_diff_for_types): Adjust for the
	removal of class_decl::member_type.
	(maybe_report_diff_for_class_members): New static function.
	(report_name_size_and_alignment_changes): Do not report a name
	change just because of a struct -> class change.  ({var_diff,
	enum_diff, function_decl_diff}::report): Use the new
	maybe_report_diff_for_class_members.  (class_diff::report):
	Adjust for the removal of class_decl::member_type.  Use the
	new maybe_report_diff_for_class_members.  (class member_diff):
	Remove.  * src/abg-dwarf-reader.cc (die_access_specifier)
	(get_scope_for_die, build_translation_unit_and_add_to_ir)
	(build_class_type_and_add_to_ir, build_function_decl)
	(build_ir_node_from_die): Adjust.  * abg-hash.cc (struct
	decl_base::hash_as_member): Define.  ({scope_type_decl,
	enum_type_decl, typedef_decl}:#️⃣:operator()): Use the
	decl_base::hash_as_member.
	* src/abg-ir.cc (decl_base::decl_base): Adjust.
	(decl_base::get_scope): New out-of-line getter.
	(decl_base::{operator==, set_scope): Adjust.
	(has_scope, is_member_decl, is_member_type)
	(get_member_access_specifier, set_member_access_specifier)
	(get_member_is_static, set_member_is_static, is_at_class_scope):
	New function definitions.
	(as_non_member_type, as_non_member_class_decl): Remove.
	(get_node_name): Adjust.
	(class_decl::{class_decl, set_earlier_declaration,
	insert_member_decl, insert_member_type, add_member_type):
	Likewise.
	(class_decl::member_type::*) Remove.
	* src/abg-reader.cc (read_access, build_qualified_type_decl)
	(build_reference_type_def, build_typedef_decl)
	(build_class_decl): Adjust.
	* src/abg-writer.cc (write_access, write_member_type)
	(write_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 11:13:54 +01:00
Dodji Seketeli
a58f60c08f Avoid more static_casts in the (comparison) code
* src/abg-ir.cc (class_decl::insert_member_type, operator==):
	Remove static_casts.
	(class_decl::member_type::operator==): Likewise.
	(class_decl::member_class_template::operator==): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 16:42:18 +01:00
Dodji Seketeli
df7c672219 Allow adding members to decl-only classes making them defined classes
* include/abg-fwd.h (lookup_type_in_scope)
	(lookup_var_decl_in_scope): New declarations.
	* include/abg-ir.h (class_decl::get_is_declaration_only): Rename
	is_declaration_only on this.
	(class_decl::set_is_declaration_only):
	* src/abg-comparison.cc (try_to_diff<class_decl>)
	(class_diff::ensure_lookup_tables_populated)
	(scope_diff::ensure_lookup_tables_populated): Update for the
	get_is_declaration_only renaming.
	* src/abg-dwarf-reader.cc (get_scope_for_die): Likewize.
	(build_class_type_and_add_to_ir): Make sure that a member type or
	data member is not already present in the class before adding it.
	Also, if a decl-only class gets a data member, it's not a
	decl-only class anymore.
	* src/abg-hash.cc (class_decl:#️⃣:operator()): Update for the
	get_is_declaration_only renaming.
	* src/abg-ir.cc (scope_decl::find_iterator_for_member)
	(look_through_decl_only_class): Likewise.
	(lookup_type_in_scope, lookup_var_decl_in_scope, get_node_name)
	(convert_node_to_decl, lookup_node_in_scope)
	(lookup_type_in_scope): New definitions.
	(class_decl::{set_definition_of_declaration,
	set_earlier_declaration, operator==}): Update for the
	get_is_declaration_only renaming.
	* src/abg-reader.cc (build_class_decl): Likewise.
	* src/abg-writer.cc (write_class_is_declaration_only): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 16:26:14 +01:00
Jonathan Wakely
9fcd72ca39 Fixed typos in abg-diff-utils.h
* include/abg-diff-utils.h (compute_diff): Fix typos in the API
	doc.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 14:52:41 +01:00
Dodji Seketeli
35d83f61eb Initialize a variable
* tools/bilint.cc (main): Initialize the 'r' variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 13:59:01 +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
b78e3371e5 Little style fix
* src/abg-comparison.cc (class_diff::report): Slight style fix.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 09:08:47 +01:00
Dodji Seketeli
6667c21fe4 Better support for decl-only classes in diffing and comparison
* include/abg-fwd.h (look_through_decl_only_class): New function
	declaration.
	* src/abg-comparison.cc (class_diff::length): Just compare the two
	classes.
	(compute_diff): Look through the two classes if they are
	decl-only, and use their declaration for the diffing.
	* src/abg-ir.cc (look_through_decl_only_class): Define this new
	entry point.
	(class_decl::set_definition_of_declaration): Allow setting a
	definition that is itself a declaration-only.
	* src/abg-writer.cc (write_class_decl): Declaration-only can now
	have members, namely member types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 23:29:10 +01:00
Dodji Seketeli
6021659d3b Fix comparison wrt hash number
* src/abg-ir.cc (decl_base::operator==): Do not consider empty
	hashes.
	(class_decl::operator==): Better support for comparing decl-only
	classes against non-decl-only classes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 23:15:54 +01:00
Dodji Seketeli
372cd79430 Better support of class DIEs with DW_AT_specification
* src/abg-dwarf-reader.cc (get_scope_for_die): The definition of a
	declaration-only class can be NULL.  Do not look through in that
	case.
	(build_class_type_and_add_to_ir): Support adding class members to
	an existing class.
	(build_ir_node_from_die): If a class DIE has a DW_AT_specification,
	get the specification DIE, get its matching IR node and add the
	current members of the current DIE to that IR node.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 22:41:05 +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
10ba4d6e7d Fix typedef_diff emptyness detection
* src/abg-comparison.cc (typedef_diff::length): Do not mask away the
	dynamic type of the typedef_decl before the comparison.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-06 09:29:11 +01:00
Dodji Seketeli
bac732ff5a Add --drop/--keep options to bidiff
* include/abg-sptr-utils.h: New file.
	* include/Makefile.am: Add abg-sptr-utils. to the build system.
	* include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove
	these typedefs as there are now in abg-sptr-utils.
	(build_sptr): Likewise for this template and its specializations
	declarations.
	* src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the
	definition of the specializations for xmlTextReader and xmlChar
	into the sptr_utils namespace.
	* include/abg-corpus.h
	(corpus::{get_regex_patterns_of_fns_to_suppress,
	get_regex_patterns_of_vars_to_suppress,
	get_regex_patterns_of_fns_to_keep,
	get_regex_patterns_of_vars_to_keep}): Declare new member
	functions.
	* src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new
	functor.
	(build_sptr) Define new specialization for regex_t.
	(struct array_deleter): Remove unused functor.
	(corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data
	members.
	(symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}):
	Likewise.
	(symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})):
	Likewise.
	(symtab_build_visitor_type::symtab_build_visitor_type): Update the
	signature of this constructor to take regex patterns for functions
	and variables to suppress and to keep.  Also, initialize the data
	members from these new parameters.
	(symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New
	member functions.
	(symtab_build_visitor_type::{add_fn_to_wip_fns,
	add_var_to_wip_vars}): Likewise.
	(symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or
	add_var_to_wip_vars depending on the overload of the visit()
	member.
	(corpus::priv::build_symbol_table): Update for the change of the
	symtab_build_visitor_type constructor signature.
	(corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}):
	Define new member functions.
	* tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}):
	New data member.
	(display_usage): Add help strings for --drop, --drop-fn,
	--drop-var, --keep, --keep-fn, --keep-var
	(parse_command_line): Parse the command lines above.
	(set_corpus_keep_drop_regex_patterns): Define new static function.
	(main): Use the new set_corpus_keep_drop_regex_patterns.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
8058f9da70 Style fix in the dwarf reader
* src/abg-dwarf-reader.cc (die_is_public_decl): Rename
	is_public_decl into this.
	(die_is_declaration_only): Rename is_declaration_only into this.
	(build_class_type_and_add_to_ir, build_var_decl)
	(build_function_decl): Adjust for the renames above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +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
6c34ffd67e Fix function parameter addition/deletion/change detection
* include/abg-ir.h (function_decl::parameter::get_name_id):
	Declare new entry point.
	* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): Use the new
	function_decl::parameter::get_name_id() for the unique name of the
	parameter.  Also, fix a little logic error: if a parm is deleted
	and inserted, in all cases, consider it as not deleted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 15:00:34 +01:00
Dodji Seketeli
fde5a31a2a Add a --stat option to bidiff
* include/abg-comparison.h (diff_context::show_stats_only):
	Declare new accessors.
	* src/abg-comparison.cc
	(diff_context::priv::show_stats_only_): New member.
	(diff_context::show_stats_only): Define new accessors.
	(corpus_diff::report): If showing stats only, quit right after
	showing the summary.
	* tools/bidiff.cc (options::show_stats_only): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Add help string for --stat.
	(parse_command_line): Parse the --stat option.
	(set_diff_context_from_opts): Update to set the show_stats_only
	onto the context.  Cleanup the logic to make it more compact.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 13:03:53 +01:00
Dodji Seketeli
d24c3d6341 Report about functions of different names
* src/abg-comparison.cc (function_decl_diff::report): Consider the
	case of functions with different names.  This doesn't happen in
	the current pipeline b/c they just show up as deleted/added
	functions so the function reporter doesn't see them as they have
	been already reported by now.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:40:38 +01:00
Dodji Seketeli
5da389b486 Fix length calculation for type diffs.
* src/abg-comparison.cc (diff_length_of_type_bases): Fix stupid
	harmful thinko here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:37:51 +01:00
Dodji Seketeli
d5f37ea7f4 Fix calculation of the length of distinct_diff
* src/abg-comparison.cc (distinct_diff::length): Also perform a
	deep comparison here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:35:36 +01:00
Dodji Seketeli
6407c66fc6 Fix diff length calculation for typedef diffs
* src/abg-comparison.cc (typedef_diff::length): Just use
	comparison for this.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:11:41 +01:00
Dodji Seketeli
241166a601 Fix layout of diff summary
* src/abg-comparison.cc
	(corpus_diff::priv::emit_corpus_diff_stats): Remove useless
	vertical and horizontal white spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:08:01 +01:00
Dodji Seketeli
0aec4376d8 Fix indentation of pieces of class diff report
* src/abg-comparison.cc (represent, class_diff::report): Fix
	indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:03:57 +01:00
Dodji Seketeli
0f397606a1 Fix detection of entities of different kinds for diff purposes
* src/abg-comparison.cc
	(distinct_diff::entities_are_of_distinct_kinds): Consider two NULL
	decls are distinct types for the purpose of diffing.  This is just
	a shortcut to avoid creating a null_diff type for now.  But then,
	stop considering same pointers as different.  This was a bug.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 11:38:34 +01:00
Dodji Seketeli
5f7ce682e2 Constify function_decl::parameter::get_type_pretty_representation()
* include/abg-ir.h
	(function_decl::parameter::get_type_pretty_representation): This
	is now const.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 10:42:46 +01:00
Dodji Seketeli
fb2de7bb71 Improve API doc for the location machinery
* include/abg-ir.h (class location): Improve doc.
	(decl_base::{get,set}_location): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 10:26:00 +01:00