Commit Graph

417 Commits

Author SHA1 Message Date
Dodji Seketeli
435f1520d7 Make type_base::get_{size,alignment}_in_bits virtual
* include/abg-ir.h (type_base::get_{size,alignment}_in_bits): Make
	this virtual.
	(typedef_decl::get_{size,alignment}_in_bits): Add new member
	functions.  Get the size,alignment from the underlying type and
	update the current size/alignment if they differ.  Keep in mind
	that the size of an underlying class_decl can change over its
	lifetime, given how the dwarf reader reads the type information,
	i.e, there can be a DIE for a class type with no size information
	that will lead to the creation of a class_decl with size zero.
	Later during the DWARF reading process, another DIE will
	supplement the type information, adding size information to that
	class_decl.  In between, a typedef_decl might have been created
	with the first version of the class_decl that has a zero size.  I
	guess this should be extended to the other type constructs that
	have an underlying type (qualified types, references and pointers).

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 10:08:10 +02:00
Dodji Seketeli
ce1df6ff33 Look through typedefs when setting SIZE_OR_OFFSET_CHANGE_CATEGORY
* include/abg-fwd.h (is_class_type): Declare new functions.
	* src/abg-comp-filter.cc (harmful_filter::visit): Use the above to
	convert a type into a class.
	* src/abg-ir.cc (is_class_type): Define the new function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 09:54:52 +02:00
Dodji Seketeli
23b7fa9ac2 Add a new DECL_NAME_CHANGE_CATEGORY change category
* include/abg-comparison.h (enum
	diff_category::DECL_NAME_CHANGE_CATEGORY): New enumerator.
	* src/abg-comparison.cc (report_name_size_and_alignment_changes)
	({enum, typedef}_diff::report): Adjust to avoid emitting name
	change report if the DECL_NAME_CHANGE_CATEGORY category of change
	is currently disallowed.
	* abg-comp-filter.cc (decl_name_changed): New static function.
	(harmless_filter::visit): Detect that the decl name changed and
	put the current diff node (and its parents) into the
	DECL_NAME_CHANGE_CATEGORY category.
	* tools/bidiff.cc (set_diff_context_from_opts): Set the new
	DECL_NAME_CHANGE_CATEGORY category into the harmless_changes group
	of categories.
	* tests/data/test-diff-filter/test6-report.txt: New test input file.
	* tests/data/test-diff-filter/test6-v0.cc: Likewise.
	* tests/data/test-diff-filter/test6-v0.o: Likewise.
	* tests/data/test-diff-filter/test6-v1.cc: Likewise.
	* tests/data/test-diff-filter/test6-v1.o: Likewise.
	* tests/data/test-diff-filter/test7-report.txt: Likewise.
	* tests/data/test-diff-filter/test7-v0.cc: Likewise.
	* tests/data/test-diff-filter/test7-v0.o: Likewise.
	* tests/data/test-diff-filter/test7-v1.cc: Likewise.
	* tests/data/test-diff-filter/test7-v1.o: Likewise.
	* tests/test-diff-filter.cc: Take the new inputs above to run new tests.
	* tests/Makefile.am: Add the new files above to the distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-06 15:59:38 +02:00
Dodji Seketeli
928efb2d4f Emit qualified name for typedefs
* src/abg-comparison.cc (typedef_diff::report): Emit qualified
	names for typedefs in diff reports about typedef name changes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-05 13:03:20 +02:00
Dodji Seketeli
17c804e565 Fix indentation in distinct type diff report
* src/abg-comparison.cc (distinct_diff::report): Do not forget to
	change line.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-05 13:02:01 +02:00
Dodji Seketeli
96edc0b08c Really compare return types for function types
* src/abg-ir.cc (compare_function_types): Compare return types,
	unless this is a method and the return type is the same type as
	the containing class type.
	* tests/data/test-diff-dwarf/test5-report.txt: Reference report
	for the comparison of the two input binaries below.
	* tests/data/test-diff-dwarf/test5-v0.cc: Source code for the
	input binary below.
	* tests/data/test-diff-dwarf/test5-v0.o: Test input binary.
	* tests/data/test-diff-dwarf/test5-v1.cc: Source code for the
	input binary below.
	* tests/data/test-diff-dwarf/test5-v1.o: Test input binary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-05 12:42:24 +02:00
