* src/abg-comparison.cc
(distinct_diff::entities_are_of_distinct_kinds): Consider two NULL
decls are distinct types for the purpose of diffing. This is just
a shortcut to avoid creating a null_diff type for now. But then,
stop considering same pointers as different. This was a bug.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Insert
reference, pointers and qualified types at the point where we see
them, in their scope, rather than under the scope of their
underlying type. This is because their might be first declared as
member types and we don't want to loose that information.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-diff-utils.h (namespace diff_utils): Add comment.
(compute_diff): Update comments for some overloads where they were
missing.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): use
as_non_member_class_decl rather that complicated casting.
src/abg-ir.cc (var_decl::get_pretty_representation): Use
get_type_declaration rather than casting.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (class member_type_diff): New class.
(member_type_diff_sptr): New convenience typedef.
(compute_diff): New overload for member_type_diff.
* src/abg-comparison.cc (struct member_type_diff::priv): New
definition.
(member_type_diff::{first_member_type, second_member_type,
underlying_type_diff, length}): New member function definitions.
(compute_diff): New definition for member type diffs.
(compute_diff_for_types): Support diffing
member types.
(class_diff::report): Do not use strip member types now that we
can properly diff them.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (decl_base::{location_, name_,
qualified_parent_name_, qualified_name_}): Make these data members
protected rather than private.
(decl_base::get_qualified_parent_name): Declare new member
functions.
(decl_base::get_qualified_name): Make the core overload virtual.
Simplify the other overload that calls the core one.
(qualified_type_def::build_name): Declare new protected helper
function.
(qualified_type_def::{get_cv_quals_string_prefix,
get_qualified_name}): Declare new functions.
(pointer_type_def::{get_qualified_name}}): Likewise.
(class_decl::member_type::get_qualified_name): Likewise.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): New
definition.
(decl_base::get_name): Make this out-of-line.
(decl_base::get_qualified_name): The signature of this got
simplified. Make it use the new get_qualified_parent_name.
(qualified_type_def::{build_name, get_qualified_name,
get_cv_quals_string_prefix}): New definitions.
(qualified_type_def::qualified_type_def): Update the constructor
to use the new build_name function above.
(pointer_type_def::get_qualified_name): New definitions.
(reference_type_def::get_qualified_name): Likewise.
(class_decl::member_type::get_qualified_name): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.h (compute_diff): For class_decl_sptr, do not
compare member types and member class templates. This adds a lots
of noise that is not necessarily useful for now.
* tests/data/test-bidiff/test-qual-type0-report.txt: Update tests.
* tests/data/test-bidiff/test-struct0-report.txt: Likewise.
* tests/data/test-bidiff/test-struct1-report.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(function_decl_diff::priv::{inserted_parms_, removed_parms_}):
Remove these.
(function_decl_diff::ensure_lookup_tables_populated): Fix thinko.
Avoid using the members removed above. Use one less loop to
update the changed params.
(function_decl_diff::report): Avoid using the removed_parms_
data member that was removed above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h
(class_decl::member_base::set_access_specifier): Put the setter
for access specifier here, where it belongs ...
(class_decl::member_type::set_access_specifier): ... not here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (is_declaration_only): Put this back (I
removed it earlier).
(build_class_type_and_add_to_ir): If the class is a
declaration-only (a forward declaration), do not add a new
declaration only IR node.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (function_type::function_type): In the
constructor that takes a vector of parms, walk the vector and set
the indexes of the parms.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (function_decl_diff::report): Do not talk
about changed function anymore. Rather, say that some indirect
sub-types changed in the function.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
Associate the member type IR node to the offset of the die of the
member type.
(build_ir_node_from_die): For a DW_TAG_subprogram DIE that has a
DW_AT_specification pointing to another subprogram DIE, associate
the offset of this DIE to the IR node of that other DIE.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (fqn_to_components)
(lookup_type_in_translation_unit, demangle_cplus_mangled_name):
Declare new public entry points
* src/abg-comparison.cc (corpus_diff::report): Report stuff about
global variables using their mangled name, and demangle them. If
there is no mangled name for the variable, then use its pretty
representation.
(compute_diff): For the corpus overload, compare global variables
using their mangled name, if its available; otherwise, fall back
to using their pretty representation.
* src/abg-corpus.cc (var_comp::operator()(const var_decl*,
const_var_decl*)): Compare variables using their mangled name in
priority. If it's not available then use their pretty
representation.
* src/abg-dwarf-reader.cc
(read_context::var_decls_to_re_add_to_tree): New accessor.
(build_translation_unit_and_add_to_ir): If there is what appears
to be a definition of a static member variable variable -- this is
in case this definition lacks the DW_AT_specification attribute
that links it to the DW_TAG_member or DW_TAG_variable DIE that is
a child of the right class/structure DIE -- that is not at the
right place in the DIE tree, remove it from the its current place
in the tree and try to hang it off of the right DIE. To do this,
de-mangle its mangled name, look at what is supposed to be the
parent class name, look it up in the translation unit IR, and if
found, stick the variable IR node in there, as a static member
variable. If not found, then bad luck.
(build_class_type_and_add_to_ir): Do not try to see if a member
variable is static here as the way I was doing it was unreliable.
Build the data member node directly w/o going through building a
variable node first. Register the data member in the die offset
-> IR node map.
(build_ir_node_from_die): When seeing DW_TAG_variable, look for a
DW_AT_specification attribute. If there is one, then it points to
a the DIE of a data member and means that data member is static.
Flag the IR node of that data member as static thus. Update the
die offset -> IR node map. If there is no DW_AT_specification
attribute or if it doesn't point to a data member DIE, schedule
this variable tag for a stage when after the whole IR is built for
the translation unit, the variable's mangled named is inspected,
its hypothetical parent struct/class is looked up and the variable
IR node is put into the node of the right struct/class IR node.
* src/abg-ir.cc (enum lookup_entity_kind): New.
(fqn_to_components, iterator, lookup_type_in_translation_unit)
(lookup_node_in_translation_unit, lookup_type_in_translation_unit)
(demangle_cplus_mangled_name): New function definitions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (class_decl::insert_member_decl): Support taking
a var_decl.
(class_decl::add_data_member): Do not insert a data member twice.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Support several
instances of the same member function being deleted. That can
happen when the same member function was present in the initial
class several times. Yeah, I've seen that in dwarf.
* src/abg-corpus.cc (corpus::priv::build_symbol_table): Do not add
the same variable (identified by its mangled name) twice in the
variable symbol table.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): If a function
has changed, deleted it from the list the removed functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (read_context::map_id_and_node): Allow
duplicated class and basic type declarations.
(build_type_decl): Allow duplicated type decls.
(build_qualified_type_decl, build_pointer_type_def)
(build_reference_type_def): As there can be several distinct
duplicated types, compare them by value.
(build_class_decl): There can be duplicated class decls.
* src/abg-writer.cc (write_enum_type_decl): The name of the enum
needs to be xml-escaped.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-reader.cc (build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def): Consider that
these types can be member types.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (typedef_decl::operator==): Consider two typedefs
with different names to be different.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): For the
DW_TAG_subprogram case, bail out early if the current function is
non-public.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h
(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Declare
new accessors.
(corpus_diff::context): Declare new getter.
* src/abg-comparison.cc
(diff_context::{show_{deleted,changed_added}_{fns,vars}}): Define
these new accessors.
(corpus_diff::priv::emit_corpus_diff_stats): Define new function.
(corpus_diff::context()): Define new getter.
(corpus_diff::report): Use the new
corpus_diff::priv::emit_corpus_diff_stats to emit diff stats at
the beginning of the report. Conditionalise emitting the
different parts of the reports (changed,deleted,added stuff) on
the values of the new properties that were just added.
* tools/bidiff.cc
(options::{show_{deleted,changed,added}_{fns,vars}): New
properties.
(display_usage, parse_command_line): Update for the newly added
--{changed,deleted,added}-{fns,vars} command line options.
(set_diff_context_from_opts): Define new static function.
(main): Create a diff context, initialize it from the options
(using set_diff_context_from_opts) and pass it to compute_diff.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::member_type::traverse): Declare new virtual
function.
(ir_node_visitor::visit): Declare new virtual function
* src/abg-ir.cc (class_decl::member_type::traverse): Implement the
traversal of a member type.
(ir_node_visitor::visit): Provide a default implementation for the
visitor of member type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-fwd.h (as_non_member_class_decl): Declare new overload.
* src/abg-ir.cc (as_non_member_class_decl): Define new overload.
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Add
member functions to the DIE -> IR Node map.
(build_ir_node_from_die): Assert that DW_TAG_subprogram cannot be
for a member function here because getting the scope of the member
function would have constructed the entire class that contains it,
including the member function. Then, calling
build_ir_node_from_die for the DIE of the member function would
find the already IR Node in the DIE -> IR Node map.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (class_decl::enum access_specifier): Give the enumerators
the same values as what the DWARF spec says.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-ir.h (function_decl::parameter::get_type_name): Add
comment.
(function_decl::parameter::get_type_pretty_representation): New
member fn.
* src/abg-comparison.cc (represent): When representing changed
members, use their pretty representation.
(function_decl_diff::{ensure_lookup_tables_populated, report}): Use the
pretty representation of parameters type.
(typedef_diff::report): Enclose the underlying type in "'".
(corpus_diff::report): Add proper spacing.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (corpus_diff::report): Emit
information about the number of added/removed/changed
functions. If the report is big, prefix any added
function with '[A]' deleted function with '[B]'. Also,
fix indentation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* include/abg-comparison.h (class distinct_diff): Declare new
type.
(compute_diff_for_distinct_kinds): Declare new function.
* src/abg-comparison.cc (distinct_diff::{distinct_diff, first,
second, entities_are_of_distinct_kinds, length, report}): Define
new member functions.
(compute_diff_for_distinct_kinds, try_to_diff_distinct_kinds):
Define new function.
(compute_diff_for_types, compute_diff_for_decls): Support diffing
entities of different kinds.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (class_decl::operator==(const decl_base& other)
const): Bail out early in case of recursive comparison, or if type
hashes are different. Do not try to compute qualified name unless
it's really necessary. The optimizations part of this change were
hinted by profiling.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_ir_node_from_die): For the
DW_TAG_subprogram case, if the function has a DW_AT_specification
attribute, build the IR node for the specification DIE instead.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
Assert that the result of build_function_decl on a member function
is a method_decl.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): If a member function
has an empty mangling name, use its pretty representation.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Do not assert that
the same member type cannot be deleted/inserted twice. It
actually can for, pointers, references, typedefs, etc.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-comparison.cc (represent): Remove extra new line after
reporting virtual function number.
(class_diff::report): Do not forget to emit a new line between two
inserted functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>