* tools/bilint.cc (options::options): Initialize ...
(options::{diff, bidiff}): ... new members.
(display_usage): Update the display usage string for --diff &
--bidiff options.
(parse_command_line): Support the --diff and --bidiff options.
(main): Require the --diff option to actually diff the emitted
output with input. Make --noout really work for when reading
from dwarf.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (read_context::m_decls_stack): Make this is a
std::deque, rather than a std::stack.
(read_context::{get_id_xml_node_map,
clear_id_xml_node_map, get_xml_node_decl_map,
map_xml_node_to_decl, get_decl_for_xml_node,
clear_xml_node_decl_map, map_id_and_node, get_xml_node_from_id,
get_scope_for_node, build_or_get_type_decl}): New member
functions.
(read_context::{get_cur_decl, push_decl, pop_decl}): Update this
now that the decl stack uses a std::deque.
(read_context::clear_decls_stack): New.
(read_context::get_translation_unit): Use the first decl of the
decl stack, that is most certainly the global scope of the current
translation unit, to get the translation unit.
(read_context::key_type_decl): Take a new flag to force the
re-keying; that is set an id to a new type, even if the id was
already set to a type.
(read_context::push_and_key_type_decl): Assert that a type must
have a declaration.
(handle_*): Make these return the decl_base_sptr resulting from
the parsing of the xml node, rather than just a bool.
(walk_xml_node_to_map_type_ids): New static function.
(read_translation_unit_from_input): Read the abi-instr xml
sub-tree once, just to build an id->xml node map. That way, when a
declaration needs a type what is not yet defined, it can just get
its XML node, build the type from it and use it. Do not forget to
advance the xml reader cursor when the reading of the 'abi-instr'
sub-tree is read. Clear all the new maps we have used for the
current translation unit.
(handle_element_node): Cleanup logic.
(build_namespace_decl): Update the new xml node -> decl map, and
use it to avoid building the same namespace twice.
(build_function_parameter): Do not even try to get the type of a
variadic parameter.
(build_function_decl, build_var_decl): Support types that are defined later.
(build_type_decl): Do not build the same type twice. But there
can be several 'unnamed-enum-underlying-type' node. In that case
just return the previous one.
(build_qualified_type_decl, build_pointer_type_def)
(build_reference_type_def, build_enum_type_decl)
(build_typedef_decl): Support underlying type defined later.
(build_class_decl): Support declaration-only related cases where
we can have several xml nodes with the same id. Update the new
xml node -> IR node maps. Fix member type adding.
(build_type_tparameter, build_non_type_tparameter)
(build_template_tparameter): Support used types defined later.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (class_decl::add_member_class_template): Do not
forget the scope of the member class template itself.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-libxml-utils.cc (unescape_xml_string): Avoid and endless
loop for strings containing an '&' but that are not pre-defined
entities.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::declaration_): Make this be a
decl_base_sptr so that it can actually be a
class_decl::member_type which underlying type is a class decl.
(class_decl::{set, get}_earlier_declaration): Take or return a
decl_base_sptr rather than a class_decl_sptr.
* src/abg-ir.cc (class_decl::set_earlier_declaration): Take a
decl_base_sptr rather than a class_decl_sptr.
* src/abg-dwarf-reader.cc (die_class_map_type): Make this map take
decl_base_sptr rather than a class_decl_sptr.
(build_class_type_and_add_to_ir): If the class being currently
built is a member class, do not loose that information after it
has been added to its scope. Also, base types and types of member
variables can be member types and should retain that information.
(build_qualified_type): Likewise, the underlying type of a
qualified type shouldn't loose the information about its
potentially being a member type.
(build_pointer_type_def, build_reference_type, build_typedef_type)
(build_var_decl, build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::{member_function_template,
member_class_template}): Make these inherit from decl_base, to
comply with class_decl::member_type.
(class_decl_base_spec::{base_spec, member_type, member_function,
member_function_template, member_class_template}::hash): Declare
these hashing functors in the header here.
(class_decl::{member_base, member_type, data_member,
member_function, member_function_template,
member_class_template}:#️⃣:operator()): define these out of
line here.
(type_base::dynamic_hash::operator()): Update this to hash member
things.
* src/abg-writer.cc (write_qualified_type_def)
(write_pointer_type_def, write_class_decl)
(write_reference_type_def, write_enum_type_decl): Add an overload
that takes the type ID to use in the serialization.
(write_member_type): New implementation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* include/abg-ir.h (location_manager::_Impl): Rename this type
into priv.
* src/abg-ir.cc b/src/abg-ir.cc (location_manager::_Impl):
Likewise.
(location_manager::location_manager): Update for the renaming
above.
* src/abg-reader.cc (build_type_decl): Remove useless white space.
(build_enum_type_decl, build_class_decl): Use the _sptr typedef in
the return type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (update_read_context)
(update_depth_info_of_read_context): Remove.
(read_context::{pop_scope, pop_scope_or_abort): New.
(read_context::{push_decl_to_current_scope,
push_and_key_type_decl}): Remove the overloads that take the
'update_depth_info' boolean.
(build_namespace_decl): New static function.
(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_type_decl)
(build_class_decl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter, build_type): Remove the
'update_depth_info' boolean from parameters.
(handle_element_node): Renamed handle_element into this. Take an
xml node and a boolean to add the resulting IR node to the IR.
(handle_type_decl, 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):
Take an xml node and a boolean to add the resulting IR node to the
IR.
(advance_cursor): No more need to call update_read_context.
(read_translation_unit_from_input): Expand the 'abi-instr' node
into memory so that we walk its XML nodes and build the IR nodes
from them.
(read_location): Remove the overload that was using the xml reader.
():
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (read_context::{get_cur_decl, pop_decl}): Return
decl_base_sptr rather than shared_ptr<decl_base>.
(read_context::push_decl): Take a decl_base_sptr rather than
shared_ptr<decl_base>.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* tests/data/test-read-dwarf/test0.cc: Define a member function
out-of-line, outside of its namespace.
* tests/data/test-read-dwarf/test0.abi: Update the .abi file.
* tests/data/test-read-dwarf/test0: Update the resulting binary.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* read_translation_unit_from_input
(read_translation_unit_from_input): Abort when an element could
not be handled.
(build_function_parameter, build_type_decl, qualified_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_enum_type_decl, build_typedef_decl, build_class_decl)
(build_type_tparameter, build_template_tparameter)
(handle_qualified_type_decl, handle_pointer_type_def)
(handle_reference_type_def, handle_typedef_decl):
Abort when a referred-to type is not found or if a type is defined twice.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (qualified_type::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(typedef_decl::get_underlying_type): Avoid triggering refcount
counter increasing/decreasing here, by returning a reference to
the underlying type. This showed up high on a profile.
({scope_decl, type_decl, scope_type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl, class_decl}::operator==):
Avoid taking the exception-using path of dynamic_cast. This
showed up very high on a profile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (read_context::clear_type_map): New member
function.
(read_translation_unit_from_input): Read up to the next element
node if we are not on an element node already. Clear the type
map. Realize that we might be on the next 'abi-instr' node upon
completion.
(read_corpus_from_input): Read up to the next element node if we
are not on an element node already. It must be an "abi-corpus"
node. THen Advance to the next 'abi-instr' element node before
handing it to read_translation_unit_from_input.
* src/abg-writer.cc (write_context::clear_type_id_map): New member
function.
(write_translation_unit): Call it.
* tools/abg-tools-utils.cc (guess_file_type): Read enough bytes to
detect abi-corpus files magic bytes.
* tools/bilint.cc (main): Do not write the corpus file to the
output stream if --noout has been provided.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (decl_base::hash_): New member.
(decl_base::{g,s}et_hash): New accessors.
(type_base_::cached_hash): Forward-declare new hasher.
(struct type_ptr_equal): New equality predicate.
(type_shared_ptr_equal::operator()): Do not forget to test pointer
equality.
(type_base::cached_hash): Declare new hasher.
* src/abg-hash.cc ({decl_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl, function_decl,
function_decl::parameter, class_decl::data_member,
class_decl::member_function, class_decl, }:#️⃣:operator()):
Implement caching.
(type_base::cached_hash::operator()(const type_base*)): Define.
(type_base::cached_hash::operator() (const type_base_sptr):
Define.
* src/abg-ir.cc (type_ptr_map): Make this map use
type_base::cached_hash instead of type_base::ptr_hash now.
(decl_base::decl_base): Initialize the new
decl_base::hash_. member.
(decl_base::{s,g}et_hash): Define.
(decl_base::operator==(const decl_base& other)): Take the hash in
account to speed up inequality detection.
* src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map
into this. Make it use type_base::cached_hash and type_ptr_equal
instead of type_base::shared_ptr_hash and type_shared_ptr_equal.
(get_id_for_type): Add overload for type_base*. Re-write the
previous overload in terms of this one.
(write_context::m_type_id_map): Use type_ptr_map as the type for
this.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* 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>
* include/abg-comparison.h (string_function_ptr_map)
(changed_function_ptr, string_changed_function_ptr_map)
(corpus_diff_sptr): New convenience typedefs.
(translation_unit_diff): Add comments.
(class corpus_diff): New type.
(compute_diff): New overload for corpus_diff.
* include/abg-corpus.h (corpus::{functions, variables}): New
typedefs.
(corpus::{operator==, get_functions, get_variables}): New members.
* include/abg-diff-utils.h (struct deep_ptr_eq_functor): New
functor.
* include/abg-ir.h (translation_unit::operator==): New member
equality operator.
* src/abg-comparison.cc (struct corpus_diff::priv): New private
struct holding the private members of corpus_diff.
(corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables,
ensure_lookup_tables_populated}): Define new private member functions.
(corpus_diff::{corpus_diff, first_corpus, second_corpus,
function_changes, variable_changes, length, report}): New public members.
(struct noop_deleter): New struct.
(compute_diff): New implementation for corpus_diff.
* src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl
into this. Add new fns, vars and is_symbol_table_built data
members.
(corpus::priv::build_symbol_table): New member function.
(class symtab_build_visitor_type): New visitor type to build the
symbol table.
(struct func_comp, struct var_comp): New comparison functors.
(corpus::priv::build_symbol_table): Define new member function.
(corpus::{corpus, add, get_translation_units, operator==,
get_functions, get_variables}): Define new members.
* src/abg-ir.cc (translation_unit::operator==): Define new member
equality operator.
(operator==(translation_unit_sptr l, translation_unit_sptr r)):
Define new equality operator.
* tools/abg-tools-utils.h (enum file_type): New enum.
(guess_file_type): Declare new function.
* tools/abg-tools-utils.cc (guess_file_type): define new function.
* tools/bidiff.cc (main): Guess the type of the files given in
input and support elf files reading and diffing.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (struct default_eq_functor): New
equality functor.
(end_of_fr_d_path_in_k, end_of_frr_d_path_in_k_plus_delta): Add a
new equality functor template parameter and document it. Use it
to compare the elements of the sequences given in argument.
(compute_middle_snake, ses_len, compute_diff): Add a new equality
functor template parameter and document it. Adjust call to
end_of_frr_d_path_in_k_plus_delta, end_of_fr_d_path_in_k and
compute_middle_snake.
(ses_len, compute_diff): Add a new overload that uses a
default_eq_functor as comparison functor, to avoid breaking
existing client code.
* src/abg-diff-utils.cc (compute_middle_snake): Adjust the call to
the compute_middle_snake.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (ir_traversable_base): New type to be the base
of IR nodes that are to be traversed. Extends traversable_base.
Its ir_traversable_base::traversable() method takes an
ir_node_visitor&.
(ir_node_visitor::visit): Change these virtual overloads to take
pointers to IR nodes, rather than references. This will be useful
to e.g, store these IR nodes in containers on the side for some
algorithms to work. That is going to be useful later to,
e.g. build symbol tables on the side, using the visitor interface.
(class decl_base): Make this inherit ir_traversable_base.
* src/abg-ir.cc (*::traverse): Adjust comments and the call the
ir_node_visitor::visit call. Use the ir_traversable_base type
rather than traversable_base.
(ir_traversable_base::traverse): Define.
(ir_node_visitor::visit): Change these overloads to take pointers
rather than reference to ir nodes.
* tests/test-walker.cc (name_printing_visitor::visit): Adjust to
take pointers rather than references.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (method_type_sptr): New convenience typedef.
* src/abg-dwarf-reader.cc (read_context::{dwarf_version,
die_wip_classes_map}): New accessors.
(die_is_virtual): Rename is_virtual into this.
(is_type_tag, is_type_die, die_virtual_function_index): Define new
static functions.
(die_member_offset): Fix comment.
(get_scope_for_die): Take the read context as argument.
(canonicalize_and_add_type_to_ir): Likewise. On NULL scope, get
the current translation unit from the read context.
(canonicalize_and_insert_type_into_ir_under_scope): Handle NULL
context.
(build_function_decl): Support creating method_decls from here
when necessary.
(build_class_type_and_add_to_ir): Rename build_class_type into
this. Handle adding the class to the IR and to the relevant maps.
During the creation of the class, arrange for
build_ir_node_from_die on the current DIE to return a
declaration-only class, representing the declaration for the class
that is being constructed. This breaks circular dependencies
induced by decls/types that refer to the class being built, before
the class is fully built and has a (logical) type ID. Once the
class is created, make it refer to the class declaration that was
previously handed for the requests to the class DIE. Now requests
to the class DIE will just yield the newly built class. Add
support for member functions and member types.
(build_corpus): Support reading the dwarf version and stick it
into the context.
(build_ir_node_from_die): Adjust for change in
canonicalize_and_add_type_to_ir and build_class_type signature
change.
* src/abg-ir.cc (class_decl::method_decl::get_type): Support
returning NULL type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (decl_base::set_scope): Make this virtual.
(class_decl::member_type::set_scope): Declare an overload here.
* src/abg-ir.cc (class_decl::member_type::set_scope): Define new
overload. Make this set the scope of the underlying type of the
member type as well.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (function_decl::parameter::{get,
set}_artificial): Add new accessors for an "artificial" flag.
* src/abg-reader.cc (build_function_parameter): Support reading
the artificial parameter flag.
* src/abg-writer.cc (write_function_decl): Support writing the
artificial parameter flag.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (enum virtuality): New enum.
(class expr_result, struct dwarf_expr_eval_context): New types.
(die_size_in_bits)
(die_access_specifier, die_virtuality, is_virtual)
(die_location_expr, op_pushes_constant_value)
(op_pushes_non_constant_value, op_manipulates_stack)
(op_is_arith_logic, op_is_control_flow)
(eval_last_constant_dwarf_sub_expr, die_member_offset)
(build_class_type): New static functions.
(build_ir_node_from_die<DW_TAG_{class, structure}_type>): Support
creating IR node for class and struct by calling the new
build_class_type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-libxml-utils.cc (xml_istream_input_read): Return the
byte read count even when the stream seems to be borked. In that
case it should be zero.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc
(build_ir_node_from_die<DW_TAG_pointer_type)
(DW_TAG_rvalue{0,1}_reference_type>): Do not crash if building the
IR node for the underlying type yields NULL.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (die_string_attribute)
(die_unsigned_constant_attribute, die_signed_constant_attribute)
(die_flag_attribute, die_die_attribute): Use dwarf_attr_integrate
rather than dwarf_attr to look through DW_AT_abstract_origin.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_enum_type): New function.
(build_ir_node_from_die): Call the new build_enum_type here to
Handle DW_TAG_enumeration_type DIEs.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (translation_unit::{mark_type_as_used,
prune_unused_types}): Remove these declarations.
* src/abg-ir.cc (translation_unit::priv::used_types_): Remove.
(class subtype_marking_visitor): Likewise.
(translation_unit::{mark_type_as_used, prune_unused_types):
Likewise.
(get_top_most_scope_under): Fix logic and add comment.
* src/abg-dwarf-reader.cc (die_tu_map_type, offset_offset_map):
New convenience typedefs.
(read_context::{die_tu_map_, die_parent_map_}): New context
members.
(read_context::{die_tu_map, die_parent_map}): New accessors.
(build_ir_node_from_die): New overload that takes the scope of the
ir node in parameter.
(die_signed_constant_attribute): Un-comment this.
(build_die_parent_relations_under, build_die_parent_map)
(get_parent_die, get_scope_for_die): New static functions.
(build_translation_unit_and_add_to_ir): Renamed
build_translation_unit into this. Populate the new
read_context::die_tu_map() here.
(canonicalize_and_add_type_to_ir)
(canonicalize_and_insert_type_into_ir)
(canonicalize_and_insert_type_into_ir_under_scope): Move these
overloads over the top of the file.
(build_namespace_decl_and_add_to_ir): Fix this by adding the
namespace to the IR scope of the DIE (using the new
get_scope_for_die()). Update the read_context::die_decl_map()
map.
(build_function_decl): Support functions that return void. Also,
skip parameters that don't have type set.
(build_corpus): Walk all the DIEs to build a DIE -> parent map.
Adjust for the rename to build_translation_unit_and_add_to_ir.
(build_ir_node_from_die): Add a scope parm. Adjust back to
building IR nodes only for public decls, unless the
'called_from_public_decl' flag is set. Adjust to stick the resulting
IR node into the scope given in parameter.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (subtype_marking_visitor): New visitor.
(translation_unit::mark_type_as_used): When marking a composite
type as used, mark its sub-types as well.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h ({translation_unit, decl_base, scope_decl,
type_decl, namespace_decl, qualified_type_decl, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
function_tdecl, class_decl, class_decl::data_member,
class_decl::member_function, class_decl::member_function_template,
class_decl::member_class_template}::traverse): Add a virtual
keyword at least to "document" that this method is virtual -- and
thus remind the user that it overrides the
traversable_base::traverse().
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* 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>
* 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>
* 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>