Commit Graph

26 Commits

Author SHA1 Message Date
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
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
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
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
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
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