* include/abg-ir.h (traversable): To traversable_base.
(decl_base): Inherit from traversable_base.
(decl_base::traverse): Null definition.
(function_decl, etc.): Remove traversable_base as base class.
* include/abg-ir.h (scope_decl): Add declarations, scopes as types.
(function_type): Add parameter_sptr, parameters as types.
(enum_type_decl): Add type_sptr, enumerators as types.
(class_decl): Adjust typedefs for consistency. Change
base_specs_type to base_specs, member_types_type to member_types,
data_members_type to data_members, member_functions_type to
member_functions, member_function_templates_type to
member_function_templates, member_class_templates_type to
member_class_templates.
* 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.
* 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.
* src/abg-ir.h (class_decl::base_spec::base_spec): Take an offset
and a is_virtual flag.
(class_decl::base_spec::{get_is_virtual, get_offset_in_bits}): New
methods.
(class_decl::has_no_base_nor_member): New method declaration..
* src/abg-ir.cc (class_decl::base_spec::base_spec): Take an offset
and a is_virtual flag
(class_decl::has_no_base_nor_member): Define it.
* src/abg-reader.cc (read_offset_in_bits): Renamed
read_var_offset_in_bits into this.
(read_is_virtual): New static function.
(build_class_decl): Read the 'layout-offset-in-bits' and the
'is-virtual' of the base class specifier. Adjust for the
read_var_offset_in_bits -> read_offset_in_bits rename.
* src/abg-writer.cc (write_layout_offset): New overload for the
base class specifiers.
(write_class_decl): If the class has no member or base class, make
it a proper empty xml element. Write the offset and the
is-virtual attribute.
* tests/data/test-read-write/test20.xml: New test input data.
* tests/test-read-write.cc: De-serialize the test above, serialize
it back and compare that both versions are the same.
* src/abg-ir.h (class_decl::base_spec::base_spec): Move this
out-of-line. Add a new constructor for clients compiled without
RTTI.
* src/abg-ir.cc (class_decl::base_spec::base_spec): This is now
here out-of-line. Define the new constructor for clients compiled
without RTTI.
* tests/data/test-read-write/test19.xml: New test case input for
base classes.
* tests/test-read-write.cc: De-serialize and serialize the new
test case input above.
* abg-ir.h (class_decl::set_earlier_declaration): Move this
out-of-line and add an overload.
* src/abg-ir.cc (class_decl::set_earlier_declaration): Moved this
out-of-line here and add an overload.
* src/abg-reader.cc (build_class_decl): Really read the
'decl-of-decl-id' property. Do not make the definition use the id
of the declaration. Both have their id.
* src/abg-writer.cc (write_class_decl): Put a space before the
property "def-of-decl-id".
* tests/data/test-read-write/test18.xml: New test input.
* tests/test-read-write.cc: De-serialize this new input, serialize
it back and make sure both versions are identical.
* src/abg-ir.h (qualified_type_def::CV_RESTRICT): New enumerator
for the qualified_type_def::CV enum.
(operator|(qualified_type_def::CV, qualified_type_def::CV)): New
declaration.
* src/abg-ir.cc (operator|(qualified_type_def::CV,
qualified_type_def::CV)): New definition.
* src/abg-reader.cc (build_qualified_type_decl): No need for
casting the result of bitwise or between instances of
qualified_type_def::CV.
* 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.
* 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.
* src/abg-ir.h (scope_decl::m_member_scopes)
(scope_decl::get_member_scopes): New declarations.
(scope_decl::add_member_decl): Move this to ...
* src/abg-ir.cc (scope_decl::add_member_decl): ... here. Make it
update the new scope_decl::m_member_scopes too.
* src/abg-ir.h (global_scope::global_scope): Take a translation
unit and initialize the tu member with it.
* src/abg-ir.cc (translation_unit::get_global_scope): Initialize
the global scope with its actual translation unit.
* src/abg-irc.cc (location_manager::create_new_location): Just
append the new expanded location to the end of the location
vectors, and return the new size of the vector as the location
number. That way we don't change the location number of an
expanded location that is already in the vector -- that change
happens if we keep the vector sorted during the insertion.
(location_manager::expand_location): The index of the expanded
location is the location number - 1.