Commit Graph

4 Commits

Author SHA1 Message Date
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
c243aac0a4 Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
	constructor with variadic parameter marker.
	(function_decl::m_type): Make this protected to let method_decl
	inheriting class to access it.
	(function_decl::get_type): Move this out-of-line.
	(class method_type, method_type_hash): New types.
	(enum class_decl::access_specifier): Add no_access new enumerator.
	(class_decl::data_member::data_member): Move this out-of-line.
	(class_decl::data_member::~data_member): Declare virtual
	destructor.
	(class method_decl): New class.
	(class member_function): Make this inherit method_decl, instead of
	function_decl.
	(class_decl::class_decl): New constructors.
	(class_decl::{hashing_started, is_declaration_only,
	set_earlier_declaration, get_earlier_declaration}): New methods.
	* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
	scope, don't add it to this scope.
	(get_global_scope): Make this work when passed an instance of
	global_scope.
	(dynamic_type_hash::operator()): Add support for method_type.
	(method_type::{method_type, set_class_type, ~method_type, })
	(method_type_hash::operator()): New defintions.
	(function_decl::get_type, class_decl::class_decl): Move these
	out-of-line here.
	(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
	New definitions.
	(class_decl::member_function::member_function): Move this
	out-of-line here.  Support method_decl.
	(class_decl::data_member::data_member): Likewise.
	(class_decl_hash::operator()): Guard this against endless loop.
	* src/abg-reader.cc (write_class_is_declaration_only): New static
	function.
	(write_var_decl): Take a flag to write the mangled name or not.
	(write_function_decl): Take a flag to skip the first parameter.
	(write_cdtor_const_static): Use 'yes' instead of 'true' as value
	of the properties.
	(write_decl, write_function_template_decl): Adjust wrt the new
	signatures of write_var_decl and write_function_decl.
	(write_enum_type_decl): Simplify call to write_location.
	(write_class_decl): Support serializing declaration-only classes.
	* src/abg-writer.cc:
	* tests/data/test-read-write/test17.xml: New test input.
	* tests/test-read-write.cc: De-serialize the above, and serialize it back.
	* tests/data/test-read-write/test10.xml: Update this test.
2013-07-23 23:13:53 +02:00
Dodji Seketeli
0c65215330 Support function_type and adapt a function_decl to use it
* src/abg-ir.h (class function_type): Forward decl prior to class
	function_decl.
	(function_decl::parameter): Pass string by const reference.  Add a
	variadic marker member and initialize it.
	(function_decl::parameter::get_type): Add a non-const overload.
	(function_decl::parameter::get_variadic_marker): New getter.
	(function_decl::function_decl) Take a const reference to a vector
	for parameters, type size/alignment.  Add two overloads that takes a
	pointer to function_type.
	(function_decl::get_parameters): Move this out-of-line.
	(function_decl::append_parameter(s)): Renamed
	function_decl::add_parameter(s) into these.  Move it out-of-line.
	Add an overload.
	(function_decl::{get_type, set_type}): New declaration.
	(function_decl::get_return_type): Move this out-of-line.
	(function_decl::is_variadic): New in-line function.
	(function_decl::m_type): New data member.
	(function_decl::{m_parms, m_return_type}): Remove.  This are now
	carried by function_decl::m_type.
	(class function_type, struct function_type_hash): New
	declarations.
	(member_function::member_function): Take a vector of pointers to
	parameters.  Take size/align of the type of the member function.
	Adjust initialization.
	* src/abg-ir.cc (dynamic_type_hash): Hash instance of
	function_type accessed through a pointer.
	(function_type::{operator==, ~function_type})
	(function_type_hash::operaror(), function_decl::{get_return_type,
	}, function_decl::parameter:#️⃣:operator()): New definitions.
	(function_decl::function_decl): The out-of-line definitions of the
	declarations above.
	(function_decl::append_parameter): Moved this out-of-line from
	inline function_decl::add_parameter.  Make this rely on the
	underlying m_type.
	(function_decl::operator==): Adjust for use of vector for the
	parameters.  Also, there is no need anymore to compare the
	parameters or the return types as they are compared by the
	comparison of the function types.
	* src/abg-reader.cc (build_function_decl): Read the new size/alignment
	attributes on the function-decl element.  Build a function_type
	and use it to build the function_decl.  Parameters and return type
	are now hung off of the function_type.
	(handle_function_decl): use build_function_decl.
	* src/abg-writer.cc (write_function_decl): Write the new
	size/alignment properties of the function-decl element.  Adjust
	for the use of vectors for function parameters now.
	* tests/data/test-read-write/test10.xml: Adjust for the presence
	of size/alignment properties in the function-decl element now.
	* tests/data/test-read-write/test11.xml: Likewise.
	* tests/data/test-read-write/test12.xml: Likewise.
	* tests/data/test-read-write/test13.xml: Likewise.
	* tests/data/test-read-write/test14.xml: Likewise.
	* tests/data/test-read-write/test9.xml: Likewise.
2013-07-23 23:13:53 +02:00
Dodji Seketeli
ee19845a94 Initial Support for class declarations
* src/abg-ir.h (scope_decl::scope_decl)
	(scope_type_decl::scope_type_decl): Don't set mangled name for
	scope_decl instances as it doesn't make sense.
	(var_decl::var_decl): Pass the type shared pointer by value.
	(struct var_decl_hash, function_decl::parameter::operator==)
	(struct function_decl::parameter_hash, function_decl::operator==)
	(struct function_decl_hash, class class_decl, struct
	class_decl_hash): New declarations.
	* src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the
	mangled name.  It doesn't make sense for scope_decls.
	(dynamic_type_hash::operator): Fix comment.  Run the hashing for
	scope_type_decl instances *after* running it for class_decl
	instance, otherwise, the class_decl instances case will never get
	hit.
	(var_decl::var_decl): Pass the type shared pointer by value.
	(function_decl::operator==, class_decl::operator==)
	(class_decl_hash::operator()): New fns.
	* src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn.
	(XML_READER_GET_ATTRIBUTE): Fix comment.
	(XML_NODE_GET_ATTRIBUTE): New getter macro.
	* src/abg-libxml-utils.cc (get_xml_node_depth): New definition.
	* src/abg-reader.cc (update_read_context)
	(update_depth_info_of_read_context, read_visibility, read_binding)
	(read_access, read_size_and_alignment, read_static)
	(read_var_offset_in_bits, read_cdtor_const, 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_class_decl)
	(build_type, handle_class_decl): New functions or overloads.
	(handle_element): Update to handle "class-decl" xml elements.
	* src/abg-writer.cc (write_size_and_alignment, write_access)
	(write_class, do_indent_to_level, get_indent_to_level): New fns.
	(write_decl): Update to serialize instances of class_decl.
	(write_type_decl, write_pointer_type_def)
	(write_reference_type_def): Use the new write_size_and_alignment instead of
	writing the attributes directly.
	* tests/data/test-read-write/test10.xml: New test file.
	* tests/Makefile.am: Add tests/data/test-read-write/test10.xml to
	the build system.
	* tests/test-read-write.cc (in_out_spec): De-serialize
	data/test-read-write/test10.xml, serialize it back into
	output/test-read-write/test10.xml, and compare the two output that
	should be identical.
2013-07-23 23:13:49 +02:00