Commit Graph

283 Commits

Author SHA1 Message Date
Dodji Seketeli
76bfae5aac Ensure added/removed member functions have their symbols added/removed
* include/abg-comparison.h (diff_context::{set_corpora,
	get_first_corpus, get_second_corpus}): Declare new member
	functions.
	* src/abg-comparison.cc (diff_context::{set_corpora,
	get_first_corpus, get_second_corpus}): Define them.
	(compute_diff): In the overload for corpus_sptr stick the corpora
	being compared, into the diff context.
	(class_diff::ensure_lookup_tables_populated): If a member function
	is allegedly removed, check that its underlying symbol is removed
	from the corpus as well.  Otherwise, consider that the member
	function hasn't been removed.  Likewise, if a member function is
	allegedly added, check that its underlying symbol has been added
	to the corpus as well.  Otherwise, consider that the member
	function hasn't been added.  The symbols can now be accessed
	through the two corpora that are now present in the diff context.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-29 18:15:48 +02:00
Dodji Seketeli
e2d450176b Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
	Declare new accessors.
	(corpus::lookup_{variable,function}_symbol): Declare new member
	functions.
	* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
	Define new accessors.
	(corpus::lookup_{variable,function}_symbol): Define new member
	functions.
	* include/abg-ir.h (string_elf_symbol_sptr_map_type)
	(string_elf_symbol_sptr_map_sptr, elf_symbols)
	(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
	convenience typedefs.
	(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
	has_aliases, add_alias, get_id_string,
	get_name_and_version_from_id, operator=}): Declare new member
	functions.
	* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
	get_next_alias, has_aliases, add_alias, get_id_string,
	get_name_and_version_from_id, operator=}): Define new member
	functions.
	* include/abg-reader.h (read_corpus_from_file): Take a shared
	pointer to corpus.
	* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
	(build_elf_symbol_db, build_elf_symbol_from_reference)
	(read_symbol_db_from_input): Define new functions.
	(read_corpus_from_input): Adjust.  Make it read symbol databases.
	(build_elf_symbol): Harden this.
	(build_{var,function}_decl): Read the symbol reference.  Do not
	read the local symbol serialization anymore.
	(read_corpus_from_archive): Adjust.
	(read_corpus_from_file): Take a reference to a shared pointer to
	corpus, rather than a reference to the corpus.
	(read_corpus_from_native_xml): Only keep the overload that returns
	a corpus.  Set the current context with the corpus.
	* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
	(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
	(read_context::{fun_sym_addr_sym_index_map_,
	var_sym_addr_sym_index_map_): Remove.
	(read_context::{fun,var}_addr_sym_map_): New.  Replace the above
	that got removed.
	(read_context::{var,fun}_syms_): New.
	(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
	(read_context::{fun,var}_addr_sym_map{_sptr}): New.
	(read_context::{fun,var}_syms{_sptr}): New.
	(read_context::load_symbol_maps): Replace
	read_context::load_symbol_addr_to_index_maps.  Adjust to load all
	the new maps.
	(read_context::maybe_load_symbol_maps): New.
	(read_debug_info_into_corpus): Renamed build_corpus into this.
	Update to load symbol maps and set it to the corpus.
	* src/abg-writer.cc (write_context::get_fun_symbol_map): New
	accessor.
	(write_elf_symbol_aliases, write_elf_symbol_reference)
	(write_elf_symbols_table): Define new static functions.
	(write_var_decl): Write the reference to the underlying symbol of
	the variable.  Do not write the full symbol here anymore.
	(write_function_decl):  Likewise, write the reference to the
	underlying symbol of the function.  Do not write the full symbol
	here anymore.
	(write_corpus_to_native_xml): Write the symbol databases at the
	beginning of the corpus document.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
	corpus has symbols, check if a the symbol of an allegedly deleted
	function (resp. variable) is deleted; if not, then do not report
	the function (resp. variable) as deleted.  Similarly, check if the
	symbol of an allegedly added function (resp. variable) is added.
	if not, the do not report the function (resp. variable) as added.
	* tests/test-write-read-archive.cc (main): Adjust.
	* tools/biar.cc (extract_tus_from_archive): Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Adjust.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 16:33:35 +02:00
Dodji Seketeli
cf80e9d378 Support debug info files being outside the expected system directories
* include/abg-dwarf-reader.h (read_corpus_from_elf): Take a
	debug_info_root_path parameter.
	src/abg-dwarf-reader.cc (create_default_dwfl): Take a
	debug_info_root_path.  Use that to initialize the Dwfl_Callbacks
	structure used by dwfl_begin.
	(create_default_dwfl_sptr, read_corpus_from_elf): Likewise, Take a
	debug_info_root_path parameter.
	* tests/test-diff-dwarf.cc (main): Adjust.
	* tests/test-read-dwarf.cc (main): Likewise.
	* tools/bidiff.cc (options::dir_root_path[12]): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the --debug-info-dir[12]
	options.
	(parse_command_line): Handle the new --debug-info-dir[12] options.
	(main): Pass the debug info directories to read_corpus_from_elf.
	* bidw.cc (options::::di_root_path): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the new --debug-info-dir
	option.
	(parse_command_line): Handle the new --debug-info-dir.
	(main): Pass the debug info root path to read_corpus_from_elf.
	* tools/bilint.cc (options::di_root_path): New member.
	(options::options): Initialize it.
	(display_usage): Add help string for the new --debug-info-dir.
	(parse_command_line): Handle --debug-info-dir command line option.
	(main): Pass the debug info root path to read_corpus_from_elf.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-22 13:14:44 +02:00
Dodji Seketeli
4d0de72a85 Support decl cloning when seeing DW_AT_abstract_origin
* include/abg-ir.h ({var,function}_decl::clone): New method.
	* src/abg-dwarf-reader.cc (die_die_attribute): Add a flag to avoid
	looking through DW_AT_abstract_origin attribute here.
	(build_function_decl): Set the linkage name from
	DW_AT_linkage_name if it's not set yet.
	(build_ir_node_from_die): For DW_TAG_{variable,subprogram}, when
	we see DW_AT_abstract_origin, clone the decl they refer to.
	Also, avoid dropping the DIE on the floor just because it doesn't
	have die_is_artificial here.
	* src/abg-ir.cc ({var,function}_decl::clone): Implement this.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-20 18:22:14 +02:00
Dodji Seketeli
335d8786b2 Serialize and de-serialize elf symbols for var & function decls
* abg-ir.h (string_to_elf_symbol_type, string_to_elf_symbol_binding):
	Declare new entry points.
	* src/abg-ir.cc (string_to_elf_symbol_type)
	(string_to_elf_symbol_binding): Define new entry points.
	* include/abg-libxml-utils.h (xml_char_sptr_to_string): Declare
	new entry points.
	* src/abg-libxml-utils.cc (xml_char_sptr_to_string): Define new
	entry points.
	* src/abg-reader.cc (read_elf_symbol_type)
	(read_elf_symbol_binding, build_elf_symbol): Define new static
	functions.
	(build_function_decl, build_var_decl): Use the new
	build_elf_symbol and set the symbol to the function.  Flag the
	function as having a public symbol in the symbol table if the
	symbol is public.
	* src/abg-writer.cc (write_elf_symbol_type)
	(write_elf_symbol_binding, write_elf_symbol): Define new static
	functions.
	(write_var_decl, write_function_decl): Use the new
	write_elf_symbol to serialize the symbol for the decl.
	* tests/data/test-read-dwarf/test[01].abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-14 11:19:34 +02:00
Dodji Seketeli
ce1278c3da Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
	* include/abg-dwarf-reader.h (enum symbol_type)
	(enum symbol_binding): Move these into abg-ir.h.
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
	Adjust.
	* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
	Declare this before using it.
	(die_address_attribute, die_location_address)
	(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
	(find_hash_table_section_index, find_symbol_table_section)
	(find_symbol_table_section_index, find_text_section)
	(find_bss_section, compare_symbol_name)
	(get_symbol_versionning_sections get_version_for_symbol)
	(lookup_symbol_from_sysv_hash_tab)
	(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
	(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
	(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
	(maybe_adjust_var_sym_address): New static functions.
	(enum hash_table_kind): New enum.
	(struct gnu_ht): New struct.
	(read_context::var_decls_to_add_): Renamed var_decls_to_add into
	this.
	(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
	(read_context::{lookup_symbol_from_elf,
	lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
	lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
	var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
	get_function_address, get_variable_address}): New member
	functions.
	(read_context::lookup_public_{variable,
	function}_symbol_from_elf): Adjust.
	(op_pushes_constant_value): Fix a bug here.
	(lookup_symbol_from_elf): Adjust.  Support cases where there is no
	elf hash table, e.g, for relocatable files.
	(lookup_public_function_symbol_from_elf)
	(lookup_public_variable_symbol_from_elf): Adjust.
	(build_var_decl): Allow updating the var_decl to associate it with
	its underlying symbol.  In that case, if the linkage name is not
	set, set it to the symbol name.
	(build_function_decl): Likewise for function_decl.
	(operator<<(std::ostream&, symbol_type)):
	(operator<<(std::ostream&, symbol_binding)): Move these do
	abg-ir.cc.
	* include/abg-ir.h (class elf_symbol): Declare new class.  Move
	enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
	elf_symbol::binding and elf_symbol::type here.
	(operator<<(std::ostream&, elf_symbol::type))
	(operator<<(std::ostream&, elf_symbol::binding))
	(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
	operators.
	(class elf_symbol::version): Declare new class.
	(class var_decl): Make this pimpl, and add ...
	(var_decl::{g,s}et_symbol): ... new member functions.
	(class function_decl): Likewise, make this pimpl and add ...
	(function_decl::{g,s}et_symbol): ... new member functions.
	* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
	types.
	(elf_symbol::*): Lots of new members and member functions.
	(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
	(operator<<(std::ostream&, elf_symbol::type)): New.
	(operator<<(std::ostream&, elf_symbol::binding)): New.
	(elf_symbol::version::priv): New type.
	(elf_symbol::version::*): Lots of member functions.
	(get_linkage_name): Removed.
	(var_decl::priv): New type.  Pimplify the thing.
	(var_decl::{s,g}et_symbol): New.
	(var_decl::operator==): Take symbols in account in the comparison.
	(function_decl::priv): New type.
	(function_decl::*): Pimplify.
	(function_decl::{s,g}et_symbol): New.
	(function_decl::operator==): Take symbols in account in the
	comparison.
	* include/abg-comparison.h (diff_context::show_linkage_name): New
	member function.
	* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
	New member.
	(diff_context::priv::priv): Initialize it.
	(diff_context::show_linkage_names): New member function.
	(corpus_diff::report): If the user used --show-linkage-names,
	display the linkage name after the name of the functions.  Add
	missing "'" in the some spots.
	* tools/bidiff.cc (options.show_linkage_names): New member.
	(display_usage, parse_command_line): Support --linkage-names.
	* tools/bisym.cc (show_help): Add '\n' at the end of help string
	for --demangle.  Add --no-absolute-path option.
	(parse_command_line): Support --no-absolute-path.
	(main): Adjust for symbol (versionning) support.  Consider that
	the program successfully completed even when the symbol wasn't
	found.  Support --no-absolute-path.
	* tests/data/test-lookup-syms/test0-report.txt: New.
	* tests/data/test-lookup-syms/test01-report.txt: New.
	* tests/data/test-lookup-syms/test02-report.txt: New.
	* tests/data/test-read-dwarf/test0.abi: Adjust.
	* tests/data/test-read-dwarf/test1.abi: Adjust.
	* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
	* tests/data/test-diff-filter/test10-report.txt: Adjust.
	* tests/data/test-diff-filter/test12-report.txt: Adjust.
	* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
	* tests/data/test-lookup-syms/test1.c: New.
	* tests/data/test-lookup-syms/test1.version-script: New.
	* tests/test-lookup-syms.cc: Adjust for new tests.
	* test/Makefile.am: Adjust makefile.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-12 16:09:47 +02:00
Dodji Seketeli
bdf9e956d8 Rename decl_base::get_mangled_name into decl_base::get_linkage_name
* include/abg-ir.h (decl_base::get_linkage_name): Renamed
	decl_base::get_mangled_name into this.
	* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated)
	(function_decl_diff::report, type_decl_diff::report)
	(corpus_diff::priv::ensure_lookup_tables_populated)
	(corpus_diff::report, compute_diff): Adjust.
	* src/abg-corpus.cc ({var_comp, func_comp}::operator()): Likewise.
	(corpus::priv::build_symbol_table): Likewise.
	* src/abg-dwarf-reader.cc (die_linkage_name): Renamed
	die_mangled_name into this.
	(die_loc_and_name, build_translation_unit_and_add_to_ir)
	(build_namespace_decl_and_add_to_ir, build_type_decl)
	(build_enum_type, build_class_type_and_add_to_ir)
	(build_typedef_type, build_var_decl, build_function_decl, ): Adjust.
	* src/abg-hash.cc (decl_base:#️⃣:operator()): Likewise.
	* src/abg-ir.cc (decl_base::priv::linkage_name_): Renamed
	decl_base::priv::mangled_name_ into this.
	(decl_base::priv::priv, decl_base::{decl_base, operator==})
	(get_linkage_name, typedef_decl::typedef_decl, var_decl::var_decl)
	(function_decl::function_decl, class_decl::base_spec::base_spec)
	(class_decl::method_decl::method_decl): Adjust.
	(decl_base::{g,s}et_linkage_name): Renamed
	decl_base::{g,s}et_mangled_name into this.
	* src/abg-writer.cc (write_decl, write_typedef_decl)
	(write_var_decl, write_function_decl, dump): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-11 19:22:00 +02:00
Dodji Seketeli
12c777681d Support symbol lookups from ELF
* include/abg-dwarf-reader.h (symbol_type, symbol_binding): New
	enums.
	(operator<<): Declare new overloads for the new enums above.
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
	Declare new entry points.
	* src/abg-dwarf-reader.cc (lookup_symbol_from_elf)
	(lookup_public_function_symbol_from_elf)
	(lookup_public_variable_symbol_from_elf): Define new static
	functions.
	(read_context::elf_{module_, handle}_): New data members.
	(read_context::{elf_module, elf_handle}): New accessors.
	(read_context::load_debug_info): Store the elf module into
	read_context::_elf_module_.  Adjust.
	(read_context::{lookup_symbol_from_elf,
	lookup_public_function_symbol_from_elf,
	lookup_public_variable_symbol_from_elf}): New member functions.
	(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf)
	(operator<<): Define public entry points.
	* tools/bisym.cc: New tool to lookup a symbol in an elf file.
	* tools/Makefile.am: Add the bisym.cc source file to the
	distribution and arrange to compile it into a 'bisym' executable.
	* tests/test-lookup-syms.cc: New test harness.
	* tests/data/test-lookup-syms/test0-report.txt: New test input
	for the harness above.
	* tests/data/test-lookup-syms/test0.cc: Likewise.
	* tests/data/test-lookup-syms/test0.o: Likewise
	* tests/data/test-lookup-syms/test01-report.txt: Likewise.
	* tests/data/test-lookup-syms/test02-report.txt: Likewise.
	* tests/Makefile.am: Build the new runtestlookupsyms test and add
	the new files to the distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 17:56:40 +02:00
Dodji Seketeli
2ce2eff68e Add corpus::{s,g}et_origin accessors
* include/abg-corpus.h (enum corpus::origin): New enum.
	(corpus::{g,s}et_origin): New accessors.
	* src/abg-corpus.cc (corpus::priv::origin): New data member.
	(corpus::priv::is_symbol_table_built): Move this up.
	(corpus::priv::priv): Adjust.
	(corpus::{g,s}et_origin): Define accessors.
	* src/abg-dwarf-reader.cc (read_corpus_from_elf): Set the corpus
	origin.  Also set the path.  Oops.
	* src/abg-reader.cc (read_corpus_from_input)
	(read_corpus_from_archive): Set the corpus origin.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 17:22:11 +02:00
Dodji Seketeli
0d55047a4e Add a get_linkage_name function.
* include/abg-fwd.h (is_at_global_scope): Declare a new overload.
	(get_linkage_name): Declare ...
	* src/abg-ir.cc (get_linkage_name): ... these new entry points.
	(is_at_global_scope): Define these new overloads useful for the
	new get_linkage_name.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 17:14:30 +02:00
Dodji Seketeli
e2c776f4bc Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
	(decl_base::priv_): New pimpl.
	(decl_base::{hashing_started, peek_hash_value,
	peek_qualified_name, set_qualified_name}): Declare new protected
	methods.
	(decl_base::{get_context_rel, set_qualified_name, get_location,
	set_location, set_name, set_mangled_name, get_visibility,
	set_visibility}): Move these out-of-line.
	(decl_base::{g,s}et_is_public_symbol_table):
	(class_decl::hashing_started): Remove this as we now have
	decl_base::hashing_started.
	(decl_base::{hash_, hashing_started, location_, context_, name_,
	qualified_parent_name_, qualified_name_, mangled_name_,
	visibility_}): Move all these members into the new ...
	* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
	(decl_base::decl_base): Move these out-of-line here.  Adjust the
	other overloads.
	(decl_base::{hashing_started, peek_hash_value,
	peek_qualified_name, set_qualified_name}): Define these new
	protected methods.
	(decl_base::{get_context_rel, set_context_rel, get_location,
	set_location, set_name, get_mangled_name, set_mangled_name,
	get_visibility, set_visibility}): Define these out-of-line here.
	(decl_base::{get_hash, set_hash, get_scope,
	get_qualified_parent_name, get_qualified_name, operator==,
	set_scope}): Adjust.
	(qualified_type_def::get_qualified_name): Likewise.
	(pointer_type_def::get_qualified_name): Likewise.
	(reference_type_def::get_qualified_name): Likewise.
	(var_decl::set_scope): Likewise.
	(class_decl::base_spec): Likewise.
	(class_decl::method_decl::set_scope): Likewise.
	(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
	* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
	scope_type_decl, qualified_type_def, pointer_type_def,
	reference_type_def, enum_type_decl, typedef_decl, var_decl,
	class_decl}:#️⃣:operator): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 17:13:46 +02:00
Dodji Seketeli
262c39f763 Categorize base class changes as SIZE_OR_OFFSET_CHANGE_CATEGORY
* include/abg-comparison.h (class_diff::{deleted, inserted,
	changed}_bases): Declare new member functions ...
	* src/abg-comparison.cc ((class_diff::{deleted, inserted,
	changed}_bases)): ... and define them.
	* src/abg-comp-filter.cc (base_classes_added_or_removed): Define
	new static functions.
	(harmless_filter): Categorize base classes added or removed.
	* tests/data/test-diff-dwarf/test8-report.txt: New test input.
	* tests/data/test-diff-dwarf/test8-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test8-v0.o: Likewise.
	* tests/data/test-diff-dwarf/test8-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test8-v1.o: Likewise.
	* tests/data/test-diff-filter/test13-report.txt: New test input.
	* tests/data/test-diff-filter/test13-v0.cc: Likewise.
	* tests/data/test-diff-filter/test13-v0.o: Likewise.
	* tests/data/test-diff-filter/test13-v1.cc: Likewise.
	* tests/data/test-diff-filter/test13-v1.o: Likewise.
	* tests/Makefile.am: Add the new files above to the source distribution.
	* tests/test-diff-dwarf.cc: Use the new relevant input above to
	run more tests.
	* tests/test-diff-filter.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-17 15:37:53 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Dodji Seketeli
e3113a2ea2 Fix documentation for the diff_utils namespace
* include/abg-diff-utils.h (namespace diff_utils): Add comment.
	(compute_diff): Update comments for some overloads where they were
	missing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-24 22:47:14 +01:00
Dodji Seketeli
9ed0572f16 Proper support for diffing member types
* include/abg-comparison.h (class member_type_diff): New class.
	(member_type_diff_sptr): New convenience typedef.
	(compute_diff): New overload for member_type_diff.
	* src/abg-comparison.cc (struct member_type_diff::priv): New
	definition.
	(member_type_diff::{first_member_type, second_member_type,
	underlying_type_diff, length}): New member function definitions.
	(compute_diff): New definition for member type diffs.
	(compute_diff_for_types): Support diffing
	member types.
	(class_diff::report): Do not use strip member types now that we
	can properly diff them.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
aa7ac96d62 Fix the support for printing cv-qualified names
* include/abg-ir.h (decl_base::{location_, name_,
	qualified_parent_name_, qualified_name_}): Make these data members
	protected rather than private.
	(decl_base::get_qualified_parent_name): Declare new member
	functions.
	(decl_base::get_qualified_name): Make the core overload virtual.
	Simplify the other overload that calls the core one.
	(qualified_type_def::build_name): Declare new protected helper
	function.
	(qualified_type_def::{get_cv_quals_string_prefix,
	get_qualified_name}): Declare new functions.
	(pointer_type_def::{get_qualified_name}}): Likewise.
	(class_decl::member_type::get_qualified_name): Likewise.
	* src/abg-ir.cc (decl_base::get_qualified_parent_name): New
	definition.
	(decl_base::get_name): Make this out-of-line.
	(decl_base::get_qualified_name): The signature of this got
	simplified.  Make it use the new get_qualified_parent_name.
	(qualified_type_def::{build_name, get_qualified_name,
	get_cv_quals_string_prefix}): New definitions.
	(qualified_type_def::qualified_type_def): Update the constructor
	to use the new build_name function above.
	(pointer_type_def::get_qualified_name): New definitions.
	(reference_type_def::get_qualified_name): Likewise.
	(class_decl::member_type::get_qualified_name): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
56973d0ac3 Put the setter of access specifiers in class_decl::member_base
* include/abg-ir.h
	(class_decl::member_base::set_access_specifier): Put the setter
	for access specifier here, where it belongs ...
	(class_decl::member_type::set_access_specifier): ... not here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
bce6bba514 Do not forget to set the indexes of fn parms
* include/abg-ir.h (function_type::function_type): In the
	constructor that takes a vector of parms, walk the vector and set
	the indexes of the parms.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 14:22:18 +01:00
Dodji Seketeli
82e83d9c5e Better support of static member variables
* include/abg-fwd.h (fqn_to_components)
	(lookup_type_in_translation_unit, demangle_cplus_mangled_name):
	Declare new public entry points
	* src/abg-comparison.cc (corpus_diff::report): Report stuff about
	global variables using their mangled name, and demangle them.  If
	there is no mangled name for the variable, then use its pretty
	representation.
	(compute_diff): For the corpus overload, compare global variables
	using their mangled name, if its available; otherwise, fall back
	to using their pretty representation.
	* src/abg-corpus.cc (var_comp::operator()(const var_decl*,
	const_var_decl*)): Compare variables using their mangled name in
	priority.  If it's not available then use their pretty
	representation.
	* src/abg-dwarf-reader.cc
	(read_context::var_decls_to_re_add_to_tree): New accessor.
	(build_translation_unit_and_add_to_ir): If there is what appears
	to be a definition of a static member variable variable -- this is
	in case this definition lacks the DW_AT_specification attribute
	that links it to the DW_TAG_member or DW_TAG_variable DIE that is
	a child of the right class/structure DIE -- that is not at the
	right place in the DIE tree, remove it from the its current place
	in the tree and try to hang it off of the right DIE.  To do this,
	de-mangle its mangled name, look at what is supposed to be the
	parent class name, look it up in the translation unit IR, and if
	found, stick the variable IR node in there, as a static member
	variable.  If not found, then bad luck.
	(build_class_type_and_add_to_ir): Do not try to see if a member
	variable is static here as the way I was doing it was unreliable.
	Build the data member node directly w/o going through building a
	variable node first.  Register the data member in the die offset
	-> IR node map.
	(build_ir_node_from_die): When seeing DW_TAG_variable, look for a
	DW_AT_specification attribute.  If there is one, then it points to
	a the DIE of a data member and means that data member is static.
	Flag the IR node of that data member as static thus.  Update the
	die offset -> IR node map.  If there is no DW_AT_specification
	attribute or if it doesn't point to a data member DIE, schedule
	this variable tag for a stage when after the whole IR is built for
	the translation unit, the variable's mangled named is inspected,
	its hypothetical parent struct/class is looked up and the variable
	IR node is put into the node of the right struct/class IR node.
	* src/abg-ir.cc (enum lookup_entity_kind): New.
	(fqn_to_components, iterator, lookup_type_in_translation_unit)
	(lookup_node_in_translation_unit, lookup_type_in_translation_unit)
	(demangle_cplus_mangled_name): New function definitions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:50 +01:00
Dodji Seketeli
1046ba96e6 Unset decl scope when removing the decl from its scope
* src/abg-ir.cc (remove_decl_from_scope): Unset the scope of the
	decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:49 +01:00
Dodji Seketeli
278520086e Add class_decl::member_base::set_is_static() accessor
* include/abg-ir.h (class_decl::member_base::get_is_static):
	Rename is_static into get_is_static.
	(class_decl::member_base::set_is_static): New accessor.
	* src/abg-comparison.cc (represent): Adjust for
	class_decl::member_base::is_static -> get_is_static.
	* src/abg-corpus.cc (symtab_build_visitor_type::visit): Likewise.
	src/abg-hash.cc (class_decl::member_function:#️⃣:operator()):
	Likewise.
	* src/abg-ir.cc (class_decl::member_base::operator==): Likewise.
	* src/abg-writer.cc (write_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 16:04:45 +01:00
Dodji Seketeli
fd21fea696 Add --{changed,deleted,added}-{fns,vars} options to bidiff
* include/abg-comparison.h
	(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Declare
	new accessors.
	(corpus_diff::context): Declare new getter.
	* src/abg-comparison.cc
	(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Define
	these new accessors.
	(corpus_diff::priv::emit_corpus_diff_stats): Define new function.
	(corpus_diff::context()): Define new getter.
	(corpus_diff::report): Use the new
	corpus_diff::priv::emit_corpus_diff_stats to emit diff stats at
	the beginning of the report.  Conditionalise emitting the
	different parts of the reports (changed,deleted,added stuff) on
	the values of the new properties that were just added.
	* tools/bidiff.cc
	(options::{show_{deleted,changed,added}_{fns,vars}): New
	properties.
	(display_usage, parse_command_line): Update for the newly added
	--{changed,deleted,added}-{fns,vars} command line options.
	(set_diff_context_from_opts): Define new static function.
	(main): Create a diff context, initialize it from the options
	(using set_diff_context_from_opts) and pass it to compute_diff.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-12 16:42:14 +01:00
Dodji Seketeli
9b1e3cd86a Do not forget to traverse member types
* include/abg-ir.h (class_decl::member_type::traverse): Declare new virtual
	function.
	(ir_node_visitor::visit): Declare new virtual function
	* src/abg-ir.cc (class_decl::member_type::traverse): Implement the
	traversal of a member type.
	(ir_node_visitor::visit): Provide a default implementation for the
	visitor of member type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-11 16:14:53 +01:00
Dodji Seketeli
cc5af46601 From DWARD, avoid adding IR nodes for member functions twice
* include/abg-fwd.h (as_non_member_class_decl): Declare new overload.
	* src/abg-ir.cc (as_non_member_class_decl): Define new overload.
	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Add
	member functions to the DIE -> IR Node map.
	(build_ir_node_from_die): Assert that DW_TAG_subprogram cannot be
	for a member function here because getting the scope of the member
	function would have constructed the entire class that contains it,
	including the member function.  Then, calling
	build_ir_node_from_die for the DIE of the member function would
	find the already IR Node in the DIE -> IR Node map.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-11 16:04:24 +01:00
Dodji Seketeli
a5b80d8203 Fix access specifiers value
* include/abg-ir.h (class_decl::enum access_specifier): Give the enumerators
	the same values as what the DWARF spec says.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-11 15:59:12 +01:00
Dodji Seketeli
67829e0daa Misc diff report cleanups
* include/abg-ir.h (function_decl::parameter::get_type_name): Add
	comment.
	(function_decl::parameter::get_type_pretty_representation): New
	member fn.
	* src/abg-comparison.cc (represent): When representing changed
	members, use their pretty representation.
	(function_decl_diff::{ensure_lookup_tables_populated, report}): Use the
	pretty representation of parameters type.
	(typedef_diff::report): Enclose the underlying type in "'".
	(corpus_diff::report): Add proper spacing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 21:31:19 +01:00
Dodji Seketeli
6f3506215b Support diffing entities of different kinds.
* include/abg-comparison.h (class distinct_diff): Declare new
	type.
	(compute_diff_for_distinct_kinds): Declare new function.
	* src/abg-comparison.cc (distinct_diff::{distinct_diff, first,
	second, entities_are_of_distinct_kinds, length, report}): Define
	new member functions.
	(compute_diff_for_distinct_kinds, try_to_diff_distinct_kinds):
	Define new function.
	(compute_diff_for_types, compute_diff_for_decls): Support diffing
	entities of different kinds.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:11 +01:00
Dodji Seketeli
ce9a34ba92 More optimizations hinted by profiling
* include/abg-ir.h (decl_base::qualified_name_): New member.
	(decl_base::get_qualified_name): Cache the qualified name.
	(decl_base::get_type): Return a reference on the shared pointer.
	(method_type::get_class_type): Likewise.
	(class_decl::get_definition_of_declaration): Likewise.
	(class_decl::member_type::get_underlying_type): Likewise.
	(class_decl::base_spec::get_base_class): Likewise.
	* src/abg-ir.cc (decl_base::get_qualified_name): Implement the
	caching.
	(class_decl::member_type::get_qualified_name): Return a reference
	on the shared pointer.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
d8046e575d Avoid crashing when getting function parm type name
* include/abg-ir.h (function_decl::parameter::get_type_name): New
	member function.
	* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): Use the new
	member function above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
ef94728513 Small optimization hinted by profiling
* include/abg-diff-utils.h (d_path_vec::max_d): Avoid using member
	functions.  This is relevant only when compiling w/o optimization.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
de342efd76 Fix allocation of diff_utils::d_path_vec
* include/abg-diff-utils.h (d_path_vec::d_path_vec):  Do not
	forget to allocate enough data for reverse vectors as well.  The
	comment of the constructor is accurate.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
cb764d3cdf Misc style fixes
* include/abg-hash.h (combine_hashes): Remove trailing white
	spaces.
	* include/abg-ir.h (class function_decl): Add end-of-class
	comment.
	(struct type_base::cached_hash): Fix comment.
	* src/abg-comparison.cc: Remove useless new line.
	* src/abg-corpus.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
9905d847d2 Support looking through decl-only classes and update diff reports
accordingly

	* include/abg-comparison.h (class diff_context): New class.
	(class diff::{ctxt_, reported_once_, currently_reporting_}): New
	data members.
	(diff::diff): Initialize the new data members above.
	(diff::{context, currently_reporting, reported_once}): New
	accessors.
	(compute_diff, var_diff::var_diff, pointer_diff::pointer_diff)
	(reference_diff::reference_diff, qualified_type_diff)
	(enum_diff:enum_diff, class_diff::class_diff)
	(scope_diff::scope_diff, function_decl_diff::function_decl_diff)
	(type_decl_diff::type_decl_diff, typedef_diff::typedef_diff)
	(translation_unit_diff::translation_unit_diff, corpus_diff::corpus_diff):
	Take an additional pointer to diff_context.
	* abg-comparison.cc (diff_context::{has_diff_for,
	has_diff_for_types, add_diff}): New methods.
	(try_to_diff, compute_diff_for_types, compute_diff_for_decls)
	(represent): Take an additional pointer to
	diff_context in argument.  In the later function, do not re-report
	a diff if it has already been reported, or if it's being reported
	already.
	(var_diff::var_diff, pointer_diff::pointer_diff)
	(reference_diff::reference_diff)
	(qualified_type_diff::qualified_type_diff, enum_diff::enum_diff)
	(class_diff::class_diff, scope_diff::scope_diff)
	(function_decl_diff::function_decl_diff, type_decl::type_decl)
	(typedef_diff::typedef_diff)
	(translation_unit_diff::translation_unit_diff)
	(corpus_diff::corpus_diff): Take an additional pointer to
	diff_context in argument.
	({pointer_diff, qualified_type_diff,
	reference_type_diff}::report): do not re-report a diff about the
	underlying type if it has already been reported, or if it's being
	reported already.
	(enum_diff::report): Fix this to properly use the populated lookup
	tables.
	(compute_diff): take an additional pointer to diff_context in
	argument. For the var_decl, pointer_diff reference_type_diff,
	qualified_type_diff enum_diff, scope_diff, function_decl_diff,
	type_decl_diff and typedef_diff overloads, do not re-build a diff
	object, if one exits already.  Otherwise, record the new diff
	object created so that it can be re-used later.
	(enum_diff::ensure_lookup_tables_populated): Fix logic to avoid
	one loop.
	(class_decl::priv::{deleted_member_functions_,
	inserted_member_functions_, changed_member_function_}): New
	members to support reporting about member functions changes.
	(class_decl::{lookup_tables_empty, clear_lookup_tables, length):
	Update for the new additions above.
	(class_decl::ensure_lookup_tables_populated): Likewise.  Fix to
	properly use the lookup tables and also avoid a going through
	several loops to compute the changed members.
	(class_decl::report): Flip a switch to make the beginning and end
	of the reporting, in the context.  Also, do not try to report
	again, if we were already reporting this diff.  Fix quite some
	spots to properly use the lookup tables.
	(scope_diff::ensure_lookup_tables_populated): Skip decl-only
	classes during comparison. Fix some thinkos.  Fix logic to avoid a
	loop.
	(scope_diff::report): Adjust to pass a context to
	compute_diff_for_types.
	(function_decl_diff::ensure_lookup_tables_populated): Fix logic to
	avoid a loop.
	(function_decl_diff::report): Adjust call to
	compute_diff_for_types to pass the context.
	(typedef::report): Avoid re-reporting the diff of the underlying
	types, if we are already reporting it.
	(corpus_diff::priv::ensure_lookup_tables_populated): Use the
	pretty representation of the function rather than its name to key
	the maps of deleted and added functions. Fix logic to avoid going
	through an additional loop for the changed functions.
	(corpus_diff::report): Add a title for removed/added/changed
	functions.  Fix indentation for added/removed/changed functions.
	* include/abg-ir.h (class_decl::comparison_started_): New member
	* src/abg-dwarf-reader.cc (is_public_decl): Style fix.
	(is_declaration_only_): New static function.
	(build_class_type_and_add_to_ir): Create decl-only classes (IR) for
	classes flagged as declaration-only in the DWARF.
	* src/abg-hash.cc (class_decl:#️⃣:operator()): Do not forget to
	include the "is_declaration_only" flag into the hashing.
	* src/abg-ir.cc (class_decl::operator==): Look through decl-only
	classes to get their definitions and compare the definitions
	instead.  Avoid comparing member types and fns if the comparison
	of this type has already started.
	* src/abg-reader.cc (build_class_decl): Set the definition of a
	declaration, when we see it.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Update.
	* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
	* tests/data/test-bidiff/test-struct1-report.txt: Likewise.

signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:10 +01:00
Dodji Seketeli
f8e9d43e68 Avoid duplicated entries in the symbol tables of the corpus
* include/abg-ir.h ({var_decl, function_decl}::ptr_equal): New
	  equality functor for pointers to var_decl and function_decl.
	  ({function_decl, var_decl}::hash): Make these hashing functors
	public.
	* include/abg-hash.cc (struct var_decl::hash, struct
	function_decl::hash): Remove these from here.  There are now in
	the public abg-ir.h.
	({var_decl, function_decl}:#️⃣:operator()): Define these here.
	* src/abg-corpus.cc (symtab_build_visitor_type::{fns_map,
	fn_is_in_map, add_fn_to_map, vars_map, var_is_in_map,
	add_var_to_map}): New accessors.
	(corpus::priv::build_symbol_table): Avoid duplicated entries in
	variables and functions symbols tables.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
e8dd2cf705 Ease debugging of abigail::diff_utils::compute_diff
* include/abg-diff-utils.h (compute_diff): Add asserts on for the
	length of the shortest edit script during the divide and conquer
	part of the diff algorithm.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
b219598e7b Fix further reaching reverse path calculation in core diff algo
* include/abg-diff-utils.h (end_of_frr_d_path_in_k_plus_delta):
	Favour moving left when the two abscissas at the previous steps
	are equal.
	(compute_diff): Update the length of the shortest edit script when
	the size of one of the inputs is zero.
	* tests/test-core-diff.cc (in_out_spec): Add a new input to diff
	two sequences for regression testing.
	* tests/data/test-core-diff/report13.txt: New reference for
	the comparison of the new regression test above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
7d19840822 Add debugging facilities for core diffing issues
* include/abg-ir.h (fns_to_str): Declare new fn.
	* src/abg-ir.cc (get_next_string, fn_to_str, fns_to_str): New
	static functions.
	(fns_to_str): Define new fn.
	* tools/abg-tools-utils.cc (dump_functions_as_string)
	(dump_function_names, compare_functions): New functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-10 15:51:09 +01:00
Dodji Seketeli
e6e4e8425e Remove debugging assertion when diffing
* include/abg-diff-utils.h (d_path_vec::at): Do not check for
	bounds.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-20 12:15:07 +01:00
Dodji Seketeli
73814ba4fa Misc Doxygen API doc fixes
* include/abg-comparison.h: Various doxygen api doc string fixes.
	* include/abg-diff-utils.h: Likewise.
	* include/abg-dwarf-reader.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-reader.h: Likewise.
	* include/abg-writer.h: Likewise.
	* src/abg-comparison.cc: Likewise.
	* src/abg-corpus.cc: Likewise.
	* src/abg-dwarf-reader.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-libxml-utils.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:25 +01:00
Dodji Seketeli
a681992d0f Do not loose the member type information when reading them from DWARF
* include/abg-ir.h (class_decl::declaration_):  Make this be a
	decl_base_sptr so that it can actually be a
	class_decl::member_type which underlying type is a class decl.
	(class_decl::{set, get}_earlier_declaration): Take or return a
	decl_base_sptr rather than a class_decl_sptr.
	* src/abg-ir.cc (class_decl::set_earlier_declaration): Take a
	decl_base_sptr rather than a class_decl_sptr.
	* src/abg-dwarf-reader.cc (die_class_map_type): Make this map take
	decl_base_sptr rather than a class_decl_sptr.
	(build_class_type_and_add_to_ir): If the class being currently
	built is a member class, do not loose that information after it
	has been added to its scope.  Also, base types and types of member
	variables can be member types and should retain that information.
	(build_qualified_type): Likewise, the underlying type of a
	qualified type shouldn't loose the information about its
	potentially being a member type.
	(build_pointer_type_def, build_reference_type, build_typedef_type)
	(build_var_decl, build_function_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:25 +01:00
Dodji Seketeli
be14ac2ab2 Fix hashing of member types
* include/abg-ir.h (class_decl::{member_function_template,
	member_class_template}):  Make these inherit from decl_base, to
	comply with class_decl::member_type.
	(class_decl_base_spec::{base_spec, member_type, member_function,
	member_function_template, member_class_template}::hash): Declare
	these hashing functors in the header here.
	(class_decl::{member_base, member_type, data_member,
	member_function, member_function_template,
	member_class_template}:#️⃣:operator()): define these out of
	line here.
	(type_base::dynamic_hash::operator()): Update this to hash member
	things.
	* src/abg-writer.cc (write_qualified_type_def)
	(write_pointer_type_def, write_class_decl)
	(write_reference_type_def, write_enum_type_decl): Add an overload
	that takes the type ID to use in the serialization.
	(write_member_type): New implementation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:25 +01:00
Dodji Seketeli
fbe972012a A Member class can also be a scope for other decls in DWARF
* include/abg-fwd.h (as_non_member_class_decl): Declare ...
	* src/abg-ir.cc (as_non_member_class_decl): ... this new function.
	* include/abg-ir.h (class class_decl::member_type): Add more
	comments about member types.
	* src/abg-dwarf-reader.cc (get_scope_for_die): Use the new
	as_non_member_class_decl here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:24 +01:00
Dodji Seketeli
31b6660832 Misc style fixes
* include/abg-ir.h (location_manager::_Impl): Rename this type
	into priv.
	* src/abg-ir.cc b/src/abg-ir.cc (location_manager::_Impl):
	Likewise.
	(location_manager::location_manager): Update for the renaming
	above.
	* src/abg-reader.cc (build_type_decl): Remove useless white space.
	(build_enum_type_decl, build_class_decl): Use the _sptr typedef in
	the return type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:24 +01:00
Dodji Seketeli
1b0f6b489a Fix apidoc markup
* include/abg-comparison.h (class var_diff): @ref var_decls ->
	@ref var_decl.
	* src/abg-comparison.cc (function_decl_diff::first_function_decl):
	@Return -> @return.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-17 15:44:24 +01:00
Jonathan Wakely
22f6a640e7 Fix checkout & build instructions
* CONTRIBUTING: Fix Git repository url.
	* doc/website/mainpage.txt: Add elfutils into the dependencies
	list and fix the repository directory name.  Also use autoreconf
	-i.
	* include/abg-fwd.h: Fix Git repository URL.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-14 15:39:34 +01:00
Dodji Seketeli
1377f9fb48 Optimize comparison & underlying type accessing
* include/abg-ir.h (qualified_type::get_underlying_type)
	(pointer_type_def::get_pointed_to_type)
	(reference_type_def::get_pointed_to_type)
	(typedef_decl::get_underlying_type): Avoid triggering refcount
	counter increasing/decreasing here, by returning a reference to
	the underlying type.  This showed up high on a profile.
	({scope_decl, type_decl, scope_type_decl, namespace_decl,
	qualified_type_def, pointer_type_def, reference_type_def,
	enum_type_decl, typedef_decl, var_decl, class_decl}::operator==):
	Avoid taking the exception-using path of dynamic_cast.  This
	showed up very high on a profile.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:20 +01:00
Dodji Seketeli
c4991c6444 Escape xml pre-defined entities in native (de-)serialization.
* include/abg-libxml-utils.h (escape_xml_string)
	(unescape_xml_string): Declare new functions.
	* src/abg-libxml-utils.cc (escape_xml_string)
	(unescape_xml_string): Define them.
	* src/abg-reader.cc (build_function_decl, build_var_decl)
	(build_type_decl, build_enum_type_decl, build_class_decl)
	(build_type_tparameter, build_non_type_tparameter)
	(build_template_tparameter, handle_namespace_decl)
	(handle_typedef_decl): Use unescape_xml_string.
	* src/abg-writer.cc (write_type_decl, write_function_decl)
	(write_class_decl, write_type_tparameter)
	(write_non_type_tparameter, write_template_tparameter): Use
	escape_xml_string.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:19 +01:00
Dodji Seketeli
5f97fc781c Implement hash caching
* include/abg-ir.h (decl_base::hash_): New member.
	(decl_base::{g,s}et_hash): New accessors.
	(type_base_::cached_hash): Forward-declare new hasher.
	(struct type_ptr_equal): New equality predicate.
	(type_shared_ptr_equal::operator()): Do not forget to test pointer
	equality.
	(type_base::cached_hash): Declare new hasher.
	* src/abg-hash.cc ({decl_base, type_decl, scope_type_decl,
	qualified_type_def, pointer_type_def, reference_type_def,
	enum_type_decl, typedef_decl, var_decl, function_decl,
	function_decl::parameter, class_decl::data_member,
	class_decl::member_function, class_decl, }:#️⃣:operator()):
	Implement caching.
	(type_base::cached_hash::operator()(const type_base*)): Define.
	(type_base::cached_hash::operator() (const type_base_sptr):
	Define.
	* src/abg-ir.cc (type_ptr_map): Make this map use
	type_base::cached_hash instead of type_base::ptr_hash now.
	(decl_base::decl_base): Initialize the new
	decl_base::hash_. member.
	(decl_base::{s,g}et_hash): Define.
	(decl_base::operator==(const decl_base& other)): Take the hash in
	account to speed up inequality detection.
	* src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map
	into this.  Make it use type_base::cached_hash and type_ptr_equal
	instead of type_base::shared_ptr_hash and type_shared_ptr_equal.
	(get_id_for_type): Add overload for type_base*.  Re-write the
	previous overload in terms of this one.
	(write_context::m_type_id_map): Use type_ptr_map as the type for
	this.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:19 +01:00
Dodji Seketeli
e66393d057 Do not canonicalize types anymore; it's slow and luckily not needed
* src/abg-ir.h (translation_unit::canonicalize_type): Remove.
	* src/abg-dwarf-reader.cc (canonicalize_and_add_type_to_ir)
	(canonicalize_and_insert_type_into_ir)
	(canonicalize_and_insert_type_into_ir_under_scope): Remove.
	(build_enum_type, build_class_type, build_ir_node_from_die):
	Update for removal of type canonicalization.
	* src/abg-ir.cc (translation_unit::canonicalize_type): Remove.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:19 +01:00
Dodji Seketeli
f42a59c3dd Fix class scope setting & member type de-serializing from dwarf
* include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope):
	return the decl added to the scope.
	(as_non_member_type, get_type_declaration): Declare new entry
	points.
	* include/abg-ir.h (class decl_base::insert_decl_into_scope):
	Update this friend declaration.
	(class scope_decl, class_decl): Update the friend add_decl_to_scope
	declaration.
	(scope_decl::add_member_decl): Return the added decl.
	(class_decl_sptr): Move this typedef befoer the class_decl class
	declaration.
	(class_decl::definition_of_declaration_): New member.
	(class_decl::{set_definition_of_declaration,
	get_definition_of_declaration}): New accessors.
	(class_decl::add_member_decl): Return the added member.
	(class_decl::insert_member_type): New member.
	(class_decl::member_base::access_specifier): Make this protected.
	(class_decl::member_type): Make this inherit from type_vase.
	(class_decl::member_type::type_): Remove this member.
	(class_decl::member_type::as_type): Remove this accessor.
	(class_decl::member_type::operator==(const type_base&)): New.
	(class_decl::member_type::operator shared_ptr<type_base>() const):
	Remove.
	(class_decl::member_type::get_underlying_type): New.
	(class_decl::member_type::operator==(const member_type&) const):
	New.
	* src/abg-comparison.cc
	(class_diff::{ensure_lookup_tables_populated, report}): Adjust for
	the removal of class_decl::member_type::as_type.
	* src/abg-dwarf-reader.cc (scope_stack_type): Change this as a
	typedef to stack<scope_decl*>.
	(current_scope): Change return type from scope_decl_sptr to
	scope_decl*.
	(insert_decl_into_scope): New.
	(build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope
	in lieu of add_decl_to_scope.
	(build_class_type_and_add_to_ir): likewise.  Link a class
	definition to its declaration.  Push the current scope on the
	scope stack.  Use as_non_member_type.  Fix setting member types.
	(get_scope_for_die): Look through declaration-only classe to get
	its definition.
	(build_qualified_type, build_pointer_type_def)
	(build_reference_type, build_typedef_type, build_var_decl)
	(build_function_decl): Use as_non_member_type.
	(build_ir_node_from_die): Fix member variable & function adding.
	* src/abg-ir.cc (scope_decl::{add_member_decl,
	insert_member_decl}): Return the added member.
	(add_decl_to_scope): Likewise.
	(insert_decl_into_scope): Likewise.
	(get_top_most_scope_under): Fix logic.
	(get_type_declaration): New overload that return a decl_base*.
	(as_non_member_type): New definition.
	(class_decl::{get_definition_of_declaration,
	set_definition_of_declaration, insert_member_decl}): Likewise.
	(class_decl::add_member_decl): Re-write in terms of
	class::insert_member_decl.
	(class_decl::insert_member_type): New definition.
	(class_decl::add_member_type): Re-write in terms of
	class_decl::insert_member_type.
	(class_decl::remove_member_type): Update for the
	class_decl::member_type::as_type removal.
	(class_decl::{add_data_member, add_member_function,
	add_member_function_template, add_member_class_template}): Call
	scope_decl::add_member_decl.
	(class_decl::member_type::member_type): Update as the type now
	virtually inherits from type_base.
	(class_decl::member_type::{set,get}_access_specifier): New
	definitions.
	(class_decl::member_type::get_underlying_type): Likewise.
	(class_decl::member_type::set_scope): Update wrt
	class_decl::member_type::as_type -> get_underlying_type rename.
	(class_decl::member_type::operator==(const decl_base& other)):
	There is no more class_decl::member_type::as_type.
	(class_decl::member_type::operator==(const type_base& other)):
	New.
	(class_decl::member_type::get_pretty_representation): Update wrt
	class_decl::member_type::as_type -> get_underlying_type rename.
	* src/abg-reader.cc (build_class_decl): New that add
	add_member_decl adds even member types, no need to add it
	explicitly anymore.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 17:36:19 +01:00
Dodji Seketeli
2c9fb3e70d Support new 'abi-corpus' native XML format (.abi)
* include/abg-reader.h (read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Declare new entry points.
	* include/abg-writer.h (write_corpus_to_native_xml)
	(write_corpus_to_native_xml_file): Likewise.
	* src/abg-reader.cc (read_translation_unit_from_input): Renamed
	read_input into this.  Support new 'path' attribute for
	'abi-instr' XML element.
	(read_corpus_from_input): New static function.
	(read_translation_unit_from_file)
	(read_translation_unit_from_buffer)
	(read_translation_unit_from_istream): Update wrt read_input ->
	read_translation_unit_from_input.
	(read_corpus_from_native_xml, read_corpus_from_native_xml)
	(read_corpus_from_native_xml_file): Define new entry points.
	* src/abg-writer.cc (write_translation_unit): Write 'path'
	attribute into the 'abi-instr' xml element.
	(write_corpus_to_native_xml, write_corpus_to_native_xml_file):
	Define new entry points.
	* tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS,
	FILE_TYPE_ZIP_CORPUS}): New enumerators.
	* tools/abg-tools-utils.cc (guess_file_type): Support detection of
	the new xml file format containing a document root 'abi-corpus'
	root element.
	* tools/bidiff.cc (main): Support diffing xml corpus-es and zip
	corpus-es.
	* tools/bidw.cc (main): Recognize elf files before reading them.
	* tools/bilint.cc (main): Support reading xml/zip corpus-es too.
	* tests/data/test-read-write/test[0-23].xml: Update 'path'
	attribute.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 14:12:26 +01:00
Dodji Seketeli
4ca76c4658 Misc style fixes
* include/abg-writer.h (write_translation_unit): Re-indent parms.
	* src/abg-writer.cc (write_translation_unit): Likewise.
	* test/test-read-write.cc (main): Fix white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-07 14:07:14 +01:00
Dodji Seketeli
0d66442b8b Add support for global variables in corpus diffing
* include/abg-comparison.h (string_var_ptr_map, changed_var_ptr)
	(string_changed_var_ptr_map): New convenience typedefs.
	* src/abg-comparison.cc
	(corpus_diff::priv::{deleted_vars_,added_vars_,changed_vars_}):
	New members.
	(corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables}):
	Update wrt the new variables related lookup tables.
	(corpus_diff::ensure_lookup_tables_populated): Update to populate
	variables related lookup tables.
	(corpus_diff::report): Update to display added/removed/changed
	variables.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-06 16:01:55 +01:00
Dodji Seketeli
a41b741118 Misc style fixlets
* include/abg-comparison.h (changed_function_ptr): Fix comment.
	* src/abg-comparison.cc (corpus_diff::report): Likewise.
	* src/abg-corpus.cc (corpus::is_empty): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-06 15:52:25 +01:00
Dodji Seketeli
fbb6b1bc73 Initial support for diffing ABI corpus files
* include/abg-comparison.h (string_function_ptr_map)
	(changed_function_ptr, string_changed_function_ptr_map)
	(corpus_diff_sptr): New convenience typedefs.
	(translation_unit_diff): Add comments.
	(class corpus_diff): New type.
	(compute_diff): New overload for corpus_diff.
	* include/abg-corpus.h (corpus::{functions, variables}): New
	typedefs.
	(corpus::{operator==, get_functions, get_variables}): New members.
	* include/abg-diff-utils.h (struct deep_ptr_eq_functor): New
	functor.
	* include/abg-ir.h (translation_unit::operator==): New member
	equality operator.
	* src/abg-comparison.cc (struct corpus_diff::priv): New private
	struct holding the private members of corpus_diff.
	(corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables,
	ensure_lookup_tables_populated}): Define new private member functions.
	(corpus_diff::{corpus_diff, first_corpus, second_corpus,
	function_changes, variable_changes, length, report}): New public members.
	(struct noop_deleter): New struct.
	(compute_diff): New implementation for corpus_diff.
	* src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl
	into this.  Add new fns, vars and is_symbol_table_built data
	members.
	(corpus::priv::build_symbol_table): New member function.
	(class symtab_build_visitor_type): New visitor type to build the
	symbol table.
	(struct func_comp, struct var_comp): New comparison functors.
	(corpus::priv::build_symbol_table): Define new member function.
	(corpus::{corpus, add, get_translation_units, operator==,
	get_functions, get_variables}): Define new members.
	* src/abg-ir.cc (translation_unit::operator==): Define new member
	equality operator.
	(operator==(translation_unit_sptr l, translation_unit_sptr r)):
	Define new equality operator.
	* tools/abg-tools-utils.h (enum file_type): New enum.
	(guess_file_type): Declare new function.
	* tools/abg-tools-utils.cc (guess_file_type): define new function.
	* tools/bidiff.cc (main): Guess the type of the files given in
	input and support elf files reading and diffing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 14:05:19 +01:00
Dodji Seketeli
dbc0225415 Generalize use of equality operator in core diff algorithms
* include/abg-diff-utils.h (struct default_eq_functor): New
	equality functor.
	(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Add a
	new equality functor template parameter and document it.  Use it
	to compare the elements of the sequences given in argument.
	(compute_middle_snake, ses_len, compute_diff): Add a new equality
	functor template parameter and document it.  Adjust call to
	end_of_frr_d_path_in_k_plus_delta, end_of_fr_d_path_in_k and
	compute_middle_snake.
	(ses_len, compute_diff): Add a new overload that uses a
	default_eq_functor as comparison functor, to avoid breaking
	existing client code.
	* src/abg-diff-utils.cc (compute_middle_snake): Adjust the call to
	the compute_middle_snake.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:40:14 +01:00
Dodji Seketeli
165434a9d7 Change ir node visitor interface work on pointer to nodes
* include/abg-ir.h (ir_traversable_base): New type to be the base
	of IR nodes that are to be traversed.  Extends traversable_base.
	Its ir_traversable_base::traversable() method takes an
	ir_node_visitor&.
	(ir_node_visitor::visit): Change these virtual overloads to take
	pointers to IR nodes, rather than references.  This will be useful
	to e.g, store these IR nodes in containers on the side for some
	algorithms to work.  That is going to be useful later to,
	e.g. build symbol tables on the side, using the visitor interface.
	(class decl_base): Make this inherit ir_traversable_base.
	* src/abg-ir.cc (*::traverse): Adjust comments and the call the
	ir_node_visitor::visit call.  Use the ir_traversable_base type
	rather than traversable_base.
	(ir_traversable_base::traverse): Define.
	(ir_node_visitor::visit): Change these overloads to take pointers
	rather than reference to ir nodes.
	* tests/test-walker.cc (name_printing_visitor::visit): Adjust to
	take pointers rather than references.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:25:32 +01:00
Dodji Seketeli
6d4015ec75 Support reading member functions and member types from DWARF
* include/abg-ir.h (method_type_sptr): New convenience typedef.
	* src/abg-dwarf-reader.cc (read_context::{dwarf_version,
	die_wip_classes_map}): New accessors.
	(die_is_virtual): Rename is_virtual into this.
	(is_type_tag, is_type_die, die_virtual_function_index): Define new
	static functions.
	(die_member_offset): Fix comment.
	(get_scope_for_die): Take the read context as argument.
	(canonicalize_and_add_type_to_ir): Likewise.  On NULL scope, get
	the current translation unit from the read context.
	(canonicalize_and_insert_type_into_ir_under_scope): Handle NULL
	context.
	(build_function_decl): Support creating method_decls from here
	when necessary.
	(build_class_type_and_add_to_ir): Rename build_class_type into
	this.  Handle adding the class to the IR and to the relevant maps.
	During the creation of the class, arrange for
	build_ir_node_from_die on the current DIE to return a
	declaration-only class, representing the declaration for the class
	that is being constructed.  This breaks circular dependencies
	induced by decls/types that refer to the class being built, before
	the class is fully built and has a (logical) type ID.  Once the
	class is created, make it refer to the class declaration that was
	previously handed for the requests to the class DIE.  Now requests
	to the class DIE will just yield the newly built class.  Add
	support for member functions and member types.
	(build_corpus): Support reading the dwarf version and stick it
	into the context.
	(build_ir_node_from_die): Adjust for change in
	canonicalize_and_add_type_to_ir and build_class_type signature
	change.
	* src/abg-ir.cc (class_decl::method_decl::get_type): Support
	returning NULL type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-20 16:19:58 +01:00
Dodji Seketeli
f47b1ffd6d Make decl_base::set_scope virtual, to work on class_decl::member_type
* include/abg-ir.h (decl_base::set_scope): Make this virtual.
	(class_decl::member_type::set_scope): Declare an overload here.
	* src/abg-ir.cc (class_decl::member_type::set_scope): Define new
	overload.  Make this set the scope of the underlying type of the
	member type as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-20 16:14:21 +01:00
Dodji Seketeli
118a5df30d Support artificial parameters
* include/abg-ir.h (function_decl::parameter::{get,
	set}_artificial): Add new accessors for an "artificial" flag.
	* src/abg-reader.cc (build_function_parameter): Support reading
	the artificial parameter flag.
	* src/abg-writer.cc (write_function_decl): Support writing the
	artificial parameter flag.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-20 16:08:32 +01:00
Dodji Seketeli
5be46a9615 Build & use a DIE -> parent map to avoid emitting useless types
* include/abg-ir.h (translation_unit::{mark_type_as_used,
	prune_unused_types}): Remove these declarations.
	* src/abg-ir.cc (translation_unit::priv::used_types_): Remove.
	(class subtype_marking_visitor): Likewise.
	(translation_unit::{mark_type_as_used, prune_unused_types):
	Likewise.
	(get_top_most_scope_under): Fix logic and add comment.
	* src/abg-dwarf-reader.cc (die_tu_map_type, offset_offset_map):
	New convenience typedefs.
	(read_context::{die_tu_map_, die_parent_map_}): New context
	members.
	(read_context::{die_tu_map, die_parent_map}): New accessors.
	(build_ir_node_from_die): New overload that takes the scope of the
	ir node in parameter.
	(die_signed_constant_attribute): Un-comment this.
	(build_die_parent_relations_under, build_die_parent_map)
	(get_parent_die, get_scope_for_die): New static functions.
	(build_translation_unit_and_add_to_ir): Renamed
	build_translation_unit into this. Populate the new
	read_context::die_tu_map() here.
	(canonicalize_and_add_type_to_ir)
	(canonicalize_and_insert_type_into_ir)
	(canonicalize_and_insert_type_into_ir_under_scope): Move these
	overloads over the top of the file.
	(build_namespace_decl_and_add_to_ir): Fix this by adding the
	namespace to the IR scope of the DIE (using the new
	get_scope_for_die()).  Update the read_context::die_decl_map()
	map.
	(build_function_decl): Support functions that return void.  Also,
	skip parameters that don't have type set.
	(build_corpus): Walk all the DIEs to build a DIE -> parent map.
	Adjust for the rename to build_translation_unit_and_add_to_ir.
	(build_ir_node_from_die): Add a scope parm.  Adjust back to
	building IR nodes only for public decls, unless the
	'called_from_public_decl' flag is set.  Adjust to stick the resulting
	IR node into the scope given in parameter.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-14 22:15:16 +01:00
Dodji Seketeli
96597e61ab Add missing virtual keywords for traverse() method
* include/abg-ir.h ({translation_unit, decl_base, scope_decl,
	type_decl, namespace_decl, qualified_type_decl, pointer_type_def,
	reference_type_def, enum_type_decl, typedef_decl, var_decl,
	function_tdecl, class_decl, class_decl::data_member,
	class_decl::member_function, class_decl::member_function_template,
	class_decl::member_class_template}::traverse): Add a virtual
	keyword at least to "document" that this method is virtual -- and
	thus remind the user that it overrides the
	traversable_base::traverse().

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-14 11:00:47 +01:00
Dodji Seketeli
d666251b42 Add a is_type overload
* include/abg-fwd.h (is_type): Declare new overload that takes a
	type reference.
	* src/abg-ir.cc (is_type): Define.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-14 10:03:09 +01:00
Dodji Seketeli
02b1b2a786 Prune types that are not ref'ed by public decls
* include/abg-fwd.h (remove_decl_from_scope): Declare new
	function.
	* include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these
	convenience typedef before the translation_unit declaration.
	(translation_unit::{mark_type_as_used, prune_unused_types}):
	Declare new methods.
	(decl_base::remove_member_decl): Likewise.
	(class_decl::{remove_member_decl, remove_member_type): Likewise.
	* src/abg-dwarf-reader.cc (die_decl_map_type): Change this map
	type so that the value is now a DIE offset, rather than a DIE.
	This is because many times the lifetime of DIEs is shorter than
	the one of the reader_context.  Also, the die offset uniquely
	designates a physical DIE even if several different instances of
	logical DIE might point to it.
	(struct die_hash): Remove this as it's useless now that we store
	DIE offsets in the map.
	(build_translation_unit): Call build_ir_node_from_die w/o setting
	the called_from_public_decl flag.  Prune the types that are not
	used by any public decls.
	(build_namespace_decl_and_add_to_ir): all build_ir_node_from_die
	w/o setting the called_from_public_decl flag.
	(build_ir_node_from_die): Change the only_public_decl flag into a
	called_from_public_decl flag.  Mark types used by public decls as
	such.  Adjust for the parm changes of build_qualified_type
	build_pointer_type_def, build_reference_type, and
	build_typedef_type.
	(build_qualified_type, build_pointer_type_def)
	(build_reference_type, build_typedef_type): Take a new
	called_from_public_decl.  Pass it to build_ir_node_from_die.
	(build_var_decl): Call build_ir_node_from_die with the
	called_from_public_decl flag set to true to flag the types
	referenced by this variable as being used.
	(build_function_decl): Take a called_from_public_decl flag as
	well, as this function can now call build_function_decl itself to
	build a function decl out of the value of the DW_AT_specification
	attribute, for DIEs representing function definitions.  Also, flag
	the types referenced by public functions are being used.
	* src/abg-ir.cc (translation_unit::priv::used_types_): New map for
	the used types.
	(translation_unit::{mark_type_as_used, prune_unused_types}):
	Define new methods.
	(scope_decl::remove_member_decl): Likewise.
	(remove_decl_from_scope): Define new function.
	(class_decl::{remove_member_decl, remove_member_type}): Define new
	methods.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 18:11:46 +01:00
Dodji Seketeli
643b02fd6a Support reading namespaces
* include/abg-fwd.h (get_global_scope): Return a const
	global_scope.  Add a new overload that takes a naked pointer as
	parm.
	(insert_decl_into_scope, get_top_most_scope_under): Declare new
	entry points.
	* include/abg-ir.h (class decl_base, class scope_decl): Add
	insert_decl_into_scope as a friend of these classes.
	(scope_decl::{insert_decl_into_scope, find_iterator_for_member}):
	Declare new member.
	(scope_decl::get_member_decls): New non-const overload.
	* src/abg-dwarf-reader.cc (build_translation_unit): Remove the
	"recurse" parameter.  Adjust the call to build_ir_node_from_die to
	read just public decls that are at namespace scope.  Anything else
	should be dropped unless it's needed to emitting the public
	namespace-level decls.
	(build_namespace_decl_and_add_to_ir)
	(canonicalize_and_insert_type_into_ir): Define new static
	functions.
	(build_corpus): Adjust ad build_translation_unit doesn't have the
	"recurse" parameter anymore.
	(canonicalize_and_add_type_to_ir): Make this static.  Fix
	comments.
	(build_ir_node_from_die): Take a new "only_public_decl"
	parameter. For DW_TAG_base_type case, use the new
	canonicalize_and_insert_type_into_ir to insert the type at the
	right place in the global scope making sure it is seen before the
	current scope.  For pointer, references and qualified types, use
	canonicalize_and_insert_type_into_ir to add the type at the same
	scope as its underlying type.  Handle DW_TAG_{namespace,module}
	using the new build_namespace_decl_and_add_to_ir function.  Add
	some vertical spaces and some assertions.
	* src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr
	typedef.
	(scope_decl::{insert_member_decl,find_iterator_for_member}):
	Define new methods.
	(insert_decl_into_scope, get_top_most_scope_under): Define new
	functions.
	(get_global_scope): Constify the return type.
	(get_translation_unit): Adjust as get_global_scope now returns a
	const.
	* src/abg-reader.cc (get_translation_unit): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 15:40:52 +01:00
Dodji Seketeli
f918fdb0f9 Fix function_decl::parameter::operator==
* include/abg-ir.h (function_decl::parameter::operator==): Support
	empty type, e.g, in presence of a variadic parameter.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 15:36:17 +01:00
Dodji Seketeli
faa9ae485c Misc style fixes
* include/abg-ir.h (decl_base::set_visibility): Remove useless
	white space.
	(class scope_decl): Remove useless white space.
	(scope_decl::add_member_decl): Use decl_base_sptr convenience
	typedef.
	(global_scope_sptr, namespace_decl_sptr): New convenience typedef.
	(class global_scope): Remove useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 15:35:09 +01:00
Dodji Seketeli
a789ed3ae8 Support pointer types
* include/abg-fwd.h (get_translation_unit, get_global_scope):
	Declare new overloads that act on a naked pointer to decl_base.
	* src/abg-dwarf-reader.cc (build_pointer_type_def): Define new
	static function.
	(canonicalize_and_add_type_to_ir): Take a naked pointer to
	scope_decl rather than a smart pointer.
	(build_ir_node_from_die): For DW_TAG_base_type, adjust.  Support
	DW_TAG_pointer_type case.  For DW_TAG_{const,volatile}_type case,
	make sure the qualified type is in the same scope as its
	underlying type.
	* src/abg-ir.cc (get_global_scope, get_translation_unit): Define
	new overloads that acts on a naked decl_base.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-11 20:28:18 +01:00
Dodji Seketeli
7350cfd893 Make bilint read input from stdin
* include/abg-libxml-utils.h (new_reader_from_istream): Declare
	new public entry point.
	* src/abg-libxml-utils.cc (xml_istream_input_read)
	(xml_istream_input_close): New static functions.
	(new_reader_from_istream): Define new public input function.
	* include/abg-reader.h (read_translation_unit_from_istream):
	Declare new entry points.
	* src/abg-reader.cc (read_translation_unit_from_istream): Define
	new entry points.
	* tools/bilint.cc (options::{read_from_stdin, noout}): New
	members.
	(display_usage): Document --stdin and --noout.
	(parse_command_line): Adjust to consider that no option on the
	command line means reading from stdin, just like --stdin.  Support
	the --noout option as well.
	(main): Support Read the abi instr from stdin; in that case, what
	was read is just serialized back to stdout, unless --noout was
	supplied.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-11 15:20:42 +01:00
Dodji Seketeli
d3929eaf23 Support the "address-size" attribute for <abi-instr> elements
* include/abg-ir.h (translation_unit::translation_unit): Take an
	address_size parameter.
	(translation_unit::{get_address_size, set_address_size}): New
	accessors.
	* src/abg-ir.cc (translation_unit::priv::address_size_): New
	private member.
	(translation_unit::translation_unit): Take an address_size
	parameter.
	(translation_unit::{get_address_size, set_address_size}): Define
	these new methods.
	* src/abg-reader.cc (read_input): Read the "address-size"
	attribute from the abi-instr element.
	* src/abg-writer.cc (write_translation_unit): Write the
	"address-size" attribute.
	* tests/data/test-read-write/test23.xml: New test input.
	* tests/test-read-write.cc (in_out_specs): Add the new test above
	to the list of files to read and write back.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-11 12:30:19 +01:00
Dodji Seketeli
bd1af4cd52 Initial support of reading an ABI Corpus from DWARF
* configure.ac: Check the presence of libdw.so and
	elfutils/libdwfl.h headers from elfutils and define the necessary
	linking flags.
	* include/abg-dwarf-reader.h: New header file
	* include/Makefile.am: Add the new header file to the source
	distribution.
	* src/abg-dwarf-reader.cc:: New file.
	* src/Makefile.am: Add the new file to the source distribution.
	* include/abg-fwd.h (dump): Add declarations for several overloads
	to allow dumping to a given output stream.
	* include/abg-ir.h (class translation_unit): Use a pimpl idiom for
	this now.
	(translation_unit::canonicalize_type): Declare new method.
	* src/abg-ir.cc (struct translation_unit::priv): New private type
	for the pimpl idiom for translation_unit.
	(translation_unit::{translation_unit, get_global_scope, get_path,
	set_path, get_loc_mgr}): Adjust for pimpl idiom.
	(translation_unit::canonicalize_type): Define this new method and
	one overload.
	* src/abg-writer.cc (dump): Define several overloads to dump IR
	nodes to given output streams.
	* tools/bidw.cc: New file for the new bidw tool.
	* tools/Makefile.am: Define rules to build the new bidw tools.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:28:00 +01:00
Dodji Seketeli
a03d9c0e64 Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
	* include/abg-ir.h (class decl_base): Add class_decl as a friend.
	This to be able to call decl_base::set_scope from class_decl.
	(scope_decl::add_member_decl): Make this virtual protected, so
	that it can be called (virtually) from e.g, class_decl.
	(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
	(class_decl::add_member_decl): New virtual overload for
	scope_decl::add_member_decl.
	(class_decl::{add_member_type, add_data_member,
	add_member_function}): New overloads.
	* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
	(get_type_declaration): Define new function.
	(class_decl::add_member_decl): New method.
	(class_decl::add_member_type): Avoid silently added a new member
	type when that member type has already been (perhaps
	inadvertently) added to a scope already.  Rather, put a strict
	assert in place there.  Also add a new overload that constructs
	the member type out of a classic type and adds it to the class.
	(class_decl::{add_data_member, add_member_function}): Likewise.
	(class_decl::{add_member_function_template,
	add_member_class_template}): Avoid silently added a new member
	template when that template has already been (perhaps
	inadvertently) added to a scope already.  Rather, put a strict
	assert in place there.
	* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
	flag saying if the current decl should be added to the current
	scope as well (in addition to being pushed onto the stack of
	scopes maintained in the reader context).
	(push_and_key_type_decl): Likewise, take that extra flag and pass
	it to push_decl_to_current_scope.
	(build_function_decl, build_var_decl, build_type_decl)
	(build_qualified_type_decl, build_pointer_type_def)
	(build_reference_type_def, build_enum_type_decl, build_typedef_decl)
	(build_function_tdecl, build_class_tdecl): Likewise.
	(build_class_decl): Likewise.  When building member data, types,
	and functions, make sure /not/ to add the data, type of function to
	the current scope before adding it to the class_decl.  This was
	making the member not being added to the class because it already
	had a scope.
	(build_type_tparameter, build_type_composition)
	(build_non_type_tparameter, build_template_tparameter)
	(build_type): Adjust to add the template parm to the current scope
	explicitly, like previously.
	(handle_type_decl): Use build_type_decl function. Add the
	type_decl to the current scope, like previously.
	(handle_namespace_decl, handle_qualified_type_decl)
	(handle_pointer_type_def, handle_reference_type_def)
	(handle_enum_type_decl, handle_typedef_decl, handle_var_decl)
	(handle_function_decl, handle_class_decl, handle_function_tdecl)
	(handle_class_tdecl): Adjust to add the decl to the current scope,
	like previously.
	* tests/data/test-read-write/test21.xml: New test input with
	member type(def).

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:26:24 +01:00
Dodji Seketeli
9be945584a Re-write middle snakes management in core diff algorithms
* include/abg-diff-utils.h (point::set): New overload..
	(point::{add, operator<, operator>, operator<=, operator>=}): New
	methods.
	(point::operator!=): Constify.
	(point::operator==): Constify. Cleanup.
	(point::operator=): Keep emptiness.
	(class snake): New class definition
	(d_path_vec::{over_bounds, offset}): New methods.
	(d_path_vec::check_index_against_bound): Don't take a bound
	parameter anymore.  Use the new over_bound method above.  Fix up
	error reporting.
	(d_path_vec::d_path_vec): Fix d_path_vec size allocation.
	(d_path_vec::operator[]): Use the d_path_vec::at method to check
	all accesses against the bounds.  This is slower, but at least we
	can expect to have something that is more robust.  We can remove
	the bound checking later when we are sure the code has been tested
	enough.  Also use the new offset() method.
	(d_path_vec::at): Take long long.
	(ends_of_furthest_d_paths_overlap): Constify input parameters.
	(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Take
	an instance of the new snake in parameter, rather than a bare end
	point that wasn't carrying enough information about the snake.
	Record the snake which consists of up to four points: a begin
	point, an intermediate point, a diagonal start point and an end
	point.  Return that snake upon successful completion.
	(compute_middle_snake): Take an instance of snake, rather than the
	two points that were supposed to represent a snake and with which
	we were loosing information before.  Revisit/simplify the logic of
	this function; this literally goes forward or in reverse, gets the
	resulting snake returned by the end_of_fr_d_path_in_k and
	end_of_frr_d_path_in_k_plus_delta functions, detect if these snakes
	overlap and just return the current snake.  Much simpler.  The
	caller now gets a snake, which has much more information than the
	previous snake approximation made of just two points.  Bonus
	point, this follows almost to the word, what the paper says.
	(maybe_record_match_point, find_snake_start_point): Remove these
	as there are not used by compute_middle_snake anymore.
	(print_snake, ses_len): Update these to take/handle a snake.
	(snake_end_points): New declaration.
	(compute_diff): When we are getting an empty first sequence, this
	means that we are inserting the second sequence *before* the
	beginning of the first sequence; keep this information by setting
	the insertion point index to -1, rather than zero.  Update this to
	get/handle snakes, rather than free points vaguely representing
	snakes.  Now that compute_middle_snake returns real snakes, handle
	the information we are getting.  Basically for edit scripts of
	length equal to 1, as the snake carries all the necessary
	information about the non-diagonal edge (as well as the diagonal
	edges), we (can) now precisely update the current edit script (as
	well as the longest common sub-sequence).  For edit scripts of
	length greater than 1, better at which points to divide the
	problem and consequently, at which points to conquer it back --
	better following The Paper to the letter.
	(display_edit_script): Update this for the use of instances of
	snake.
	* src/abg-diff-utils.cc (ends_of_furthest_d_paths_overlap): Update
	for constification of inputs.
	(snake_end_points): Define new function.
	(compute_middle_snake): Adapt for the taking an instance of snake.
	* tests/test-diff2.cc (main): Update for using instances of snake.
	* tests/test-core-diff.cc: Add new tests.
	* tests/data/test-core-diff/report0.txt: Update for output
	adaptation.
	* tests/data/test-core-diff/report6.txt: Likewise.
	* tests/data/test-core-diff/report7.txt: Likewise.
	* tests/data/test-core-diff/report8.txt: New test data.
	* tests/data/test-core-diff/report9.txt: Likewise.
	* tests/data/test-core-diff/report10.txt: Likewise.
	* tests/data/test-core-diff/report11.txt: Likewise.
	* tests/data/test-core-diff/report12.txt: Likewise.
	* tests/data/test-core-diff/report3.txt: Likewise.

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:25:21 +01:00
Dodji Seketeli
ee2d8c9196 Fix IR node comparison bugs
* include/abg-ir.h (type_shared_ptr_equal::operator()): Fix thinko
	in checking for the boolean value of the pointers to types.
	* src/abg-ir.cc (type_decl::operator==(const decl_base&)): Do not
	forget to compare the decl_base part of the type too.
	(type_decl::operator==(const type_base&)): To ease maintenance,
	re-use the equality operator that takes a decl_base.
	(scope_type_decl::operator==(const type_base&)): Likewise.
	(qualified_type_def::operator==(const type_base&)): Likewise.
	(compare_function_types): New sub-routine to compare function
	types.  It fixes an infinite recursion when comparing two methods
	of the same class.
	(function_type::operator==(const type_base&)): Use the new
	compare_function_types function.
	(class_decl::operator==(const decl_base&)): Fix a thinko in the
	first test of the function.  Use a dedicated scope for each class
	section comparison; that way, there won't be any chance to misuse
	the variables pertaining to a different section.  Fix the member
	function sections; we were mistakenly using the variables for the
	*data* section there.
	(class_decl::operator==(const type_base&)): Re-use the operator
	that takes a decl_base.
	(class_decl::operator==(const class_decl&)): Don't remove
	const-ness during the static cast.
	(class_decl::member_function::operator==(const member_function&)):
	Do not remove the reference from the static cast.
	(class_decl::member_class_template::operator==(const
	member_base&)): Likewise.
	(type_tparameter::operator==(const template_parameter&)):
	Likewise.
	(template_tparameter::operator==(const template_parameter&)):
	Likewise.
	(function_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const template_decl&)): Likewise.
	(class_tdecl::operator==(const class_tdecl&)): Likewise.
	* tests/data/test-read-write/test12.xml: Update this because the
	test now correctly considers two type template parameters at the
	same index as being equivalent.
	* tests/data/test-read-write/test13.xml: Likewise.

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

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

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

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:23:12 +01:00
Dodji Seketeli
997e2d9328 Fix middle snake determination & ses len computation for d == 1
* include/abg-diff-utils.h (compute_middle_snake): After the
	overlap determination happened, finding the middle snake can
	require keep on building the current path until the "end".  The
	end meaning reaching the max of D.  And that max is (M + N)/2 + 1.
	In the extreme cases were middle snake was on the very last step
	(M + N) + 1, we were not finding the middle snake.  Fix this.
	(compute_diff): When d == 1 and the first edge on the edit graph
	is a non-diagonal edge and when a_base != a_begin, we were failing
	to properly initialize x,y to find that non-diagonal edge.  Also
	we were failing to correctly compute the size of the sequence.
	Fix these.
	* tests/test-core-diff.cc: Add a new regression test for the two
	cases above.
	* tests/data/test-core-diff/report7.txt: New reference data for
	the new regression test.

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

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

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

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

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

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

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:28 +01:00
Dodji Seketeli
fe1b7062eb Fix middle snake determination
* include/abg-diff-utils.h (point::{operator!=,operator==}): New
	operators.
	(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Allow
	the initial point (-1,-1) that is not a point addressing elements
	of the input sequences, but that is the starting point of the
	forward paths and the ending point of reverse paths in the "Linear
	Refinement" of the algorithm.
	(is_match_point, maybe_record_match_point)
	(find_snake_start_point): New functions.
	(find_last_snake_in_path): Remove this.  It's not used anymore.
	(compute_middle_snake): Allow checking for overlapping paths even
	on points that are outside of the edit graph boundaries.  Once the
	overlap is detected, if a non-empty snake has been seen already,
	report it as the middle snake.  Otherwise, keep building the path
	until the end and report the last snake encountered as the middle
	snake.  Add comments.
	(compute_diff): For the d == 1 case, fix the logic of the finding
	the non-diagonal edge.  Fix typos.  Add comments.
	(display_edit_script): Fix report glitches.
	* tests/data/test-core-diff/report3.txt: Update as per the report
	glitch above.
	* tests/data/test-core-diff/report4.txt: Likewise.
	* tests/data/test-core-diff/report5.txt: Likewise.
	* tests/data/test-core-diff/report6.txt: New reference report for
	a new test.
	* tests/test-core-diff.cc: Add a new test for negative delta.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:19 +01:00