Commit Graph

19 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
628911ee5f Prepare node visitors to be usable on things other than IR nodes
* include/abg-fwd.h (node_visitor_base): Renamed ir_node_visitor
	into this.
	* include/abg-traverse.h (struct node_visitor_base): New base for
	the visitors.
	(struct traversable_base): Update comments.
	(traversable_base::traverse): Change this into non-pure virtual.
	Make it take a reference to node_visitor_base, rather than a
	reference to ir_node_visitor.
	* src/abg-traverse.cc (traversable_base::traverse): New empty
	default implementation.
	* include/abg-ir.h: Make ir_node_visitor inherit from new
	node_visitor_base.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:12 +01:00
Dodji Seketeli
e90467e69b Misc white space cleanups
* include/abg-corpus.h: Cleanup white spaces.
	* include/abg-fwd.h: Likewise.
	* include/abg-ir.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* src/abg-config.cc: Likewise.
	* src/abg-ir.cc: Likewise.
	* src/abg-reader.cc: Likewise.
	* src/abg-writer.cc: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:40 +02:00
Dodji Seketeli
10ed52ca7c Misc cleanups in abg-fwd.h
* include/abg-fwd.h: Move location, location_manager and
	translation_unit in the ir section.  Remove stuff that was
	commented out anyway.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 13:27:35 +02:00
Dodji Seketeli
a9a8834018 Tweak the apidoc mainpage
* include/abg-fwd.h<doxygen markup>: Fix link to the project web
	page and for git check-out.
2013-08-21 22:24:13 +02:00
Benjamin Kosnik
6684ad97ad Separate out bits from the ir header.
* include/abg-irfwd.h: Move to...
	* include/abg-fwd.h: ...this.

	* include/abg-ir.h (traverse_base): Move to...
	* include/abg-traverse.h: ...here. New.

	* include/abg-ir.h (location, location_manager, translation_unit):
	Move to...
	* include/abg-corpus.h: ...here.

	* include/Makefile.am: Adjust.
	* include/Makefile.in: Regenerate.
2013-08-14 15:07:19 +02:00