Commit Graph

467 Commits

Author SHA1 Message Date
Dodji Seketeli
b7ae89e325 Fix API doc for static_data_member_type_size_changed
* src/abg-comp-filter.cc (static_data_member_type_size_changed):
	Fix API doc comment.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 13:27:23 +02:00
Dodji Seketeli
fffb903ea0 Don't blindly drop DIEs defined in the scope of a function
* src/abg-dwarf-reader.cc (get_scope_for_die): Do not drop a DIE
	on the floor just because it is in the scope of a function.  We
	were dropping a function parameter because its type is a typedef
	defined right before the parameter, in the scope of the function.
	Urgh.  So with this change, that function parameter is not dropped
	anymore.  I have seen that happening in a DWARF generated by GCC
	4.7.1 on libstdc++.so.  Hard to come up with a regression test
	case for this one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 13:21:40 +02:00
Dodji Seketeli
57ceb9e3d1 Useless code killing
* src/abg-comparison.cc (decls_equal::operator()(const decls_type,
	const decls_type)): Kill dead code.  Note that there is a proper
	equality operator for decl_base_sptr already.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 13:15:46 +02:00
Dodji Seketeli
e4820f9e33 File static data member changes in STATIC_DATA_MEMBER_CHANGE_CATEGORY
* include/abg-comparison.h
	(diff_category::STATIC_DATA_MEMBER_CHANGE_CATEGORY): New category.
	(diff_category::EVERYTHING_CATEGORY): Update
	* src/abg-comp-filter.cc (static_data_member_type_size_changed)
	(static_data_member_added_or_removed): Define new static
	functions.
	(harmless_filter::visit): Categorize changes to static data
	members as STATIC_DATA_MEMBER_CHANGE_CATEGORY.
	* tools/bidiff.cc (set_diff_context_from_opts):
	STATIC_DATA_MEMBER_CHANGE_CATEGORY is falls into the harmless
	group.
	* tests/data/test-diff-filter/test12-report.txt: New test input.
	* tests/data/test-diff-filter/test12-v0.cc: Likewise.
	* tests/data/test-diff-filter/test12-v0.o: Likewise.
	* tests/data/test-diff-filter/test12-v1.cc: Likewise.
	* tests/data/test-diff-filter/test12-v1.o: Likewise.
	* tools/bidiff.cc: Run this test with the additional input data
	above.
	* tests/Makefile.am: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 11:50:45 +02:00
Dodji Seketeli
fc6af95304 Fix typo in comments
* include/abg-comparison.h
	(diff_category::NON_VIRT_MEM_FUN_CHANGE_CATEGORY): Fix typo in
	comments.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 11:17:02 +02:00
Dodji Seketeli
d95eb0f682 Only non-static data member changes are SIZE_OR_OFFSET_CHANGE_CATEGORY
* src/abg-comp-filter.cc
	(non_static_data_member_type_size_changed): Renamed
	data_member_offset_changed into this.  Make sure the test detects
	changes on *non-static* data members only.
	(non_static_data_member_added_or_removed): Likewise for
	data_member_offset_changed that got renamed into this.
	(harmful_filter::visit): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 11:10:20 +02:00
Dodji Seketeli
85f47880cb Fix comments in categorization code
* src/abg-comp-filter.cc (data_member_added_or_removed): Fix
	comments.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 10:35:21 +02:00
Dodji Seketeli
c4d202099e Really detect static-ness of data members. Oops.
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Let's
	consider that a data member being not laid out (i.e, not having a
	data_member_location) is is a static data member.  Otherwise, we
	were not detecting static data members at all.  Well we were only
	inferring their presence from seeing the static variable
	definition later on.  That means we were missing most of the
	static variables.  Woops.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Now that we
	are really seeing static data members, let's be prepare to the
	fact that we can the same static data member being declared
	several times in a corpus.
	* tests/data/test-diff-dwarf/test7-report.txt: New test input file.
	* tests/data/test-diff-dwarf/test7-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test7-v0.o: Likewise.
	* tests/data/test-diff-dwarf/test7-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test7-v1.o: Likewise.
	* tests/test-diff-dwarf.cc: Update this to consume the new test
	input files.
	* tests/Makefile.am: Update this to add the missing test files to
	the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 17:31:13 +02:00
