Commit Graph

32 Commits

Author SHA1 Message Date
Dodji Seketeli
c5b81de47d Add support for bidiff regression testing
* tests/data/test-bidiff/test-enum0-v0.cc.bi: New input file.
	* tests/data/test-bidiff/test-enum0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum0-report.diff: Likewise.
	* tests/data/test-bidiff/test-enum1-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum1-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-enum1-report.txt: Likewise.
	* tests/data/test-bidiff/test-qual-type0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-qual-type0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Likewise.
	* tests/data/test-bidiff/test-struct0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
	* tests/data/test-bidiff/test-struct1-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct1-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
	* tests/data/test-bidiff/test-var0-v0.cc.bi: Likewise.
	* tests/data/test-bidiff/test-var0-v1.cc.bi: Likewise.
	* tests/data/test-bidiff/test-var0-report.txt: Likewise.
	* tests/test-bidiff.cc: New file.
	* tests/Makefile.am: Build the new runtestbidiff regression test
	and add the above to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-29 14:32:30 +01:00
Dodji Seketeli
d8882b850c Add missing test inputs to source distribution
* tests/Makefile.am (data/test-read-write/test{17, 18, 19, 20,
	21}.xml): Add these test input files to the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-29 13:37:58 +01:00
Dodji Seketeli
90467f10f2 Initial regression test facility for core diff algorithms
* tests/data/test-core-diff/report0.txt: New test reference data.
	* tests/data/test-core-diff/report1.txt: Likewise.
	* tests/data/test-core-diff/report2.txt: Likewise.
	* tests/data/test-core-diff/report3.txt: Likewise.
	* tests/data/test-core-diff/report4.txt: Likewise.
	* tests/data/test-core-diff/report5.txt: Likewise.
	* tests/test-core-diff.cc: New regression test program.
	* tests/Makefile.am: Add these new files to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:20:03 +01:00
Dodji Seketeli
fd8f8f1af2 Initial command line testing facility for core diff algorithms
* tests/test-diff2.cc: New command line testing facility.
	* tests/Makefile.am: Add this to the build system.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 11:19:51 +01:00
Dodji Seketeli
0d738e2b95 Initial version of an archive manipulation program: biar
* tests/test-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Move these directories manipulation
	utilities from here to ...
	* tools/abg-tools-utils.h (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Declare these new functions.
	* tests/test-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): Likewise, move these to ...
	* tools/abg-tools-utils.cc (is_dir, ensure_dir_path_created)
	(ensure_parent_dir_created): ... here in this new file.
	(dir_name, base_name): Define these.
	* tools/Makefile.am: New file.  Create a new libtoolsutils.la
	static library with stuff from tools/abg-tools-utils.cc in it.
	Also create a new 'biar' program with the stuff from the new
	tools/biar.cc in it.
	* tools/biar.cc: New file.  Contains the code for the new "biar"
	archive manipulation command line utility.
	* tests/test-read-write.cc (main): Adjust for the change about
	ensure_parent_dir_created above.
	* tests/test-write-read-archive.cc (main): Likewise.
	* Makefile.am (SUBDIRS): Add the new tools/ sub-directory to the
	build system.
	* configure.ac (AC_CONFIG_FILES): Generate tools/Makefile.
	* tests/Makefile.am: Make libtestutils.la link with the new
	libtoolsutils.la.  Make sure to express the dependencies between
	libtestutils.la and the binaries that depend on it.  Otherwise
	parallel builds can go awry.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-29 17:08:47 +02:00
Dodji Seketeli
c57e950ec7 Initial writing/reading of an ABI corpus to an archive
* configure.ac: Support detection of libzip dependency. Define
        new DEPS_CFLAGS and DEPS_LIBS variables for use in
        Makefile.am to refer to the dependency headers and
        libraries.
	* doc/website/mainpage.txt: Update this to talk about the new
	libzip dependency.
	* include/Makefile.am: Add abg-libzip-utils.h to the build system.
	* include/abg-corpus.h (corps): Hide abigail::corpus's private behind a
	pimpl idiom.
	(corpus::{drop_translation_units, get_file_path, set_file_path,
	write, read}): New methods.
	* include/abg-libxml-utils.h (new_reader_from_buffer): Declare new
	function.
	* include/abg-libzip-utils.h: New file.
	* src/Makefile.am: Add abg-corpus.cc and abg-libzip-utils.cc to
	the build system.  Refer to the library and headers dependencies
	via the new DEPS_LIBS and DEPS_CFLAGS variables.
	* src/abg-corpus.cc: New file.
	* src/abg-ir.cc (translation::set_path): New method.
	* src/abg-libxml-utils.cc (new_reader_from_buffer): Define new
	function.
	* src/abg-libzip-utils.cc: New file.
	* src/abg-reader.cc (translation_unit::read): New overload.
	* src/abg-writer.cc: Inject the names from the std namespace into
	the abigail namespace, rather than into abigail::writer.
	(abigail::translation_unit::write): New overload.  This can now
	use ofstream and the other stuff from std that are injected in the
	abigail:: namespace.
	* tests/Makefile.am: Add tests/test-write-read-archive.cc to the
	build system; use that to build runtestwritereadarchive.  Also add
	the input test data from
	tests/data/test-write-read-archive/test[0-4].xml.
	* /tests/data/test-write-read-archive/test[0-4].xml: New test
	input data files.
	* tests/test-write-read-archive.cc: New test for this archive
	write/read support.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:41 +02:00