Dodji Seketeli
2c03fdda8a Add missing tests for previous commits
* tests/data/test-diff-dwarf/test4-report.txt: Adjust.
	* tests/test-diff-dwarf.cc: Run tests for
	data/test-diff-dwarf/test3-report.txt" and
	data/test-diff-dwarf/test4-report.txt.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-05 12:40:28 +02:00
Dodji Seketeli
8801da4eb9 Categorize through compatible distinct type diffs
* src/abg-comparison.cc (report_size_and_alignment_changes): Split
	this static function out of ...
	(report_name_size_and_alignment_changes): ... this one.
	(distinct_diff::report): If the typedef-stripped variants of the
	diff subjects are of the same kind, display their diff.
	Otherwise, tell explicitly is the distinct type diff involves a
	type size change.
	(distinct_diff::traverse): If the typedef-stripped variants of the
	diff subjects are of the same kind, traverse that underlying diff
	sub-tree and propagate the categorizing possibly resulting from
	that traversal.
	* tests/data/test-diff-dwarf/test4-v0.o: New test input binary.
	* tests/data/test-diff-dwarf/test4-v0.cc: Source code for the
	input binary above.
	* tests/data/test-diff-dwarf/test4-v1.o: New test input binary.
	* tests/data/test-diff-dwarf/test4-v1.cc: Source code for the
	input binary above.
	* tests/data/test-diff-dwarf/test4-report.txt: Reference report
	for the difference between the two binaries above.
	* tests/data/test-diff-filter/test5-v0.o: New test input binary.
	* tests/data/test-diff-filter/test5-v0.cc: Source code for the
	input binary above.
	* tests/data/test-diff-filter/test5-v1.o: New test input binary.
	* tests/data/test-diff-filter/test5-v1.cc: Source code for the
	input binary above.
	* tests/data/test-diff-filter/test5-report.txt: Reference report
	for the difference between the two binaries above.
	* tests/test-diff-filter.cc: Adjust to produce a filtered diff for
	the two input binaries above.
	* tests/Makefile.am: Adjust to add missing test files to the
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-05 12:24:25 +02:00
Dodji Seketeli
08acaa1c84 Slight run-by fixes
* src/abg-comparison.cc
	(corpus_diff::priv::apply_filters_and_compute_diff_stats)
	(corpus_diff::report): Use compute_diff for types which it has an
	overload rather than going through the compute_diff_for_decls that
	would use dynamic casting.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-04 15:21:46 +02:00
Dodji Seketeli
e9ce9ef352 Do not hook type diff nodes to a parent
A given diff node for a type can be hung off of several contexts: a
function parameter type node, another type diff node, etc.  For that
reason, a type diff node should not have a parent node.  Thus, it's
should be the job of the context containing the type diff node to
propagate its categories to the context nodes.  This actually fixes a bug
about category propagation.

	* abg/comparison.cc (var_diff::var_diff): Do not set parent node
	for the type diff of the var_diff.
	(var_diff::traverse): Handle category propagation from the
	type diff node to the var_diff node.
	(pointer_diff::underlying_type_diff)
	(reference_diff::underlying_type_diff)
	(qualified_type_diff::underlying_type_diff, enum_diff::enum_diff)
	(base_diff::get_underlying_class_diff)
	(typedef_diff::underlying_type_diff): Do not set the parent node
	here.
	({pointer_diff, reference_diff, qualified_type, enum_diff,
	class_diff, base_diff, function_decl_diff,
	typedef_diff}::traverse): Handle category propagation here.
	* tests/data/test-diff-filter/test4-v0.o: New input binary.
	* tests/data/test-diff-filter/test4-v0.cc: Source code for the
	input binary above.
	* tests/data/test-diff-filter/test4-v1.o: New input binary.
	* tests/data/test-diff-filter/test4-v1.cc: Source code for the
	input binary above.
	* tests/data/test-diff-filter/test4-report.txt: Reference diff
	report for the input binaries above.
	* tests/test-diff-filter.cc:: Run bidiff --no-harmless on the
	binaries above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-04 14:44:50 +02:00