Dodji Seketeli
c545e58b52 Add dumping routines for declaration location
* include/abg-fwd.h (get_global_scope()): New overload for const
	decl_base&.  Move the other overloads up in the file.
	(get_translation_unit): Add an overload for decl_base&.  Constify
	the others.
	(dump_decl_location): Declare new functions.
	* src/abg-ir.cc (get_global_scope): Define the overload for const
	decl_base&.  Write the other overloads in terms of this one.
	(get_translation_unit): Likewise, define the overload for const
	decl_base&.  Write the other overloads in terms of this one.
	(dump_decl_location): Define these new overloads.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 17:09:49 +02:00
Dodji Seketeli
2dd9d92e34 Fix dumping function to make them use generic ostream
* src/abg-writer.cc (dump(const decl_base_sptr, std::ostream&)):
	Do not dump the content to cerr here.  Rather dump to the output
	stream given in parameter.  Oops.
	(dump(const translation_unit&, std::ostream&)): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 17:06:11 +02:00
Dodji Seketeli
b462192739 Misc style fixes
* src/abg-ir.cc (get_translation_unit): Remove useless vertical
	white space.
	(is_global_scope): Add missing API doc.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 17:00:32 +02:00
Dodji Seketeli
97a7051560 A virt mem fn deleted and added to the same offset is not harmful
* src/abg-comp-filter.cc (has_virtual_mem_fn_change): A virtual
	member that gets deleted and added back again to the same vtable
	offset is not considered as being a virtual member function change
	suitable for VIRTUAL_MEMBER_CHANGE_CATEGORY.  Likewise for a
	function sub-type change not involving a change in the vtable
	offset.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
24add14903 Do not categorize size/offset changes when a decl-only class is involved
* src/abg-comp-filter.cc (there_is_a_decl_only_class)
	(diff_involves_decl_only_class): New static functions.
	(type_size_changed, data_member_added_or_removed)
	(has_virtual_mem_fn_change, has_non_virtual_mem_fn_change): Bail
	out if one of the types involved is a decl-only class.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
dc9959696c Work around "mangled name vanishing from one version of mem fn decl" bug
* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): If the first version
	of the member function decl doesn't have a mangled name while the
	second has it, try the lookups using the pretty representation of
	the function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
63965bbae7 Do not try to represent the offset for a static data member
* src/abg-comparison.cc (represent_data_member(var_decl_sptr,
	ostream&)): If the data member is static, do not try to represent
	its offset.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
f2872084ec A static data member shouldn't be checked for having been laid out
* src/abg-comparison.cc (represent_data_member(var_decl_sptr,
	ostream&)): If the data member is static do not check for it
	having been laid out.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
3299e63da0 Prefix pretty representation of static data members with 'static'
* src/abg-ir.cc (var_decl::get_pretty_representation): Prefix
	pretty representation of static data members with 'static'.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
3ae24bafc3 Provide a robust way of getting the size of a qualified type
* include/abg-ir.h (qualified_type_def::get_size_in_bits): Declare
	new member function ...
	* src/abg-ir.cc (qualified_type_def::get_size_in_bits): ... and
	define it.  Keep in mind that some times the size of the
	underlying type can change between the moment the qualified type
	is created and the end of its life time.  That is because a
	subsequent DIE (from DWARF) can alter the size of the underlying
	type.  This overload allows the user to always query the size of
	the underlying type and keep the size of the qualified type in
	sync with it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
609a49832c Add an assert to the pointer diff reporting code
* src/abg-comparison.cc (pointer_diff::report): If the pointer
	diff node is deemed to be reported then the underlying diff node
	should be reported as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
00a0f986d6 Little style adjustment in diff node categorization code
* src/abg-comp-filter.cc (harmful_filter::visit): Factorize the
	categorization into SIZE_OR_OFFSET_CHANGE_CATEGORY for data member
	adding or removal and for data member type size change.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-16 11:41:20 +02:00