Dodji Seketeli
81c496dfe3 Pass absolute paths to the compiler during the build
* src/Makefile.am: Pass absolute file paths to the compiler during
	the build.  This helps in e.g in emacs' compilation mode, when the
	output shows an error reported by GCC's diagnostics, setting point
	to the error line and hitting 'enter' transports the user to the
	file location where the error happened; as the file path is nows
	absolute, emacs can always find it.  Otherwise, finding it depends
	on $PWD and whatnot.
	* tests/Makefile.am: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-08-27 16:20:00 +02:00
Benjamin Kosnik
d23c4e9b96 Collapse subdir of include to include.
* include/libabigail/abg-*.h: Move to...
	* include/abg-*.h
	* include/libabigail: Remove.

	* configure.ac: Adjust include location from libabigail/include to
	include.
	* Makefile.in: Same.
	* aclocal.m4: Same.
	* configure: Same.
	* doc/Makefile.in: Same.
	* include/Makefile.am: Same.
	* src/Makefile.am: Same.
	* src/Makefile.in: Same.
	* tests/Makefile.am: Same.
	* tests/Makefile.in: Same.
2013-08-14 15:07:18 +02:00
Dodji Seketeli
95ec67b143 Implement a translation unit traversal API
* include/libabigail/abg-ir.h (struct ir_node_visitor, struct
	traversable): New interfaces.
	(translation_unit, scope_decl, type_decl, qualified_type_def)
	(pointer_type_def, reference_type_def, enum_type_decl)
	(typedef_decl, var_decl, function_decl, data_member)
	(member_function, member_function_template)
	(member_class_template): Implement the traversable interface,
	overload the traversable::traverse pure virtual function.
	* src/abg-ir.cc ({translation_unit, scope_decl, type_decl,
	namespace_decl, qualified_type_def, pointer_type_def,
	reference_type_def, enum_type_decl, typedef_decl, var_decl,
	function_decl, class_decl::member_function, class_decl,
	class_decl::data_member, class_decl::member_function_template,
	class_decl::member_class_template, function_template_decl,
	class_template_decl, }::traverse): Implement traversal.
	(ir_node_visitor::visit): New method, overloaded for the types
	above, which implement the traversable interface.
	* tests/test-walker.cc: New test case program to showcase how to
	use the new traversal API.
	* tests/makefile.am: Add test-walker.cc to the build system.