Dodji Seketeli
6a57f61497 Fix off-by one comparison bug in comparing function parameters
* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): Function
	parameters that are diff'ed start at the first non-implicit
	parameter, not at the first parameter.  Oops.
	* tests/data/test-diff-dwarf/test3-v0.o: New test input binary.
	* tests/data/test-diff-dwarf/test3-v0.cc: Source code for the
	binary above.
	* tests/data/test-diff-dwarf/test3-v1.o: New test input binary.
	* tests/data/test-diff-dwarf/test3-v1.cc: Source code for the
	binary above.
	* tests/data/test-diff-dwarf/test3-report.txt: Reference report
	for the diff of the new test inputs.
	* tests/test-diff-dwarf.cc: Use the test inputs above to run new
	tests.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-04 11:39:41 +02:00
Dodji Seketeli
712320ab4c Do not forget parm sub-type changes as opposed to parm changes
* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): A parm
	change is valid only when the added parm has a different name from
	the removed parm.  Both have the same index, of course.  In that
	case, do not try to remove the corresponding parm sub-type change.
	* tests/data/test-bidiff/test-enum0-report.txt: Adjust.
	* tests/data/test-bidiff/test-enum1-report.txt: Adjust.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Adjust.
	* tests/data/test-bidiff/test-struct0-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test0-report.txt: Adjust.
	* tests/data/test-diff-dwarf/test1-report.txt: Adjust.
	* tests/data/test-diff-filter/test0-report.txt: Adjust.
	* tests/data/test-diff-filter/test01-report.txt: Adjust.
	* tests/data/test-diff-filter/test1-report.txt: Adjust.
	* tests/data/test-diff-filter/test2-report.txt: Adjust.
	* tests/data/test-diff-filter/test3-report.txt: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-03 16:52:14 +02:00
Dodji Seketeli
27df878b59 Remove useless white space
* src/abg-ir.cc (look_through_decl_only_class): Remove useless
	white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-03 09:20:00 +02:00