Dodji Seketeli
13af201739 If a diff node is in NO_CHANGE_CATEGORY do not report it anymore
* src/abg-comparison.cc (diff::is_filtered_out): Now that we seem
	to be flagging every changes to a class into a category, we do not
	need to dive into reporting a diff not that is categorized as
	NO_CHANGE_CATEGORY anymore.  So let's have the implementation that
	one would expect for this function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-15 12:46:14 +02:00
Dodji Seketeli
728f4f2fcc Categorize changes to virt mem fncts as VIRTUAL_MEMBER_CHANGE_CATEGORY
* src/abg-comp-filter.cc (has_virtual_mem_fn_change): New static
	function.
	(harmful_filter): Categorize changes to virtual member functions
	into VIRTUAL_MEMBER_CHANGE_CATEGORY.
	* src/abg-comparison.cc
	(class_diff::priv::count_filtered_changed_dm): Move this up, right
	after class_diff::priv::count_filtered_subtype_changed_dm.
	(SKIP_MEM_FN_IF_VIRTUALITY_DISALLOWED): New macro.
	(class_diff::priv::count_filtered_{changed, inserted,
	deleted}_mem_fns): Modify these to properly take member function
	virtual-ness in account.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-15 12:36:36 +02:00
Dodji Seketeli
e641f7a61c Do not hash non-virtual member functions when hashing a class
* src/abg-hash.cc (class_decl:#️⃣:operator): Do not hash
	non-virtual member functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-15 11:49:26 +02:00
Dodji Seketeli
b6c3e9ec0a Fix a missing new line in the reports
* src/abg-comparison.cc (represent(class_decl::method_decl_sptr,
	ostream&)): Add a missing new line.
	* tests/data/test-bidiff/test-struct1-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-15 11:32:21 +02:00
Dodji Seketeli
8b93472231 Add more pretty printing facilities
* include/abg-comparison.h (get_pretty_representation(diff*)):
	Declare new function.
	* include/abg-fwd.h (get_pretty_representation): Declare functions
	for decl_base*, type_base*, decl_base_sptr and type_base_sptr.
	* src/abg-comparison.cc (get_pretty_representation): Implement
	this for diff*.
	* src/abg-ir.cc (get_pretty_representation): Define
	implementations for decl_base*, type_base*, decl_base_sptr and
	type_base_sptr.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-14 22:46:51 +02:00
Dodji Seketeli
0112c5619a Don't compare non-virtual member functions in class comparison
* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): Use the virtual
	member functions here, not the member functions in general.
	(compute_diff): Consider virtual member functions only, not
	non-virtual ones.
	* src/abg-ir.cc (class_decl::operator==): Do not compare
	non-virtual member functions.  Only compare virtual member
	functions.
	* tests/data/test-bidiff/test-struct1-report.txt: New test input.
	* tests/data/test-diff-dwarf/test0-report.txt: New test input.
	* tests/data/test-diff-filter/test0-report.txt: New test input.
	* tests/data/test-diff-filter/test01-report.txt: New test input.
	* tests/data/test-diff-filter/test10-report.txt: New test input.
	* tests/data/test-diff-filter/test11-report.txt: New test input.
	* tests/data/test-diff-filter/test2-report.txt: New test input.
	* tests/data/test-diff-filter/test9-report.txt: New test input.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-14 21:48:00 +02:00