2013-07-23 23:13:56 +02:00
Dodji Seketeli
f9d66af03c Put headers in include/libabigail
* include/libabigail: New directory.
	* include/Makefile.am:  New file.
	* include/libabigail/Makefile.am: New file.
	* src/abg-*.h: Move these in include/libabigail/*.h
	* src/Makefile.am: Set -I option to look for headers in include/libabigail
	* doc/api/libabigail.doxy: Look for headers in include/libabigail
	* tests/Makefile.am: Set -I option to look for headers in include/libabigail
	* abigail.m4: Set includedir to $prefix/include/libabigail for
	library used as a dep, or to srcdir/libabigail/include/libabigail
	in GCC source tree.
	* configure.ac: Add Makefile.am in include and include/libabigail
	* abigail.m4: Look for headers in include/libabigail when the
	libabigail is in in the source tree and in $incdir/libabigail when
	it is installed as a dependency.
2013-07-23 23:13:56 +02:00
Benjamin Kosnik
f6c2daedc3 Correct DOT merge.
* src/abg-viz-common.h: Use _M_attributes for attribute overflows.
	* src/abg-viz-dot.h: Merge in correct node_base.
	* src/abg-viz-dot.cc: Same.
	* tests/test-dot.cc: Correct examples.

	* tests/Makefile.am: Add .gv to CLEANFILES.
	* tests/Makefile.in: Regenerate.
2013-07-23 23:13:55 +02:00
Benjamin Kosnik
f3dae517b9 Initial DOT work.
* doc/vizualization/layout/scripts/
	(inkscape_export_svg_to_plain_svg.sh): Move...
	(inkscape_export_svg_to_png_and_pdf.sh): Move...
	* scripts: ..here. New toplevel directory.
	* scripts/scripts/dot_to_png.sh: New.
	* scripts/scripts/dot_to_svg.sh: New.
	* src/Makefile.am: Add abg-viz-dot.cc, abg-viz-dot.h.
	* tests/Makefile.am: Add test-dot.cc.
	* src/abg-viz-dot.cc: New.
	* src/abg-viz-dot.h: New.
	* tests/test-dot.cc: New.
	* doc/vizualization/graph: New.
	* doc/vizualization/graph/gv/sa-A.gv: New.
	* doc/vizualization/graph/gv/sa-B.gv: New.
	* doc/vizualization/graph/gv/sa-C1.gv: New.
	* doc/vizualization/graph/gv/sa-C2.gv: New.
	* doc/vizualization/graph/gv/sa-C3.gv: New.
	* doc/vizualization/graph/gv/sa-C4.gv: New.
	* doc/vizualization/graph/gv/sa-D1.gv: New.
	* doc/vizualization/graph/gv/sa-D2.gv: New.
	* doc/vizualization/graph/gv/sa-D2v.gv: New.
	* doc/vizualization/graph/gv/sa-D3.gv: New.
	* doc/vizualization/graph/gv/sa-D3v.gv: New.
	* doc/vizualization/graph/gv/sa-D4v.gv: New.
	* doc/vizualization/graph/gv/sa-D5v1.gv: New.
	* doc/vizualization/graph/gv/sa-D5v2.gv: New.
	* doc/vizualization/graph/gv/sa-DD1.gv: New.
	* doc/vizualization/graph/gv/sa-DD2.gv: New.
	* doc/vizualization/graph/gv/sa-DD3.gv: New.
	* doc/vizualization/graph/gv/sa-DD4.gv: New.
	* doc/vizualization/graph/gv/sa-DD5.gv: New.
	* doc/vizualization/graph/gv/sa-base.gv: New.
	* doc/vizualization/graph/png/sa-A.png: New.
	* doc/vizualization/graph/png/sa-B.png: New.
	* doc/vizualization/graph/png/sa-C1.png: New.
	* doc/vizualization/graph/png/sa-C2.png: New.
	* doc/vizualization/graph/png/sa-C3.png: New.
	* doc/vizualization/graph/png/sa-C4.png: New.
	* doc/vizualization/graph/png/sa-D1.png: New.
	* doc/vizualization/graph/png/sa-D2.png: New.
	* doc/vizualization/graph/png/sa-D2v.png: New.
	* doc/vizualization/graph/png/sa-D3.png: New.
	* doc/vizualization/graph/png/sa-D3v.png: New.
	* doc/vizualization/graph/png/sa-D4v.png: New.
	* doc/vizualization/graph/png/sa-D5v1.png: New.
	* doc/vizualization/graph/png/sa-D5v2.png: New.
	* doc/vizualization/graph/png/sa-DD1.png: New.
	* doc/vizualization/graph/png/sa-DD2.png: New.
	* doc/vizualization/graph/png/sa-DD3.png: New.
	* doc/vizualization/graph/png/sa-DD4.png: New.
	* doc/vizualization/graph/png/sa-DD5.png: New.
	* doc/vizualization/graph/png/sa-base.png: New.
	* doc/vizualization/graph/sources/sa-A.cc: New.
	* doc/vizualization/graph/sources/sa-B.cc: New.
	* doc/vizualization/graph/sources/sa-C.cc: New.
	* doc/vizualization/graph/sources/sa-D.cc: New.
	* doc/vizualization/graph/sources/sa-DD.cc: New.
	* doc/vizualization/graph/sources/sa-base.cc: New.
	* doc/vizualization/graph/svg/sa-A.svg: New.
	* doc/vizualization/graph/svg/sa-B.svg: New.
	* doc/vizualization/graph/svg/sa-C1.svg: New.
	* doc/vizualization/graph/svg/sa-C2.svg: New.
	* doc/vizualization/graph/svg/sa-C3.svg: New.
	* doc/vizualization/graph/svg/sa-C4.svg: New.
	* doc/vizualization/graph/svg/sa-D1.svg: New.
	* doc/vizualization/graph/svg/sa-D2.svg: New.
	* doc/vizualization/graph/svg/sa-D2v.svg: New.
	* doc/vizualization/graph/svg/sa-D3.svg: New.
	* doc/vizualization/graph/svg/sa-D3v.svg: New.
	* doc/vizualization/graph/svg/sa-D4v.svg: New.
	* doc/vizualization/graph/svg/sa-D5v1.svg: New.
	* doc/vizualization/graph/svg/sa-D5v2.svg: New.
	* doc/vizualization/graph/svg/sa-DD1.svg: New.
	* doc/vizualization/graph/svg/sa-DD2.svg: New.
	* doc/vizualization/graph/svg/sa-DD3.svg: New.
	* doc/vizualization/graph/svg/sa-DD4.svg: New.
	* doc/vizualization/graph/svg/sa-DD5.svg: New.
	* doc/vizualization/graph/svg/sa-base.svg: New.
2013-07-23 23:13:55 +02:00
Benjamin Kosnik
e021203019 Add svg generation.
* src/Makefile.am: Add abg-viz-svg.cc, abg-viz-svg.h.
	* tests/Makefile.am: Add test-svg.cc.
	* src/abg-viz-svg.cc: New.
	* src/abg-viz-svg.h: New.
	* tests/test-svg.cc: New.
2013-07-23 23:13:54 +02:00
Dodji Seketeli
3563b06270 Build system fix for make distcheck
* Makefile.am: Support the doc sub-directory.  We don't have a
	COPYRIGHT file.
	* src/Makefile.am: Don't prefix the file paths by the absolute
	path of the src dir; current autotools know how to deal with it,
	otherwise and it break them.
	* tests/Makefile.am: Likewise.  Make sure to remove the output of
	the tests upon make clean.
	* Makefile.in: Re-generate.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* src/Makefile.in: Likewise.
	* tests/Makefile.in: Likewise.
2013-07-23 23:13:51 +02:00
Dodji Seketeli
a7e6fbbd7d Initial support for member class templates
* src/abg-ir.cc (class_decl::add_member_function_template): Fix
	comment.
	(class_decl::add_member_class_template)
	(class_decl::member_class_template::operator==)
	(class_decl::member_class_template_hash::operator()): New
	definitions.
	(class_decl::operator==): Compare member templates.  Fix logic.
	(class_decl::data_member_hash::operator())
	(class_decl::member_function_hash::operator())
	(class_decl::member_function_template_hash::operator()): Don't
	hash the is_static boolean as it's hashed as part of the 'member'
	sub-object hashing.
	(class_decl::member_function_template::operator==): Move this out
	of line here, from the header file.
	(class_decl_hash::operator()): Hash member class templates.
	* src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static
	boolean here, so that it's factorized out of the inherited classes
	of this class.
	(class_decl::data_member::{is_static, m_is_static})
	(class_decl::member_function::{is_static, m_is_static})
	(class_decl::member_function_template::{is_static, m_is_static}): Remove this
	as it's now part of the base 'member' class.
	(class_decl::data_member::operator==)
	(class_decl::member_function::operator==): Don't compare the
	is_static boolean as it's now compared as part of the 'member'
	sub-object comparison.
	(class_decl::member_function_template::operator==): Move this
	out-of-line into src/abg-ir.cc.
	(class class_decl::member_class_template, struct
	class_decl::member_class_template_hash)
	(class_decl::{add_member_class_template,
	get_member_class_templates}): New declarations.
	(class_decl::member_class_templates_type): New typedef.
	* src/abg-reader.cc (build_class_decl): Support de-serializing
	member class templates.
	* src/abg-writer.cc (write_class_decl): Likewise, support
	serializing member class templates.
	* tests/data/test-read-write/test16.xml: New test input.
	* tests/test-read-write.cc (int_out_specs[]): Add the new test
	input to the list of inputs that are de-serialized and serialized
	back.
	* tests/Makefile.am: Add the new test input to the distribution.
2013-07-23 23:13:51 +02:00
Dodji Seketeli
c50b9dbb55 Initial support of class templates
* src/abg-ir.cc (class_template_decl::class_template_decl)
	(class_template_decl::set_pattern)
	(class_template_decl::operator==)
	(class_template_decl::~class_template_decl)
	(class_template_decl_hash::operator())
	(class_tmpl_shared_ptr_hash::operator()): New definitions.
	* src/abg-ir.h (class class_template_decl, struct
	class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash):
	New declarations.
	* src/abg-reader.cc (read_context::const_class_tmpl_map_it): New
	typedef.
	(read_context::get_fn_tmpl_decl): Fix comment.
	(read_context::{get_class_tmpl_decl,key_class_tmpl_decl})
	(build_class_template_decl, handle_class_template_decl): New
	definitions.
	(read_context::m_class_tmpl_map): New member.
	(handle_element): Support "class-template-decl" xml elements
	nodes.
	(build_class_decl): Add missing bits to comment.
	(build_function_template_decl): Fix spacing.
	* src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef.
	(write_context::m_class_tmpl_map): New member.
	(write_context::get_id_for_class_tmpl, write_class_template_decl):
	New definitions.
	(write_template_parameters): Factorize this this out from ...
	(write_function_template_decl): ... here.
	(write_decl): Support writing instances of class_template_decl.
	Fix spacing.
	* tests/data/test-read-write/test15.xml: New test input.
	* tests/Makefile.am: Add the new test15.xml input to the
	distribution.
	* tests/test-read-write.cc (in_out_specs): Add the new test15.xml
	test to the list of serialized output to be de-serialized and
	serialized back.
2013-07-23 23:13:51 +02:00
Dodji Seketeli
97ef8941b3 Support member function templates
* src:abg-ir.h: Move template declarations before class
	class_decl, so that class_decl can have member templates.
	(class class_decl::member_function_template)
	(class_decl::add_member_function_template)
	(class_decl::{base_specs_type, member_types_type,
	data_members_types, member_functions_type,
	member_function_templates_type}): New declarations.
	* src/abg-ir.cc (class_decl::add_member_function_template)
	(class_decl::member_function_template_hash::operator()): New
	definitions.
	(class_decl_hash::operator()):  Support hashing for member
	function templates.
	* src/abg-reader.cc (build_class_decl): Use the new
	class_decl::{member_types_type, data_members_type,
	member_functions_type, base_specs_type} types.  Support member
	function templates.
	* src/abg-writer.cc (write_cdtor_const_static): New definition.
	(write_class_decl): Support member function templates.
	* tests/data/test-read-write/test14.xml: New input data.
	* tests/Makefile.am: Add it to the distribution.
	* tests/test-read-write.cc (InOutSpec int_out_specs): De-serialize
	the new test input file, serialize it back and diff both results.
2013-07-23 23:13:51 +02:00
Dodji Seketeli
6831ba7c21 Support composing template type parameters
* src/abg-ir.h (class tmpl_parm_type_composition): New
	declaration.
	* src/abg-ir.cc
	(tmpl_parm_type_composition::tmpl_parm_type_composition)
	(tmpl_parm_type_composition::~tmpl_parm_type_composition): New
	definitions.
	* src/abg-reader.cc (build_tmpl_parm_type_composition): New
	function.
	(build_template_parameter): Support template parameter type
	composition.
	* src/abg-writer.cc (write_tmpl_parm_type_composition): New
	function.
	(write_template_non_type_parameter): Fix type-id attribute.
	(write_template_parameter): Support template parameter type
	composition.
	* tests/data/test-read-write/test13.xml: New test input.
	* tests/Makefile.am: Add it to the distribution.
	* tests/test-read-write.cc (InOutSpec in_out_spec): Add test13.xml
	to the list of xml file that are de-serialized and serialized back.
2013-07-23 23:13:50 +02:00
Dodji Seketeli
ace9af4568 Fix depth management during the parsing
* src/abg-ir.cc (decl_base_hash::operator()):  Don't hash the
	context for decls in general.
	* src/abg-reader.cc (read_context::push_decl_to_current_scope)
	(read_context::push_and_key_type_decl): Add an overload that takes
	a node and update_depth_info boolean.
	(build_var_decl, build_type_decl, build_qualified_type_decl)
	(build_pointer_type_def, build_reference_type_def)
	(build_enum_type_decl, build_type_decl)
	(build_template_type_parameter, build_template_non_type_parameter)
	(build_template_template_parameter, build_template_parameter)
	(build_type): Make these functions take an update_depth_info
	parameter.  Pass it do read_context::push_and_key_type_decl or
	read_context::push_decl_to_current_scope rather than call
	update_read_context.
	(build_function_decl, build_class_decl)
	(build_function_template_decl): Change the seen_by_reader
	parameter into update_depth_info.  Pass the update_depth_info bool
	to read_context::push_decl_to_current_scope rather than call
	update_depth_info here.
	(handle_class, handle_function_template_decl): Adjust.
	* tests/data/test-read-write/test12.xml: Add new test input.
	* tests/test-read-write.cc (InOutSpec in_out_specs): Add it to the
	list of input to de-serialize, serialize back and compare the two.
	* tests/Makefile.am: Add the new test input to the distribution.
2013-07-23 23:13:50 +02:00
Dodji Seketeli
6a03c86a28 Initial support for function templates
* src/abg-ir.h (function_decl::set_return_type): New inline
	definition.
	(class template_decl, struct template_decl_hash, class
	template_parameter, struct template_parameter_hash, struct
	dynamic_template_parameter_hash, struct
	template_parameter_shared_ptr_hash, class template_type_parameter)
	(struct template_type_parameter_hash, class
	template_non_type_parameter, struct
	template_non_type_parameter_hash, class
	template_template_parameter, struct
	template_template_parameter_hash, class function_template_decl)
	(struct function_template_decl_hash, struct
	fn_tmpl_shared_ptr_hash): New declarations.
	* src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for
	template template, and template type parameters.
	(template_decl_hash::operator, template_decl::~template_decl)
	(template_decl::operator==, template_parameter::operator==)
	(template_parameter_hash::operator())
	(dynamic_template_parameter_hash::operator())
	(template_type_parameter::operator==)
	(template_type_parameter::~template_type_parameter)
	(template_type_parameter_hash::operator())
	(template_non_type_parameter::operator==)
	(template_non_type_parameter::~template_non_type_parameter)
	(template_non_type_parameter_hash::operator())
	(template_template_parameter::operator==)
	(template_template_parameter::~template_template_parameter)
	(template_template_parameter_hash::operator())
	(function_template_decl::operator==)
	(function_template_decl_hash::operator())
	(fn_tmpl_shared_ptr_hash::operator())
	(function_template_decl::~function_template_decl()): New
	definitions.
	* src/abg-reader.cc (read_context::get_fn_tmpl_decl)
	(read_context::key_fn_tmpl_decl): New functions.
	(read_context::m_fn_tmpl_map): New data member.
	(read_context::key_type_decl): Renamed read_context::add_type_decl
	into this.
	(read_context::push_decl_to_current_scope): Renamed
	read_context::finish_decl_creation into this.  Add an assert.
	(read_context::push_and_key_type_decl): Renamed
	read_context::finish_type_decl_creation into this.  Adjust to the
	use of push_decl_to_current_scope and key_type_decl.
	(build_function_template_decl, build_template_type_parameter)
	(build_template_non_type_parameter)
	(build_template_template_parameter, build_template_parameter)
	(handle_function_template_decl): New functions.
	(handle_element): Call handle_function_template_decl.
	(build_function_decl): Take a bool parameter to update depth
	information in parsing context.  Move instantiation of
	function_decl before parsing its xml sub-nodes.  Update the depth
	info in the parsing context if necessary.  Push the newly
	intantiated decl to scope.  And then parse the sub nodes.  Do not
	forget to add the fn parameters and return type using
	function_decl::add_parameter and function_decl::set_return_type.
	(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, handled_type_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): Adjust.
	(build_class_decl): Take a bool parameter to update depth
	information in parsing context. Add comment.  Wait for the class
	members to be built, before keying (and thus hashing it) the
	class.
	(build_type): Fix logic, and adjust.
	* src/abg-writer.cc (write_context::type_has_existing_id)
	(write_context::get_id_for_fn_tmpl, write_template_type_parameter)
	(write_template_non_type_parameter)
	(write_template_template_parameter, write_template_parameter)
	(write_function_template_decl): New functions.
	(write_context::get_id_for_type): Simplify logic.
	(write_decl): Support writing function template.
	* tests/data/test-read-write/test11.xml: New test input.
	* tests/test-read-write.cc (InoutSpec in_out_specs[]):
	De-serialize the new test11.xml test, serialize it back and diff
	output and input.
	* tests/Makefile.am: Add test11.xml to the distribution.
2013-07-23 23:13:50 +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
Dodji Seketeli
816eb4999c Support function declarations
* src/abg-ir.h (class function_decl): New declaration & inline
	definitions.
	* src/abg-ir.cc (function_decl::~function_decl): New definition.
	* src/abg-reader.cc (read_location): New overload to read location
	from an xmlNodePtr.
	(build_function_parameter, handle_function_decl):
	New definitions.
	(handle_element): Support "function-decl" elements.
	* src/abg-writer.cc (write_location): New overload to write a
	location directly, not from a decl.
	(write_function_decl): New definition.
	(write_binding): Support writing the binding attribute from a
	function_decl instance.
	(write_decl): support serializing function
	* tests/data/test-read-write/test9.xml: New test input file.
	* tests/Makefile.am: Add data/test-read-write/test9.xml to the
	build system.
	* tests/test-read-write.cc: De-serialize
	data/test-read-write/test9.xml, serialize it back and diff the
	output from the input.
2013-07-23 23:13:49 +02:00
Dodji Seketeli
760248d26b Support var decl & mangled_name attributes
* src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name)
	(decl_base::set_mangled_name, decl_base::m_mangled_name): New
	declarations.
	(scope_decl::scope_decl: type_decl::type_decl)
	(scope_type_decl::scope_type_decl, typedef_decl::typedef_decl):
	Initialize mangled_name.
	(namespace_decl::namespace_decl): Initialize visibility.
	(class var_decl): New declaration.
	* src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl)
	(type_decl::type_decl, scope_type_decl::scope_type_decl):
	Initialize mangled name.
	(namespace_decl::namespace_decl): Initialize visibility.
	(qualified_type_def::qualified_type_def)
	(pointer_type_def::pointer_type_def)
	(reference_type_def::reference_type_def): By default, set the
	visibility to the same as for the underlying type.
	(enum_type_decl::enum_type_decl, typedef_decl::typedef_decl):
	Initialize mangled name.
	(var_decl::var_decl, var_decl::operator==, var_decl::~var_decl):
	New definitions.
	* src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New
	definitions.
	(read_file): Handle var-decl elements.
	* src/abg-writer.cc (write_location): Rename write_decl_location
	into this.
	(write_var_decl, write_visibility, write_binding): New definitions.
	(write_decl, write_type_decl, write_qualified_type_def)
	(write_pointer_type_def, write_reference_type_def)
	(write_enum_type_decl, write_typedef_decl): Adjust to use
	write_location.
	* tests/data/test-read-write/test8.xml: New test input.
	* tests/test-read-write.cc: De-serialize the above and serialize
	it back and ensure both are equal.
	* tests/Makefile.am: add tests/data/test-read-write/test8.xml to
	the distribution.
2013-04-02 16:51:59 +02:00
Dodji Seketeli
a5a6fd8fce Support typedef declarations
* src/abg-ir.cc (dynamic_type_hash::operator()): Handle hashing of
	a pointer to an instance of typedef_decl.
	(typedef_decl::typedef_decl, typedef_decl::operator==)
	(typedef_decl::operator==, typedef_decl::get_underlying_type)
	(typedef_decl::~typedef_decl): New definitions.
	* src/abg-ir.h (class typedef_decl, struct typedef_decl_hash): New
	declarations.
	* src/abg-reader.cc (handle_typedef_decl): New definition.
	(handle_element): Handle de-serialization of typedef-decl element.
	* src/abg-writer.cc (write_typedef_decl): New definition.
	(write_decl): Handle serialization of an instance of typedef_decl.
	* tests/data/test-read-write/test7.xml: New test.
	* tests/Makefile.am: Add it to the distribution.
	* tests/test-read-write.cc: De-serialize the content of the new
	test, serialize it back and diff both.
2013-03-30 21:59:19 +01:00
Dodji Seketeli
170885cfcc Support enum type declarations
* src/abg-ir.h (class enum_type_decl, struct enum_type_decl_hash):
	New declarations.
	* src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing
	support for enum_type_decl.
	(enum_type_decl::enum_type_decl)
	(enum_type_decl::get_underlying_type)
	(enum_type_decl::get_enumerators, enum_type_decl::~enum_type_decl)
	(enum_type_decl::operator==): New definitions.
	* src/abg-reader.cc (handle_enum_type_decl): New definition.
	(handle_element): Handle "enum-decl" element.
	* src/abg-writer.cc (write_enum_type_decl): New.
	(write_decl): Add support to serialize enum_type_decl.
	* tests/test-read-write.cc: De-serialize and serialize
	data/test-read-write/test6.xml back.
	* tests/data/test-read-write/test6.xml: New test input.
	* tests/Makefile.am: Add it to the distribution.
2013-03-30 19:33:05 +01:00
Dodji Seketeli
0951049924 Support reference types
* src/abg-ir.h (class reference_type_def, struct pointer_type_def)
	(struct reference_type_def): New declaration.
	(type_base_hash::operator(), type_decl_hash::operator())
	(scope_type_decl_hash::operator())
	(qualified_type_def_hash::operator()): Include the typeid name in
	the hash.
	* src/abg-ir.cc (reference_type_def::reference_type_def)
	(reference_type_def::operator==)
	(reference_type_def::get_pointed_to_type)
	(reference_type_def::is_lvalue)
	(reference_type_def::~reference_type_def): New definitions.
	(dynamic_type_hash::operator): Hash pointer_type_def and
	reference_type_def instances.
	* src/abg-reader.cc (read_context::finish_decl_creation)
	(read_context::finish_type_decl_creation)
	(handle_reference_type_def): New definitions.
	(read_file): Handle "reference-type-def" elements.
	(handle_type_decl, handle_namespace_decl)
	(handle_qualified_type_decl, handle_pointer_type_def): Use the new
	read_context::finish_type_decl_creation or
	read_context::finish_decl_creation.
	* src/abg-writer.cc (write_reference_type_def): New definition.
	(write_decl): Supporting writing a pointer to an instance of
	reference_type_def.
	* tests/data/test-read-write/test5.xml: New test file.
	* tests/test-read-write.cc: (De)Serialize it.
	* tests/Makefile.am: Add it to the build system.
2013-03-29 16:44:08 +01:00
Dodji Seketeli
d418d5198f Support pointer types & Fix IR types equality
* src/abg-ir.h (location::{operator==, operator<})
	(decl_base::operator==, scope_decl::operator==)
	(type_base::operator==, struct type_shared_ptr_equal)
	(type_decl::operator==, scope_type::operator==)
	(qualified_type_def::operator==, class pointer_type_def): New
	declarations..
	* src/abg-ir.cc (decl_base::operator==, scope_decl::operator==)
	(type_base::operator==, type_decl::operator==)
	(scope_type_decl::operator==, namespace_decl::operator==)
	(qualified_type_def::operator==)
	(pointer_type_def::pointer_type_def, pointer_type_def::operator==)
	(pointer_type_def::get_pointed_to_type)
	(pointer_type_def::~pointer_type_def): New definitions.
	* src/abg-reader.cc (handle_pointer_type_def): New definition.
	(read_input): Handle pointer-type-def
	elements.
	* src/abg-writer.cc (type_shared_ptr_map):  Make this map use the
	use type_shared_ptr_equal predicate.
	(write_pointer_type_def): New definition.
	(write_decl): Improve logic.  Support serializing a pointer to
	pointer_type_def.
	* tests/data/test-read-write/test4.xml: New test input file.
	* tests/Makefile.am: Add tests/data/test-read-write/test4.xml to
	the build system.
	* tests/test-read-write.cc: (De)serialize the new test file.
2013-03-28 15:42:12 +01:00
Dodji Seketeli
57d8b7da41 Support qualified types & Misc ancillary fixes
* src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash)
	(struct type_shared_ptr_hash, struct scope_type_decl_hash, class
	qualified_type_def, struct qualified_type_def_hash): New.
	(decl_base_hash::operator()): Constify. Don't crash if the scope
	of the decl we are hashing is null.
	(class type_decl): Add comment at the end.
	(type_decl_hash::operator()): Constify.  Reuse the new
	type_base_hash hasher.
	(class namespace_decl): Add comment.
	* src/abg-ir.cc (qualified_type_def::qualified_type_def)
	(qualified_type_def::~qualified_type_def)
	(qualified_type_def::get_cv_quals)
	(qualified_type_def::set_cv_quals)
	(qualified_type_def::get_underlying_type)
	(dynamic_type_hash::operator()): New function definitions.
	* src/abg-reader.cc (handle_qualified_type_decl): New.
	(read_file): Handle elements named "qualified-type-def".
	(read::context::add_type_decl): Assert that
	the type being associated to the unique ID is non-null.
	(handle_type_decl): Fix this in the process; don't crash if some
	attributes are not present.  Associate the unique id present in
	the xml document with the type we just parsed.
	(handle_namespace_decl): Add some comments.  Don't crash if the
	name attribute is not present.
	* src/abg-writer.cc (write_context::get_id_for_type)
	(write_context::m_type_id_map, write_decl_location)
	(write_qualified_type_def): New.
	(write_decl): Handle instances of qualified_type_def.
	(write_type_decl): Use the new write_decl_location and
	write_context::get_id_for_type.
	* tests/data/test-read-write/test0.xml: Update id format since we
	are now using the new write_context::get_id_for_type to generate
	it.
	* tests/data/test-read-write/test1.xml: Likewise.
	* tests/data/test-read-write/test2.xml: Likewise.
	* tests/data/test-read-write/test3.xml: New test.
	* tests/test-read-write.cc: Test De-serializing
	tests/data/test-read-write/test3.xml and serializing it back.
	Also don't bail out if we fail on one input.
	* tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the
	distribution.
2013-03-27 23:59:16 +01:00
Dodji Seketeli
90930a5716 Fix parallel build
* tests/Makefile.am: Remove useless absolute reference to the
	current directory.
2013-03-26 12:22:28 +01:00
Dodji Seketeli
1c1532d60d Fix depth handling during the parsing
* src/abg-reader.cc (read_context::get_cur_scope): Remove useless
	const overload.  Don't make this rely on m_cur_scope.  Rather, use
	the path to the current decl (from the root element) to compute
	the cur scope.
	(read_context::m_cur_scope, read_context::set_cur_scope): Remove
	these.
	(update_read_context): Re-think logic.
	* tests/data/test-read-write/test2.xml: Add new test input.
	* tests/Makefile.am: Add data/test-read-write/test2.xml to the
	distribution.
	* tests/test-read-write.cc: Add data/test-read-write/test2.xml to
	the harness.
2013-03-26 11:43:59 +01:00
Dodji Seketeli
4ef7b34387 Debug read-write of a type-decl in a namespace-decl
* abg-ir.{h,cc} (decl_base::decl_base, scope_decl::scope_decl)
	(type_decl::type_decl, namespace_decl::namespace_decl): Do not
	append a decl to its context from within its constructor.  It's
	better doing that in a function that takes shared_ptrs to decl and
	context.  That way we avoid memory management havoc.
	(decl_base::set_scope): New private function.
	(scope_decl::add_member_decl): Make this private.
	(add_decl_to_scope): New function, friend of decl_base and
	scope_decl.
	* abg-reader.cc (read_context::get_cur_scope): Add a non-const
	overload.
	(handle_type_decl, handle_namespace_decl): Use add_decl_to_scope.
	Adjust to new type_decl and namespace_decl constructor signature.
	* src/abg-writer.cc (write_type): Emit 'id', not 'xml:id'.
	(write_namespace_decl): Emit "namespace-decl", not
	"namespace-decl-name", as the name of namespace element.
	* tests/Makefile.am (test0.xml): Rename input0.xml into this.
	(test1.xml): New test input.
	* tests/data/test-read-write/test0.xml: Update to use 'id' as id
	attribute, rather than xml:id.
	* tests/data/test-read-write/test1.xml: New test.
	* test-read-write.cc (struct InOutSpec): New
	(main): Reorganize to give a list of input files to read and to
	write to an output file, have the test read the input files, write
	them, and diff the two.
2013-03-25 16:56:00 +01:00
Dodji Seketeli
fc27d10cee Debugged type-decl de-serialization
* src/abg-ir.cc (namespace_decl::~namespace_decl): Add this
	missing virtual constructor definition.
	* src/abg-reader.cc (read_context::{get_cur_decl,pop_decl}):
	Return a null pointer when the decls stack is empty.
	(update_read_context): Don't try to de-reference a NULL cur_decl.
	(read_input): Don't try to poke at file validity here.  What was I
	thinking.  Really test for advance_cursor to return 1, expressing
	success.
	* src/abg-reader.h (read_file):  Fix style.
	* Makefile.am: Add tests sub-directory.
	* configure.ac: Build with debugging-friendly options if the
	ABIGAIL_DEBUG env variable is set.  Generate tests/Makefile.
	* tests/Makefile.am: New file.
	* tests/test-read-write.cc: Likewise.
	* tests/test-utils.{h,cc}: Likewise.
	* tests/data/test-read-write/input0.xml: Likewise.
2013-03-21 23:57:22 +01:00