Dodji Seketeli
dd346bab80 Use mangled name for decl comparison when it's present
* src/abg-ir.cc (decl_base::operator==(const decl_base& other)
	const): Use the mangled name of the decl in priority.
	* src/abg-hash.cc (struct decl_base:#️⃣:operator()): Likewise.
	* src/abg-comparison.cc (function_decl_diff::report): Do not
	report a function name change if it doesn't involve a mangled name
	change.  This might change when we start dealing with templates.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-03 09:18:52 +02:00
Dodji Seketeli
b386b28eb4 A change involving a decl-only class is not SIZE_OR_OFFSET_CHANGE_CATEGORY
* src/abg-comp-filter.cc (harmful_filter::visit): If a size change
	involves a decl-only class, it certainly shouldn't trigger putting
	the sub-tree into the SIZE_OR_OFFSET_CHANGE_CATEGORY category.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-02 17:58:54 +02:00
Dodji Seketeli
42473515bc Fix heuristics to detect function static-ness for DWARF < 3
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Make
	the heuristics work for functions with no parameters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-02 17:56:55 +02:00
Dodji Seketeli
5652802eef Avoid emitting local filtered-out changes in more spots
* src/abg-comparison.cc (maybe_report_diff_for_member): Take the
	diff_context in parameter.  Use that to check if local changes of
	category ACCESS_CHANGE_CATEGORY are filtered-out and do not report
	the change in that case.
	({var_diff, enum_diff, class_diff, base_diff,
	function_decl_diff}::report): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-02 17:31:06 +02:00
Dodji Seketeli
64bbb5ccef Add a COMPATIBLE_TYPE_CHANGE_CATEGORY to bidiff --no-harmless
* include/abg-comparison.h
	(diff_category::COMPATIBLE_TYPE_CHANGE_CATEGORY): New enumerator.
	(operator|=(diff_category&, diff_category)): New declaration.
	* include/abg-fwd.h (is_typedef, strip_typedef)
	(types_are_compatible): New declarations.
	* include/abg-ir.h (operator==(const decl_base_sptr, const
	decl_base_sptr)): Added the consts here.
	(operator==(const type_base_sptr, const type_base_sptr)): New
	declaration.
	* src/abg-comp-filter.cc (is_compatible_change): New static
	function.
	(harmless_filter::visit): Detect compatible changes and add the
	sub-tree into the new COMPATIBLE_TYPE_CHANGE_CATEGORY if
	applicable. Cleanup the logic.
	* src/abg-comparison.cc (operator|=(diff_category&,
	diff_category)): Define new function.
	(operator==(const decl_base_sptr l, const decl_base_sptr r)): Add
	consts.
	(operator==(const type_base_sptr l, const type_base_sptr r)):
	Define new operator.
	(is_typedef, strip_typedef, types_are_compatible): New function
	definitions.
	* tests/data/test-diff-filter/test3-report.txt: New test report
	reference.
	* tests/data/test-diff-filter/test3-v0.cc: Source code for new
	test input.
	* tests/data/test-diff-filter/test3-v0.o: New test input.
	* tests/data/test-diff-filter/test3-v1.cc: Source code for new
	test input.
	* tests/data/test-diff-filter/test3-v1.o: New test input.
	* tests/test-diff-filter.cc: Adjust to consume the new tests
	inputs above.
	* tools/bidiff.cc: Add the new COMPATIBLE_TYPE_CHANGE_CATEGORY
	into the --harmless group.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-02 17:23:56 +02:00
Dodji Seketeli
28304c9439 Don't emit local filtered-out changes
* src/abg-comparison.cc (represent): For var_decl, do not emit
	filtered-out local size/offset/access changes.
	(report_name_size_and_alignment_changes): Take the diff context.
	Do not report filtered-out local size/offset changes.
	({var_diff, enum_diff, class_diff, type_decl_diff}::report):
	Adjust.
	* test0-report.txt: Adjust.
	* test01-report.txt: New reference report for the same inputs
	test0-v{1,0}.o, but called without the --no-harmless command line.
	* tests/data/test-diff-filter/test2-v0.cc: Source code for new test input.
	* tests/data/test-diff-filter/test2-v1.cc: Likewise.
	* tests/data/test-diff-filter/test2-v0.o: New test input.
	* tests/data/test-diff-filter/test2-v1.o: Likewise.
	* tests/data/test-diff-filter/test2-report.txt: Reference report
	for new test input.
	* tests/test-diff-filter.cc: Consume the test inputs above.
	* tests/Makefile.am: Add the new test inputs above to the
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-01 16:08:30 +02:00
Dodji Seketeli
70d5afdaa2 Compact & intuitive reporting for changed function parameters
* include/abg-comparison.h (unsigned_changed_parm_map)
	(unsigned_parm_map): New typedefs.
	* src/abg-comparison.cc
	(function_decl_diff::subtype_changed_parms): Renamed this from
	changed_parms.
	(function_decl_diff::priv::subtype_changed_parms_}): Renamed this
	from changed_parms_;
	(function_decl_diff::priv::{deleted_parms_by_id_,
	added_parms_by_id_, changed_parms_by_id_}): New members.
	(function_decl_diff::ensure_lookup_tables_populated): Update the
	new priv::changed_parms_by_id_ member to contain the parameters
	that got changed, as opposed to the subtype_changed_parms_ member
	that contain parameters that got a sub-type change.  The other
	priv::*_by_id_ members are helpers for this.  Update them too.
	(function_decl_diff::subtype_changed_parms): Renamed this from
	::changed_parms.
	(function_decl_diff::report): Report separately about parameters
	having a sub-type change, and parameters that got changed.  Note
	that in both cases, the change is necessarily to a compatible
	type.
	* data/test-diff-dwarf/test2-v0.cc: New test file.
	* data/test-diff-dwarf/test2-v0.o: Likewise.
	* data/test-diff-dwarf/test2-v1.cc: Likewise.
	* data/test-diff-dwarf/test2-v1.o: Likewise.
	* data/test-diff-dwarf/test2-report.txt: Likewise.
	* tests/Makefile.am: Add the new test files above to the
	distribution.
	* tests/test-diff-dwarf.cc: Consume the input files above to
	actually perform a regression test.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-01 12:38:51 +02:00