Dodji Seketeli
99d3857ddd Recognize virtual member functions better and store them appart
* include/abg-fwd.h (set_member_function_is_virtual): Declare new
	function.
	* include/abg-ir.h (class class_decl): Declare
	set_member_function_is_virtual and member_function_is_virtual as
	friends of class_decl.
	(class_decl::add_member_function): Take an is_virtual flag.
	(class_decl::get_num_virtual_functions): Remove.
	(class_decl::get_virtual_mem_fns): New member function.
	(mem_fn_context_rel::is_virtual_): New member.
	(mem_fn_context_rel::mem_fn_context_rel): Adjust to initialize the
	new is_virtual_ member.
	(mem_fn_context_rel::is_virtual): New member functions.
	* src/abg-comparison.cc (represent): Adjust.
	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Adjust.
	* src/abg-ir.cc (member_function_is_virtual): Change this to use
	mem_fn_context_rel::is_virtual.
	(set_member_function_is_virtual): Define this new function.
	(class_decl::priv::virtual_mem_fns_): New member to hold virtual
	member functions.
	(class_decl::get_virtual_mem_fns): Implement this member function.
	(class_decl::get_num_virtual_functions): Remove.
	(class_decl::add_member_function): Take a new is_virtual flag.
	Add virtual member functions to
	class_decl::priv::virtual_mem_fns_.
	* src/abg-reader.cc (build_class_decl): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-14 14:56:51 +02:00
Dodji Seketeli
305f18e91e Filter non-virtual member fns insertions/deletions from class changes
* include/abg-fwd.h (member_function_is_virtual): Declare new
	function.
	* include/abg-comparison.h
	(diff_category::{NON_VIRT_MEM_FUN_CHANGE_CATEGORY,
	VIRTUAL_MEMBER_CHANGE_CATEGORY}): New enumerators.
	(diff_category::EVERYTHING_CATEGORY): Adjust.
	(class_diff::{changed, deleted, inserted}_member_fns): Declare new
	member functions.
	* src/abg-comp-filter.cc (data_member_added_or_removed): Add
	missing comments.
	(has_non_virtual_mem_fn_change): New static predicate function.
	(harmless_filter::visit): Categorize non-virtual member function
	changes in a diff into NON_VIRT_MEM_FUN_CHANGE_CATEGORY.
	* src/abg-comparison.cc
	(TRAVERSE_MEM_FN_DIFF_NODE_AND_PROPAGATE_CATEGORY): New macro.
	(report_mem_header): Count filtered functions for added/deleted
	functions as well.
	(class_diff::priv::count_filtered_changed_mem_fns): Renamed
	priv::count_filtered_member_functions into this.  Filter out
	changes to non-virtual member functions here.
	(class_diff::priv::count_filtered_{inserted, deleted}_mem_fns):
	New member functions.
	(class_diff::{deleted, inserted, changed}_member_fns): Define new
	member functions.
	(class_diff::report): Adjust count for filtered inserted/deleted
	member functions.  Do not report NON_VIRT_MEM_FUN_CHANGE_CATEGORY
	if it's disallowed.
	(class_diff::traverse): Propagate only
	VIRTUAL_MEMBER_CHANGE_CATEGORY from member functions to their
	enclosing class.
	* src/abg-ir.cc (member_function_is_virtual): Define new
	functions.
	* tools/bidiff.cc (set_diff_context_from_opts): Adjust to add
	NON_VIRT_MEM_FUN_CHANGE_CATEGORY into the harmless group and
	VIRTUAL_MEMBER_CHANGE_CATEGORY into the harmful one.
	* tests/data/test-diff-filter/test0-report.txt: New test input.
	* tests/data/test-diff-filter/test10-report.txt: Likewise.
	* tests/data/test-diff-filter/test10-v0.cc: Likewise.
	* tests/data/test-diff-filter/test10-v0.o: Likewise.
	* tests/data/test-diff-filter/test10-v1.cc: Likewise.
	* tests/data/test-diff-filter/test10-v1.o: Likewise.
	* tests/data/test-diff-filter/test11-report.txt: Likewise.
	* tests/data/test-diff-filter/test11-v0.cc: Likewise.
	* tests/data/test-diff-filter/test11-v0.o: Likewise.
	* tests/data/test-diff-filter/test11-v1.cc: Likewise.
	* tests/data/test-diff-filter/test11-v1.o: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Likewise.
	* tests/data/test-diff-filter/test9-v0.cc: Likewise.
	* tests/data/test-diff-filter/test9-v0.o: Likewise.
	* tests/data/test-diff-filter/test9-v1.cc: Likewise.
	* tests/data/test-diff-filter/test9-v1.o: Likewise.
	* tests/test-diff-filter.cc: Consume the test input above to run
	more tests.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 23:09:02 +02:00