Dodji Seketeli
847c9e8166 Fix thinko class_diff traversing.
* src/abg-comparison.cc (class_diff::traverse): Fix thinking in
	introduced by commit "6709478 Fix infinite loop when traversing
	classes and their members"
	* tests/data/test-diff-filter/test1-v{0,1}.o: New test binary input files.
	* tests/data/test-diff-filter/test1-v{0,1}.cc: Source code for the
	above.
	* tests/data/test-diff-filter/test1-report.txt: Reference report
	for the diffing of the two binary input files above.
	* tests/test-diff-filter.cc: Make the test run on the new input above.
	* tests/Makefile.am: Add the new material to the distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 13:17:28 +02:00
Dodji Seketeli
33be9938be Add forgotten test output adjustment
* tests/data/test-diff-filter/test0-report.txt: Adjust for the
	commit "a8d5284 Fix diff report indentation issue"
	* tests/data/test-diff-dwarf/test{0,1}-report.txt: Likewise.

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 11:27:32 +02:00
Dodji Seketeli
a8d5284442 Fix diff report indentation issue
* abg-comparison.cc (corpus_diff::report): Indent the details of
	function changes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 11:23:50 +02:00
Dodji Seketeli
6709478816 Fix infinite loop when traversing classes and their members
* src/abg-comparison.cc (TRY_{PRE,POST}_VISIT_CLASS_DIFF): New
	macros.
	(class_diff::priv::traversing_): New flag.
	(class_diff::priv::priv): New constructor to initialize the new
	flag above.
	(class_diff::traversing): Do not traverse the diff again if it's
	being traversed already.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 09:39:49 +02:00
Dodji Seketeli
0951fd93ea Fix access_changed and data_member_offset_changed predicates
* src/abg-comp-filter.cc (access_changed)
	(data_member_offset_changed): Fix detection of membership.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-31 09:38:11 +02:00
Dodji Seketeli
67e6971005 Take filtering in account in diff stats & better categorizing
* include/abg-comparison.h
	(diff_category::ACCESS_CHANGE_CATEGORY): Renamed
	ACCESS_CHANGED_CATEGORY into this.
	(diff_category::SIZE_OR_OFFSET_CHANGE_CATEGORY): Renamed
	SIZE_CHANGED_CATEGORY into this.  Changed its semantics to
	incorporate offset changes as well.
	* src/abg-comparison.cc (struct noop_deleter): Move this up.
	(represent): Do not report filtered out data members.
	(report_mem_header): Add a new num_filtered parameter to take
	filtered-out members in account in members report headers.
	Adjust.
	(class_diff::priv::{count_filtered_bases,
	count_filtered_data_members, count_filtered_member_functions}):
	New member functions.  When a member is filtered, do not report
	it all.
	({enum_diff, class_diff}::report): Adjust.  Take filtered members
	into account in headers.
	(corpus_diff::priv::apply_filters_and_compute_diff_stats): New
	member function.
	(corpus_diff::priv::emit_diff_stats): Renamed
	emit_corpus_diff_stats into this.  Change it to take the stats in
	parameter.
	(corpus_diff::report): Adjust to re-use the above.  Filter
	varibles as well.  Take the filtered functions & variables in
	account in the stats.  Do not report filtered-out functions &
	variables at all.
	* src/abg-comp-filter.cc (type_size_changed, access_changed)
	(data_member_offset_changed): New predicates.
	({harmless, harmful}_filter::visit): Adjust to use the new
	predicates above.  Update the harmful variant for the new
	SIZE_OR_OFFSET_CHANGE_CATEGORY category.
	* tools/bidiff.cc (set_diff_context_from_opts): Adjust for the
	categories name changes.
	* tests/data/test-diff-filter/test0-report.txt: New test input.
	* tests/data/test-diff-filter/test0-v0.cc: Likewise.
	* tests/data/test-diff-filter/test0-v0.o: Likewise.
	* tests/data/test-diff-filter/test0-v1.cc: Likewise.
	* tests/data/test-diff-filter/test0-v1.o: Likewise.
	* tests/test-diff-filter.cc: New test harness.
	* tests/Makefile.am: Add the new test files above to the
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-29 10:26:45 +01:00
Dodji Seketeli
e55a7e3397 Fix var_diff length determination
* src/abg-comparison.cc (var_diff::length):  Just compare the two
	diff subjects.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-29 10:26:45 +01:00
Dodji Seketeli
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