Dodji Seketeli
7ac2fe072d Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
	(class_decl::{get_is_declaration_only, set_is_declaration_only,
	is_struct, get_definition_of_declaration, get_earlier_declaration,
	add_base_specifier, get_base_specifiers, get_member_types,
	get_data_members, get_member_functions,
	get_member_function_templates, get_member_class_templates}): Move
	these methods out-of-line.
	(class_decl::{comparison_started_,
	declaration_,is_declaration_only_, definition_of_declaration,
	is_struct_, bases_, member_types_, data_members_,
	member_functions_, member_function_template,
	member_class_templates_}): Move these data members into the pimpl
	in ...
	* src/abg-ir.cc
	(class_decl::priv::{declaration_,is_declaration_only_,
	definition_of_declaration, is_struct_, bases_, member_types_,
	data_members_, member_functions_, member_function_template,
	member_class_templates_}): ... here.
	(class_decl::priv::classes_being_compared_): New data member.
	(class_decl::priv::priv): Initialize the data members.
	(class_decl::priv::{mark_as_being_compared,
	unmark_as_being_compared, comparison_started): New methods.
	(class_decl::{get_is_declaration_only, set_is_declaration_only,
	is_struct, get_definition_of_declaration, add_base_specifier,
	get_base_specifiers, get_member_types, get_data_members,
	get_member_functions, get_member_function_templates,
	get_member_class_templates}): Move these out-of-line in here.
	(class_decl::{class_decl, set_definition_of_declaration,
	set_earlier_declaration, insert_member_type, add_member_type,
	add_data_member, add_member_function,
	add_member_function_template, add_member_class_template,
	has_no_base_nor_member}): Adjust.
	(class_decl::operator==): Harden inf-loop prevention during class
	comparison using the new priv::mark/unmark_as_being_compared()
	functions.  Now comparison of a class really compares member
	functions again.  And it is *slooow*.  I should probably change
	this to compare only virtual member functions.  But at least this
	should be correct and robust for now.
	* tests/data/test-diff-filter/test0-report.txt: Adjust.
	* test01-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 22:09:24 +02:00
Dodji Seketeli
263fb9513c Remove the parent member of the diff node
* include/abg-comparison.h (diff::parent_): Remove.
	(diff::diff): Adjust.
	(diff::{get, set}_parent): Remove.
	* src/abg-comp-filter.cc (harmless_filter::visit): Remove category
	propagation to the parent.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 22:14:21 +02:00
Dodji Seketeli
2f674216dc Update the decl_base copy constructor for forgotten members
* src/abg-ir.cc (decl_base::decl_base): Copy forgotten decl_base
	members hashing_started_, qualified_parent_name_, qualified_name_.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:55:16 +02:00
Dodji Seketeli
3df5f1dc9a Comment fix in filtering code
* src/abg-comp-filter.cc (harmful_filter::visit): Fix comment
	typos.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:55:16 +02:00
Dodji Seketeli
45b6ecc415 Put data member type size changes in SIZE_OR_OFFSET_CHANGE_CATEGORY
* src/abg-comp-filter.cc (type_size_changed): New overload for
	type_base_sptr.
	(data_member_type_size_changed): New predicate.
	(harmful_filter::visit): Use the new predicate to categorize data
	member type size changes into the SIZE_OR_OFFSET_CHANGE_CATEGORY.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:55:16 +02:00
Dodji Seketeli
f02768e7a7 Represent a removed+added data member at a given offset as changed
* include/abg-fwd.h (get_data_member_offset): Declare new overload for
	decl_base_sptr.
	* include/abg-comparison.h (unsigned_decl_base_sptr_map)
	(unsigned_changed_type_or_decl_map): New typedefs.
	* src/abg-ir.cc (get_data_member_offset): Define new overload for decl_base_sptr.
	* src/abg-comparison.cc (diff_kind::subtype_change_kind): New
	enumerator for a change about a type or sub-type of a member of a
	structure/enum.
	(report_mem_header): Handle the new enumerator above.
	(class_diff::priv::{deleted_dm_by_offset_, inserted_dm_by_offset_,
	changed_dm_}): New data members.
	(class_diff::priv::subtype_changed_dm_): Renamed
	class_diff::priv::changed_data_members_ into this.
	(class_diff::priv::subtype_changed_dm): Renamed
	class_diff::priv::data_member_has_changed into this. Adjust.
	(class_diff::count_filtered_subtype_changed_dm): Renamed
	count_filtered_data_members into this.  Adjust.
	(class_diff::priv::count_filtered_changed_dm): New member
	function.
	(class_diff::lookup_tables_empty): Adjust.
	(class_diff::ensure_lookup_tables_populated): Adjust.  Detect when
	a data member is deleted and added back to offset N, and be
	prepared to present that as a change of data member at offset N.
	(class_diff::report): Adjust.  Report data members of a given
	offset that have changed.
	* tests/data/test-diff-dwarf/test6-report.txt: New reference
	report for new test input.
	* tests/data/test-diff-dwarf/test6-v0.cc: Source code for new test
	input binary.
	* tests/data/test-diff-dwarf/test6-v0.o: New test input binary.
	* tests/data/test-diff-dwarf/test6-v1.cc: Source code for new test
	input binary.
	* tests/data/test-diff-dwarf/test6-v1.o: New test input binary.
	* tests/test-diff-dwarf.cc: Adjust to include the new test inputs above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:55:08 +02:00
Dodji Seketeli
288cf513e9 Unmark class_diff node as being traversed once traversal is finished
* src/abg-comparison.cc (class_diff:traverse): Unmark class_diff
	node as being traversed once traversal is finished

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:45:17 +02:00
Dodji Seketeli
c957d7b747 Do not use the parent diff node link for category propagation
* src/abg-comparison.cc (class_diff::traverse): Use the new
	TRAVERSE_MEM_DIFF_NODE_AND_PROPAGATE_CATEGORY macro to propagate
	categorization from the children diff nodes to the current one for
	bases, data members and member functions.
	(scope_diff::traverse): Likewise, use the
	TRAVERSE_DIFF_NODE_AND_PROPAGATE_CATEGORY to propagate
	categorization from the children diff nodes to the current one.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:11:53 +02:00
Dodji Seketeli
13c6c8ebed Ensure that each diff node is traversed just once
* include/abg-comparison.cc (pointer_map): New typedef.
	(diff_context::{has_diff_for}): New overload for diff*.
	(diff_context::{diff_has_been_traversed, mark_diff_as_traversed,
	forget_traversed_diffs}): Declare new methods.
	* src/abg-comparison.cc (ENSURE_DIFF_NODE_TRAVERSED_ONCE)
	(ENSURE_MEM_DIFF_NODE_TRAVERSED_ONCE): Define new macros.
	(diff_context::priv::traversed_diff_nodes_): New data member.
	(diff_context::has_diff_for): New overload for diff*
	(diff_context::{diff_has_been_traversed, mark_diff_as_traversed,
	forget_traversed_diffs}): Define new member functions.
	(diff_context::maybe_apply_filters): Forget the traversed diffs
	before applying a filter.
	({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}::traverse): Ensure that the diff node is
	traversed only once.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:11:53 +02:00
Dodji Seketeli
d74618530a Factorize diff sub-tree traversal and category propagation code
* src/abg-comparison.cc
	(TRAVERSE_DIFF_NODE_AND_PROPAGATE_CATEGORY)
	(TRAVERSE_MEM_DIFF_NODE_AND_PROPAGATE_CATEGORY): New macros.
	({distinct_diff, pointer_diff, reference_diff,
	qualified_type_diff, enum_diff, base_diff, function_decl_diff,
	typedef_diff}::traverse): Use the new macro above in lieu of the
	duplicated sub-tree traversal code in there.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:11:53 +02:00
Dodji Seketeli
42cce25598 Style fixes in the diff nodes traversing code
* src/abg-comparison.cc (TRY_{PRE, PRO}_VISIT, TRY_{PRE,
	PRO}_VISIT_CLASS_DIFF, ): Add a white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-11 21:11:53 +02:00
Dodji Seketeli
0b71429c15 Supporting reporting data member name change
* src/abg-comparison.cc (represent): Support reporting data member
	name change.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-10 15:07:24 +02:00
Dodji Seketeli
bf52d83bfe Consider added/removed data members as changing size or offset
* src/abg-comp-filter.cc (data_member_added_or_removed): New
	static function.
	(harmless_filter::visit): Re-organize logic.  Categorize data
	member addition/removal into SIZE_OR_OFFSET_CHANGE_CATEGORY.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-10 15:07:24 +02:00
Dodji Seketeli
ff78ffab6a Add missing comment
* src/abg-ir.cc (non_type_tparameter::get_hash): Add missing api doc.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-10 09:18:06 +02:00
Dodji Seketeli
d25c8bbbaa Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
	type_composition, class_decl}::hash): Declare hashers.
	({scope_decl, var_decl, non_type_tparameter, type_composition,
	class_decl}::get_hash): Provide new overloads of the get_hash.
	* src/abg-hash.cc ({type_decl, scope_type_decl,
	qualified_type_def, pointer_type_def, reference_type_def,
	enum_type_decl, typedef_decl, var_decl,
	function_decl}:#️⃣:operator()): If the hash is being
	calculated, do not use the not-yet fully calculated hash value.
	Rather, calculate the hash, cache it and return the value.
	({class_decl, non_type_tparameter}:#️⃣:operator()): Moved the
	{class_decl, non_type_tparameter}::hash declaration out of here
	and stick it in include/abg-ir.h.  Keep the definition of the
	hashing operators here though.
	(type_composition:#️⃣:operator()): New operator definition.
	* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
	non_type_tparameter, type_composition}::get_hash): Define new
	virtual overload.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 17:11:32 +02:00
Dodji Seketeli
793be5e374 Fix mis-hashing of base specifiers and function_decl during comparison
* include/abg-ir.h (function_decl::get_hash): Declare new virtual
	overload.
	* src/abg-hash.cc (class_decl::base_spec:#️⃣:operator()):
	Properly hash the base specifier so that it doesn't collide with
	hashing a class.
	* src/abg-ir.cc (decl_base::get_hash): Abort if we detect a
	missing overload for this;
	(function_decl::get_hash() const): Implement this missing
	overload, allowing using the virtual decl_base::get_hash for
	function_decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 15:56:18 +02:00
Dodji Seketeli
dce487d39c Properly place opening quote and add missing closing quote in report
* src/abg-comparison.cc (corpus_diff::report): Move the [{A,D}]
	marker before the opening quote.  And add a closing quote.
	* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test01-report.txt: Adjust.
	* tests/data/test-diff-filter/test2-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 15:08:06 +02:00
Dodji Seketeli
30a301220d Drive-by indentation fix
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Fix
	indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 13:30:27 +02:00
Dodji Seketeli
ff712fe3fc Drop ABI artifacts that are local to a function
* src/abg-dwarf-reader.cc (get_scope_for_die): If the parent die
	is  DW_TAG_subprogram then just drop the whole thing on the floor.
	(build_ir_node_from_die): When the scope is NULL, just drop the
	whole thing on the floor.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 13:23:25 +02:00
Dodji Seketeli
8ac24228b0 Fix the static data member recognition hack
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	When trying to recognize the global var_decl as being definition
	variables for static data members, lookup the declaration for the
	data member in the relevant class.  If found, then just flag the
	var_decl for the data member as being static; no need to add a
	var_decl as data member in that case, that would duplicate the
	data member.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 13:14:52 +02:00
Dodji Seketeli
25509e06cb Fix looking up a node inside a class
* src/abg-ir.cc (lookup_node_in_scope): Do not forget to actually
	look at the class members.  Sigh.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-08 12:04:54 +02:00
Dodji Seketeli
7639b2d3ab Work around old dwarf producers forgetting mangled names for functions
* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): If lookup
	using mangled name for a deleted function yields nada, try the
	lookup with the pretty representation for the function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 13:52:40 +02:00