2013-07-16 19:58:43 +00:00
|
|
|
// -*- Mode: C++ -*-
|
|
|
|
//
|
2015-01-07 12:53:58 +00:00
|
|
|
// Copyright (C) 2013-2015 Red Hat, Inc.
|
2013-07-17 21:39:24 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
|
|
// free software; you can redistribute it and/or modify it under the
|
2013-07-16 19:58:43 +00:00
|
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
2013-07-17 21:39:24 +00:00
|
|
|
// later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2013-07-16 19:58:43 +00:00
|
|
|
// General Lesser Public License for more details.
|
2013-07-17 21:39:24 +00:00
|
|
|
|
2013-07-16 19:58:43 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; see the file COPYING-LGPLV3. If
|
|
|
|
// not, see <http://www.gnu.org/licenses/>.
|
2013-10-10 08:11:35 +00:00
|
|
|
//
|
|
|
|
// Author: Dodji Seketeli
|
2013-07-17 21:39:24 +00:00
|
|
|
|
2013-04-03 06:23:33 +00:00
|
|
|
/// @file
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
#ifndef __ABG_IR_H__
|
|
|
|
#define __ABG_IR_H__
|
2013-02-28 10:42:57 +00:00
|
|
|
|
2014-02-10 13:08:12 +00:00
|
|
|
#include <assert.h>
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
#include <tr1/unordered_map>
|
2013-08-27 11:21:26 +00:00
|
|
|
#include "abg-fwd.h"
|
2013-08-07 09:07:29 +00:00
|
|
|
#include "abg-hash.h"
|
2013-08-27 11:21:26 +00:00
|
|
|
#include "abg-traverse.h"
|
2013-08-02 03:16:22 +00:00
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
/// @file
|
|
|
|
///
|
|
|
|
/// This file contains the declarations of the Internal Representation
|
|
|
|
/// of libabigail.
|
|
|
|
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
/// @defgroup Memory Memory management
|
|
|
|
/// @{
|
|
|
|
///
|
|
|
|
/// How objects' lifetime is handled in libabigail.
|
|
|
|
///
|
|
|
|
/// For memory management and garbage collection of libabigail's IR
|
|
|
|
/// artifacts, we use std::tr1::shared_ptr and std::tr1::weak_ptr.
|
|
|
|
///
|
|
|
|
/// When manipulating these IR artifacts, there are a few rules to keep in
|
|
|
|
/// mind.
|
|
|
|
///
|
|
|
|
/// <b>The declaration for a type is owned by only one scope </b>
|
|
|
|
///
|
|
|
|
/// This means that for each instance of abigail::type_base (a type) there
|
|
|
|
/// is an instance of abigail::scope_decl that owns a @ref
|
|
|
|
/// abigail::decl_base_sptr (a shared pointer to an abigail::decl_base)
|
|
|
|
/// that points to the declaration of that type. The
|
|
|
|
/// abigail::type_base_sptr is added to the scope using the function
|
|
|
|
/// abigail::add_decl_to_scope().
|
|
|
|
///
|
|
|
|
/// There is a kind of type that is usually not syntactically owned by a
|
|
|
|
/// scope: it's function type. In libabigail function types are
|
|
|
|
/// represented by abigail::function_type and abigail::method_type. These
|
|
|
|
/// types must be owned by the translation unit they originate from.
|
|
|
|
/// Adding them to the translation unit must be done by a call to the
|
|
|
|
/// method function abigail::translation::get_canonical_function_type().
|
|
|
|
/// The type returned by that function is the one to use.
|
|
|
|
///
|
|
|
|
/// <b> A declaration that has a type does NOT own the type </b>
|
|
|
|
///
|
|
|
|
/// This means that, for instance, in an abigail::var_decl (a variable
|
|
|
|
/// declaration), the type of the declaration is not owned by the
|
|
|
|
/// declaration. In other (concrete) words, the variable declaration
|
|
|
|
/// doesn't have a shared pointer to the type. Rather, it has a *weak*
|
|
|
|
/// pointer to its type. That means that it has a data member of type
|
|
|
|
/// abigail::type_base_wptr that contains the type of the declaration.
|
|
|
|
///
|
|
|
|
/// But then abigail::var_decl::get_type() returns a shared pointer that
|
|
|
|
/// is constructed from the internal weak pointer to the type. That way,
|
|
|
|
/// users of the type of the var can own a temporary reference on it and
|
|
|
|
/// be assured that the type's life time is long enough for their need.
|
|
|
|
///
|
|
|
|
/// Likewise, data members, function and template parameters similarly
|
|
|
|
/// have weak pointers on their type.
|
|
|
|
///
|
|
|
|
/// @}
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
|
2013-02-28 10:42:57 +00:00
|
|
|
namespace abigail
|
|
|
|
{
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2014-10-11 09:27:59 +00:00
|
|
|
/// The namespace of the internal representation of ABI artifacts like
|
|
|
|
/// types and decls.
|
|
|
|
namespace ir
|
|
|
|
{
|
|
|
|
|
Build the set of exported decls directly during DWARF loading
Until now, after the ABI corpus was built from DWARF, the translation
units of the corpus were walked and each function was considered for
addition into the set of exported decls. During that walking, a first
version of the set was put into a std::list and then, a set of filters
(user-provided tunables like a list of regular expressions to keep or
remove some functions from the exported decls) is applied to that list
and the final set of exported decls is put in a std::vector.
Profiling has shown that this process of building the set of exported
decls is a hot spot and also that the current use of std::list was a
big memory consumer especially on binaries with large exported symbol
tables.
So this patch builds the set of exported decls "on the fly", during
DWARF reading, as opposed to waiting after the DWARF is read and
having to walk the corpus again. The corpus defines a policy object
that encapsulates the methods for determining if a function or
variable ought to be part of the set of exported decls. The DWARF
reader uses that policy object to determine which functions and
variables among those built during the reading ought be part of the
exported decls; the policy object also has a reference to the final
vector (managed by the corpus) that must hold the exported decls, so
the decls are put in that vector directly without unnecessary copying.
Profiling also showed that the string copying done by
{var_decl,function_decl}::get_id() was a hot spot. So the patch
returns a reference there.
With this patch applied, the peak memory consumption of abidiff on
libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of
resident and takes 2 minutes and 16s (on my slow system). Without the
patch the peak consumption was more than 300MB and it was taking
slightly longer.
For the test of bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory
consumtion and wall clock time spent is down from 3.4GB and 1m59s to
760MB and 0m43s.
* include/abg-ir.h ({var,function}_decl::get_id): Return a
reference.
* src/abg-ir.cc ({var,function}_decl::get_id): Return a reference
to the string rather than copying it over.
* include/abg-corpus.h (class corpus::exported_decls_builder):
Declare new type.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Declare new methods.
* src/abg-corpus.h (corpus::exported_decls_builder::priv): Define
new type.
(class symtab_build_visitor_type): Remove this type that is
useless now.
(corpus::exported_decls_builder::{exported_decls_builder,
exported_functions, exported_variables,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new functions.
(corpus::priv::is_public_decl_table_built): Remove this data
member. It's now useless.
(corpus::priv::priv): Adjust.
(corpus::priv::build_public_decl_table): Remove this member
function. It's now useless.
(corpus::{priv::build_unreferenced_symbols_tables, get_functions,
get_variables}): No need to build the public decls table here.
It's already built by the time the corpus is read from DWARF now.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Define new member functions.
* src/abg-dwarf-reader.cc (read_context::exported_decls_builder):
New data member.
(read_context::read_context): Initialize it.
(read_context::{exported_decls_builder,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new member functions.
(read_debug_info_into_corpus): Get the the new
'exported_decls_builder' object from the corpus and stick it into
the read context so the DWARF reading code can use it to build the
exported decls set. When the DWARF reading is done, sort the set
of exported functions and variables that was built.
(build_ir_node_from_die): When a function or variable is built,
consider putting it into the set of exported decls.
* tools/abicompat.cc (main): Now that the exported decls is built
*before* we had a chance to stick the list of symbol IDs to keep,
call corpus::maybe_drop_some_exported_decls() to update the set of
exported decls we should consider for the corpus.
was applied to that list and the final
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
|
|
|
// Inject some std::tr1 types in here.
|
|
|
|
using std::tr1::unordered_map;
|
|
|
|
|
2013-08-27 11:21:26 +00:00
|
|
|
/// @brief The source location of a token.
|
|
|
|
///
|
|
|
|
/// This represents the location of a token coming from a given
|
|
|
|
/// translation unit. This location is actually an abstraction of
|
|
|
|
/// cursor in the table of all the locations of all the tokens of the
|
2014-02-28 09:26:00 +00:00
|
|
|
/// translation unit. That table is managed by the @ref location_manager
|
|
|
|
/// type. To get the file path, line and column numbers associated to
|
|
|
|
/// a given instance of @ref location, you need to use the
|
|
|
|
/// location_manager::expand_location method.
|
2013-08-27 11:21:26 +00:00
|
|
|
class location
|
|
|
|
{
|
2013-09-26 14:45:00 +00:00
|
|
|
unsigned value_;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
2014-11-06 10:27:14 +00:00
|
|
|
location(unsigned v) : value_(v) {}
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-26 14:45:00 +00:00
|
|
|
location() : value_(0) { }
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
unsigned
|
|
|
|
get_value() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return value_;}
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
operator bool() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{ return !!value_; }
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const location other) const
|
2013-10-10 08:11:35 +00:00
|
|
|
{return value_ == other.value_;}
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
operator<(const location other) const
|
2013-09-26 14:45:00 +00:00
|
|
|
{ return value_ < other.value_; }
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
friend class location_manager;
|
2014-02-28 09:26:00 +00:00
|
|
|
}; // end class location
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
/// @brief The entry point to manage locations.
|
|
|
|
///
|
|
|
|
/// This type keeps a table of all the locations for tokens of a
|
|
|
|
/// given translation unit.
|
|
|
|
class location_manager
|
|
|
|
{
|
2014-01-17 07:34:30 +00:00
|
|
|
struct priv;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
/// Pimpl.
|
2014-01-17 07:34:30 +00:00
|
|
|
shared_ptr<priv> priv_;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
location_manager();
|
|
|
|
|
|
|
|
location
|
|
|
|
create_new_location(const std::string& fle, size_t lne, size_t col);
|
|
|
|
|
|
|
|
void
|
|
|
|
expand_location(const location location, std::string& path,
|
|
|
|
unsigned& line, unsigned& column) const;
|
|
|
|
};
|
|
|
|
|
2013-09-26 21:33:23 +00:00
|
|
|
struct ir_node_visitor;
|
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref
|
|
|
|
/// translation_unit type.
|
2013-10-10 14:58:30 +00:00
|
|
|
typedef shared_ptr<translation_unit> translation_unit_sptr;
|
2013-11-20 09:54:15 +00:00
|
|
|
|
|
|
|
/// Convenience typedef for a vector of @ref translation_unit_sptr.
|
2013-10-10 14:58:30 +00:00
|
|
|
typedef std::vector<translation_unit_sptr> translation_units;
|
|
|
|
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref type_base
|
|
|
|
typedef shared_ptr<type_base> type_base_sptr;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
/// Convenience typedef for a weak pointer on a @ref type_base
|
|
|
|
typedef weak_ptr<type_base> type_base_wptr;
|
|
|
|
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
/// Convenience typedef for a smart pointer on @ref decl_base.
|
|
|
|
typedef shared_ptr<decl_base> decl_base_sptr;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
class function_type;
|
|
|
|
|
|
|
|
class function_decl;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer on a @ref function_type
|
|
|
|
typedef shared_ptr<function_type> function_type_sptr;
|
|
|
|
|
Delay non-complete class type resolution up to end of corpus reading
From the DWARF emitted by GCC 4.4.7 for libstdc++ we encountered an
interesting construct.
A non-complete version of std::runtime_error is declared in
libstdc++-v3/src/functexcept.cc and is represented in DWARF as:
[ 37344] class_type
name (strp) "runtime_error"
declaration (flag)
Then a bit later, that *non-complete* class is used as a base class
for a class, *without* being fully defined! This shouldn't happen
but, well, it does:
[ 3b3a1] class_type
specification (ref4) [ 3733e]
byte_size (data1) 16
decl_file (data1) 5
decl_line (data1) 141
containing_type (ref4) [ 3734a]
sibling (ref4) [3b405]
[ 3b3b1] inheritance
type (ref4) [ 37344] <---- here.
The thing is that, later, in another translation unit
(libstdc++-v3/src/stdexcept.cc), that same class is defined fully:
[ 7e9f9] class_type
name (strp) "runtime_error"
declaration (flag)
[...]
[ 80c95] class_type
specification (ref4) [ 7e9f9]
byte_size (data1) 16
decl_file (data1) 4
decl_line (data1) 108
containing_type (ref4) [ 7e9ff]
sibling (ref4) [ 80d2b]
[...] <---------- and the definition goes here.
But then you see that the DIE offset of the "version" of the
runtime_error class that is "defined" libstdc++-v3/src/stdexcept.cc in
is different from the version that is only declared in
libstdc++-v3/src/functexcept.cc. But virtue of the "One Definition
Rule", we can assume that they designate the same type. But still,
runtime_error should have been defined in
libstdc++-v3/src/stdexcept.cc. Anyhow, libabigail needs to be able to
handle this. That is, it needs to wait until the entire ABI corpus is
loaded from DWARF, then lookup the definition of all the non-complete
types we have encountered.
And then only after that non-complete type resolution has taken place,
we can proceed with type canonicalizing, rather than doing it after
the loading of each translation unit like what we were doing
previously.
This is what this patch does.
* include/abg-fwd.h (lookup_type_in_corpus): Declare new function.
* src/abg-corpus.cc (lookup_type_in_corpus): Define new function
here.
* include/abg-ir.h (function_types_type): Declare new typedef.
(translation_unit::get_canonical_function_type): Remove member function.
(translation_unit::bind_function_type_life_time): Declare new
member function.
(classes_type): New typedef.
* src/abg-ir.cc
(translation_unit::priv::canonical_function_types_): Remove data
member.
(translation_unit::priv::function_types): New data member.
(translation_unit::get_canonical_function_type): Remove this
function definition.
(translation_unit::bind_function_type_life_time): New function
definition.
(lookup_node_in_scope): Ensure that the type returned is
complete.
* src/abg-dwarf-reader.cc (string_classes_map): New typedef.
(read_context::decl_only_classes_map_): New data member.
(read_context::declaration_only_classes): New accessor.
(read_context::{maybe_schedule_declaration_only_class_for_resolution,
is_decl_only_class_scheduled_for_resolution,
resolve_declaration_only_classes, current_elf_file_is_executable,
current_elf_file_is_dso}): Define new member functions.
(read_context::clear_per_translation_unit_data): Do not clear the
data structures that associate DIEs to decls/types or that contain
the types to canonicalize here. Rather, clear them ...
(read_context::clear_per_corpus_data): ... here instead.
(read_context::build_translation_unit_and_add_to_ir): Do not
perform late type canonicalizing here. Rather, do it ...
(read_debug_info_into_corpus): ... here instead. And before that,
call read_context::clear_per_corpus_data() and the new
read_context::resolve_declaration_only_classes() here.
(build_class_type_and_add_to_ir): Schedule the non-complete types
for resolution to complete types. Assert that base classes that
are non-complete are scheduled to be completed.
(build_function_decl): Do not try to canonicalize function types
this early, systematically. Now, all the non-complete types needs
to be completed before starting canonicalizing. So let function
types go through the normal processes of deciding when to
canonicalize them. But then, bind the life time of the function
type to the life time of the current translation unit.
(maybe_canonicalize_type): If a class type is non-complete,
schedule it for late canonicalizing.
* src/abg-hash.cc (class_decl::hash::operator()(const class_decl&)
const): During hashing, a base class should be complete.
* src/abg-reader.cc
(read_context::clear_per_translation_unit_data): Do not clear
id/xml node, and type maps here. Rather, clear it ...
(read_context::clear_per_corpus_data): ... here instead.
(read_translation_unit_from_input): Do not perform late
canonicalizing here. Rather, do it ...
(read_corpus_from_input): ... here. Also, call the new
read_context::clear_per_corpus_data() here.
(build_function_decl): Do not canonicalize function types here so
early. Rather, bind the life time of the function type to the
life time of the translation unit.
* src/abg-writer.cc (write_translation_unit): Do not clear the
type/ID map here.
* tests/data/test-read-dwarf/test2.so.abi: Adjust test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-17 09:54:12 +00:00
|
|
|
/// Convenience typedef fo a vector of @ref function_type_sptr
|
|
|
|
typedef vector<function_type_sptr> function_types_type;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
/// Convenience typedef for a weak pointer on a @ref function_type
|
|
|
|
typedef weak_ptr<function_type> function_type_wptr;
|
|
|
|
|
2013-12-23 12:25:32 +00:00
|
|
|
struct ir_traversable_base;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to @ref
|
|
|
|
/// ir_traversable_base.
|
|
|
|
typedef shared_ptr<ir_traversable_base> ir_traversable_base_sptr;
|
|
|
|
|
|
|
|
/// The base of an entity of the intermediate representation that is
|
|
|
|
/// to be traversed.
|
|
|
|
struct ir_traversable_base : public traversable_base
|
|
|
|
{
|
2014-03-19 10:01:58 +00:00
|
|
|
/// Traverse a given IR node and its children, calling an visitor on
|
|
|
|
/// each node.
|
|
|
|
///
|
|
|
|
/// @param v the visitor to call on each traversed node.
|
|
|
|
///
|
|
|
|
/// @return true if the all the IR node tree was traversed.
|
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor& v);
|
2013-12-23 12:25:32 +00:00
|
|
|
}; // end class ir_traversable_base
|
|
|
|
|
2013-08-27 11:21:26 +00:00
|
|
|
/// This is the abstraction of the set of relevant artefacts (types,
|
|
|
|
/// variable declarations, functions, templates, etc) bundled together
|
|
|
|
/// into a translation unit.
|
|
|
|
class translation_unit : public traversable_base
|
|
|
|
{
|
2013-12-07 07:07:54 +00:00
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
2013-12-07 07:07:54 +00:00
|
|
|
priv_sptr priv_;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
// Forbidden
|
|
|
|
translation_unit();
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
|
2013-08-27 11:21:26 +00:00
|
|
|
public:
|
2013-12-07 07:07:54 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref global_scope.
|
|
|
|
typedef shared_ptr<global_scope> global_scope_sptr;
|
2013-08-27 11:21:26 +00:00
|
|
|
|
On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language,
when the name of the function is different from its linkage name, even
when the function symbol has no aliases, show the symbol information
of the function.
* include/abg-ir.h (translation_unit::language): New enum type.
(translation_unit::{get_language, set_language}): Declare new
accessors.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Declare new functions.
* src/abg-ir.cc (translation_unit::priv::language_): New data
member.
(translation_unit::priv::language_): Initialize it.
(translation_unit::{set_language, get_language}): Define new
member functions.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Define new functions.
* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New
static function.
(build_translation_unit_and_add_to_ir): Read the language of the
translation unit.
* src/abg-comparison.cc (corpus_diff::report): When reporting a
change in a function sub-type, if we are in C language translation
unit, if the function name is different from its linkage name,
even if the symbol doesn't have any alias, show symbol
information.
* src/abg-reader.cc (read_translation_unit_from_input): Read the
'language' property of the translation unit, if present.
* src/abg-writer.cc (write_translation_unit): Write the 'language'
property to the translation unit, if present.
* tests/data/test-read-dwarf/test0.abi: Adjust for the new
'language' property of the 'abi-instr' element.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test4.so.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test6.so.abi: Likewise.
* tests/data/test-read-dwarf/test7.so.abi: Likewise.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 12:55:24 +00:00
|
|
|
/// The language of the translation unit.
|
|
|
|
enum language
|
|
|
|
{
|
|
|
|
LANG_UNKNOWN = 0,
|
|
|
|
LANG_Cobol74,
|
|
|
|
LANG_Cobol85,
|
|
|
|
LANG_C89,
|
|
|
|
LANG_C99,
|
|
|
|
LANG_C11,
|
|
|
|
LANG_C,
|
|
|
|
LANG_C_plus_plus_11,
|
|
|
|
LANG_C_plus_plus_14,
|
|
|
|
LANG_C_plus_plus,
|
|
|
|
LANG_ObjC,
|
|
|
|
LANG_ObjC_plus_plus,
|
|
|
|
LANG_Fortran77,
|
|
|
|
LANG_Fortran90,
|
|
|
|
LANG_Fortran95,
|
|
|
|
LANG_Ada83,
|
|
|
|
LANG_Ada95,
|
|
|
|
LANG_Pascal83,
|
|
|
|
LANG_Modula2,
|
|
|
|
LANG_Java,
|
|
|
|
LANG_PL1,
|
|
|
|
LANG_UPC,
|
|
|
|
LANG_D,
|
|
|
|
LANG_Python,
|
|
|
|
LANG_Go,
|
|
|
|
LANG_Mips_Assembler
|
|
|
|
};
|
|
|
|
|
2013-12-07 07:07:54 +00:00
|
|
|
public:
|
2013-12-11 11:23:54 +00:00
|
|
|
translation_unit(const std::string& path,
|
|
|
|
char address_size = 0);
|
2013-08-27 11:21:26 +00:00
|
|
|
|
|
|
|
virtual ~translation_unit();
|
|
|
|
|
On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language,
when the name of the function is different from its linkage name, even
when the function symbol has no aliases, show the symbol information
of the function.
* include/abg-ir.h (translation_unit::language): New enum type.
(translation_unit::{get_language, set_language}): Declare new
accessors.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Declare new functions.
* src/abg-ir.cc (translation_unit::priv::language_): New data
member.
(translation_unit::priv::language_): Initialize it.
(translation_unit::{set_language, get_language}): Define new
member functions.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Define new functions.
* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New
static function.
(build_translation_unit_and_add_to_ir): Read the language of the
translation unit.
* src/abg-comparison.cc (corpus_diff::report): When reporting a
change in a function sub-type, if we are in C language translation
unit, if the function name is different from its linkage name,
even if the symbol doesn't have any alias, show symbol
information.
* src/abg-reader.cc (read_translation_unit_from_input): Read the
'language' property of the translation unit, if present.
* src/abg-writer.cc (write_translation_unit): Write the 'language'
property to the translation unit, if present.
* tests/data/test-read-dwarf/test0.abi: Adjust for the new
'language' property of the 'abi-instr' element.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test4.so.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test6.so.abi: Likewise.
* tests/data/test-read-dwarf/test7.so.abi: Likewise.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 12:55:24 +00:00
|
|
|
language
|
|
|
|
get_language() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_language(language l);
|
|
|
|
|
2013-08-27 11:21:26 +00:00
|
|
|
const std::string&
|
|
|
|
get_path() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_path(const string&);
|
|
|
|
|
|
|
|
const global_scope_sptr
|
|
|
|
get_global_scope() const;
|
|
|
|
|
|
|
|
location_manager&
|
|
|
|
get_loc_mgr();
|
|
|
|
|
|
|
|
const location_manager&
|
|
|
|
get_loc_mgr() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_empty() const;
|
|
|
|
|
2013-12-11 11:23:54 +00:00
|
|
|
char
|
|
|
|
get_address_size() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_address_size(char);
|
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
bool
|
|
|
|
is_constructed() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_is_constructed(bool);
|
|
|
|
|
Initial support for diffing ABI corpus files
* 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>
2013-12-23 13:05:19 +00:00
|
|
|
bool
|
|
|
|
operator==(const translation_unit&) const;
|
|
|
|
|
Delay non-complete class type resolution up to end of corpus reading
From the DWARF emitted by GCC 4.4.7 for libstdc++ we encountered an
interesting construct.
A non-complete version of std::runtime_error is declared in
libstdc++-v3/src/functexcept.cc and is represented in DWARF as:
[ 37344] class_type
name (strp) "runtime_error"
declaration (flag)
Then a bit later, that *non-complete* class is used as a base class
for a class, *without* being fully defined! This shouldn't happen
but, well, it does:
[ 3b3a1] class_type
specification (ref4) [ 3733e]
byte_size (data1) 16
decl_file (data1) 5
decl_line (data1) 141
containing_type (ref4) [ 3734a]
sibling (ref4) [3b405]
[ 3b3b1] inheritance
type (ref4) [ 37344] <---- here.
The thing is that, later, in another translation unit
(libstdc++-v3/src/stdexcept.cc), that same class is defined fully:
[ 7e9f9] class_type
name (strp) "runtime_error"
declaration (flag)
[...]
[ 80c95] class_type
specification (ref4) [ 7e9f9]
byte_size (data1) 16
decl_file (data1) 4
decl_line (data1) 108
containing_type (ref4) [ 7e9ff]
sibling (ref4) [ 80d2b]
[...] <---------- and the definition goes here.
But then you see that the DIE offset of the "version" of the
runtime_error class that is "defined" libstdc++-v3/src/stdexcept.cc in
is different from the version that is only declared in
libstdc++-v3/src/functexcept.cc. But virtue of the "One Definition
Rule", we can assume that they designate the same type. But still,
runtime_error should have been defined in
libstdc++-v3/src/stdexcept.cc. Anyhow, libabigail needs to be able to
handle this. That is, it needs to wait until the entire ABI corpus is
loaded from DWARF, then lookup the definition of all the non-complete
types we have encountered.
And then only after that non-complete type resolution has taken place,
we can proceed with type canonicalizing, rather than doing it after
the loading of each translation unit like what we were doing
previously.
This is what this patch does.
* include/abg-fwd.h (lookup_type_in_corpus): Declare new function.
* src/abg-corpus.cc (lookup_type_in_corpus): Define new function
here.
* include/abg-ir.h (function_types_type): Declare new typedef.
(translation_unit::get_canonical_function_type): Remove member function.
(translation_unit::bind_function_type_life_time): Declare new
member function.
(classes_type): New typedef.
* src/abg-ir.cc
(translation_unit::priv::canonical_function_types_): Remove data
member.
(translation_unit::priv::function_types): New data member.
(translation_unit::get_canonical_function_type): Remove this
function definition.
(translation_unit::bind_function_type_life_time): New function
definition.
(lookup_node_in_scope): Ensure that the type returned is
complete.
* src/abg-dwarf-reader.cc (string_classes_map): New typedef.
(read_context::decl_only_classes_map_): New data member.
(read_context::declaration_only_classes): New accessor.
(read_context::{maybe_schedule_declaration_only_class_for_resolution,
is_decl_only_class_scheduled_for_resolution,
resolve_declaration_only_classes, current_elf_file_is_executable,
current_elf_file_is_dso}): Define new member functions.
(read_context::clear_per_translation_unit_data): Do not clear the
data structures that associate DIEs to decls/types or that contain
the types to canonicalize here. Rather, clear them ...
(read_context::clear_per_corpus_data): ... here instead.
(read_context::build_translation_unit_and_add_to_ir): Do not
perform late type canonicalizing here. Rather, do it ...
(read_debug_info_into_corpus): ... here instead. And before that,
call read_context::clear_per_corpus_data() and the new
read_context::resolve_declaration_only_classes() here.
(build_class_type_and_add_to_ir): Schedule the non-complete types
for resolution to complete types. Assert that base classes that
are non-complete are scheduled to be completed.
(build_function_decl): Do not try to canonicalize function types
this early, systematically. Now, all the non-complete types needs
to be completed before starting canonicalizing. So let function
types go through the normal processes of deciding when to
canonicalize them. But then, bind the life time of the function
type to the life time of the current translation unit.
(maybe_canonicalize_type): If a class type is non-complete,
schedule it for late canonicalizing.
* src/abg-hash.cc (class_decl::hash::operator()(const class_decl&)
const): During hashing, a base class should be complete.
* src/abg-reader.cc
(read_context::clear_per_translation_unit_data): Do not clear
id/xml node, and type maps here. Rather, clear it ...
(read_context::clear_per_corpus_data): ... here instead.
(read_translation_unit_from_input): Do not perform late
canonicalizing here. Rather, do it ...
(read_corpus_from_input): ... here. Also, call the new
read_context::clear_per_corpus_data() here.
(build_function_decl): Do not canonicalize function types here so
early. Rather, bind the life time of the function type to the
life time of the translation unit.
* src/abg-writer.cc (write_translation_unit): Do not clear the
type/ID map here.
* tests/data/test-read-dwarf/test2.so.abi: Adjust test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-17 09:54:12 +00:00
|
|
|
void
|
|
|
|
bind_function_type_life_time(function_type_sptr) const;
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-27 11:21:26 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
|
|
|
|
friend function_type_sptr
|
|
|
|
lookup_function_type_in_translation_unit(const function_type& t,
|
|
|
|
const translation_unit& tu);
|
2015-07-20 14:14:01 +00:00
|
|
|
|
|
|
|
friend function_type_sptr
|
|
|
|
synthesize_function_type_from_translation_unit(const function_type& fn_type,
|
|
|
|
translation_unit& tu);
|
|
|
|
|
|
|
|
friend type_base_sptr
|
|
|
|
synthesize_type_from_translation_unit(const type_base_sptr& type,
|
|
|
|
translation_unit& tu);
|
2013-08-27 11:21:26 +00:00
|
|
|
};//end class translation_unit
|
|
|
|
|
On changed fn, show symbol info when name is different from linkage name in C
In change reports for function sub-type changes, for the C language,
when the name of the function is different from its linkage name, even
when the function symbol has no aliases, show the symbol information
of the function.
* include/abg-ir.h (translation_unit::language): New enum type.
(translation_unit::{get_language, set_language}): Declare new
accessors.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Declare new functions.
* src/abg-ir.cc (translation_unit::priv::language_): New data
member.
(translation_unit::priv::language_): Initialize it.
(translation_unit::{set_language, get_language}): Define new
member functions.
(translation_unit_language_to_string)
(string_to_translation_unit_language, is_c_language)
(is_cplus_plus_language): Define new functions.
* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): New
static function.
(build_translation_unit_and_add_to_ir): Read the language of the
translation unit.
* src/abg-comparison.cc (corpus_diff::report): When reporting a
change in a function sub-type, if we are in C language translation
unit, if the function name is different from its linkage name,
even if the symbol doesn't have any alias, show symbol
information.
* src/abg-reader.cc (read_translation_unit_from_input): Read the
'language' property of the translation unit, if present.
* src/abg-writer.cc (write_translation_unit): Write the 'language'
property to the translation unit, if present.
* tests/data/test-read-dwarf/test0.abi: Adjust for the new
'language' property of the 'abi-instr' element.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test4.so.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test6.so.abi: Likewise.
* tests/data/test-read-dwarf/test7.so.abi: Likewise.
* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-07-19 12:55:24 +00:00
|
|
|
string
|
|
|
|
translation_unit_language_to_string(translation_unit::language);
|
|
|
|
|
|
|
|
translation_unit::language
|
|
|
|
string_to_translation_unit_language(const string&);
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_c_language(translation_unit::language l);
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_cplus_plus_language(translation_unit::language l);
|
|
|
|
|
Initial support for diffing ABI corpus files
* 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>
2013-12-23 13:05:19 +00:00
|
|
|
bool
|
|
|
|
operator==(translation_unit_sptr, translation_unit_sptr);
|
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
/// Access specifier for class members.
|
|
|
|
enum access_specifier
|
|
|
|
{
|
|
|
|
no_access,
|
|
|
|
public_access,
|
|
|
|
protected_access,
|
|
|
|
private_access,
|
|
|
|
};
|
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
class elf_symbol;
|
|
|
|
/// A convenience typedef for a shared pointer to elf_symbol.
|
|
|
|
typedef shared_ptr<elf_symbol> elf_symbol_sptr;
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
/// A convenience typedef for a weak pointer to elf_symbol.
|
|
|
|
typedef weak_ptr<elf_symbol> elf_symbol_wptr;
|
|
|
|
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
/// Convenience typedef for a map which key is a string and which
|
|
|
|
/// value if the elf symbol of the same name.
|
|
|
|
typedef std::tr1::unordered_map<string, elf_symbol_sptr>
|
|
|
|
string_elf_symbol_sptr_map_type;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to an
|
|
|
|
/// string_elf_symbol_sptr_map_type.
|
|
|
|
typedef shared_ptr<string_elf_symbol_sptr_map_type>
|
|
|
|
string_elf_symbol_sptr_map_sptr;
|
|
|
|
|
|
|
|
/// Convenience typedef for a vector of elf_symbol
|
|
|
|
typedef std::vector<elf_symbol_sptr> elf_symbols;
|
|
|
|
|
|
|
|
/// Convenience typedef for a map which key is a string and which
|
|
|
|
/// value is a vector of elf_symbol.
|
|
|
|
typedef std::tr1::unordered_map<string, elf_symbols>
|
|
|
|
string_elf_symbols_map_type;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to
|
|
|
|
/// string_elf_symbols_map_type.
|
|
|
|
typedef shared_ptr<string_elf_symbols_map_type> string_elf_symbols_map_sptr;
|
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
/// Abstraction of an elf symbol.
|
|
|
|
///
|
|
|
|
/// This is useful when a given corpus has been read from an ELF file.
|
|
|
|
/// In that case, a given decl might be associated to its underlying
|
|
|
|
/// ELF symbol, if that decl is publicly exported in the ELF file. In
|
|
|
|
/// that case, comparing decls might involve comparing their
|
|
|
|
/// underlying symbols as well.
|
|
|
|
class elf_symbol
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// The type of a symbol.
|
|
|
|
enum type
|
|
|
|
{
|
|
|
|
NOTYPE_TYPE = 0,
|
|
|
|
OBJECT_TYPE,
|
|
|
|
FUNC_TYPE,
|
|
|
|
SECTION_TYPE,
|
|
|
|
FILE_TYPE,
|
|
|
|
COMMON_TYPE,
|
|
|
|
TLS_TYPE,
|
|
|
|
GNU_IFUNC_TYPE
|
|
|
|
};
|
|
|
|
|
|
|
|
/// The binding of a symbol.
|
|
|
|
enum binding
|
|
|
|
{
|
|
|
|
LOCAL_BINDING = 0,
|
|
|
|
GLOBAL_BINDING,
|
|
|
|
WEAK_BINDING,
|
|
|
|
GNU_UNIQUE_BINDING
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Inject the elf_symbol::version here.
|
|
|
|
class version;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct priv;
|
|
|
|
shared_ptr<priv> priv_;
|
|
|
|
|
|
|
|
elf_symbol();
|
|
|
|
|
|
|
|
elf_symbol(size_t i,
|
|
|
|
const string& n,
|
|
|
|
type t,
|
|
|
|
binding b,
|
|
|
|
bool d,
|
|
|
|
const version& v);
|
|
|
|
|
|
|
|
elf_symbol(const elf_symbol&);
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
elf_symbol&
|
|
|
|
operator=(const elf_symbol& s);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static elf_symbol_sptr
|
|
|
|
create();
|
|
|
|
|
|
|
|
static elf_symbol_sptr
|
|
|
|
create(size_t i,
|
|
|
|
const string& n,
|
|
|
|
type t,
|
|
|
|
binding b,
|
|
|
|
bool d,
|
|
|
|
const version& v);
|
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
size_t
|
|
|
|
get_index() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_index(size_t);
|
|
|
|
|
|
|
|
const string&
|
|
|
|
get_name() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_name(const string& n);
|
|
|
|
|
|
|
|
type
|
|
|
|
get_type() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_type(type t);
|
|
|
|
|
|
|
|
binding
|
|
|
|
get_binding() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_binding(binding b);
|
|
|
|
|
|
|
|
version&
|
|
|
|
get_version() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_version(const version& v);
|
|
|
|
|
|
|
|
bool
|
2014-11-30 09:51:01 +00:00
|
|
|
is_defined() const;
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
|
|
|
|
void
|
2014-11-30 09:51:01 +00:00
|
|
|
is_defined(bool d);
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
is_public() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_function() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_variable() const;
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
const elf_symbol_sptr
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
get_main_symbol() const;
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
elf_symbol_sptr
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
get_main_symbol();
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_main_symbol() const;
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
elf_symbol_sptr
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
get_next_alias() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
has_aliases() const;
|
|
|
|
|
2015-07-02 10:57:04 +00:00
|
|
|
int
|
|
|
|
get_number_of_aliases() const;
|
|
|
|
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
void
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
add_alias(elf_symbol_sptr);
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
|
|
|
|
const string&
|
|
|
|
get_id_string() const;
|
|
|
|
|
2015-06-04 09:51:27 +00:00
|
|
|
elf_symbol_sptr
|
|
|
|
get_alias_from_name(const string& name) const;
|
|
|
|
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
elf_symbol_sptr
|
|
|
|
get_alias_which_equals(const elf_symbol& other) const;
|
|
|
|
|
2014-09-16 12:53:30 +00:00
|
|
|
string
|
Support comparing symbols not referenced by debug info
* doc/manuals/abidiff.rst: Adjust intro to mention that w/o debug
info, abidiff now works but just report about added/removed
symbols. Add documentation about the new
--no-unreferenced-symbols option.
* include/abg-comparison.h (string_elf_symbol_map): New typedef.
(diff_context::show_symbols_unreferenced_by_debug_info): Declare
new accessors.
* src/abg-comparison.cc
(diff_context::priv::show_syms_unreferenced_by_di_): New data
member.
(diff_context::priv::priv): Adjust.
(diff_context::show_symbols_unreferenced_by_debug_info): Implement
these accessors.
(corpus_diff::priv::{unrefed_fn_syms_edit_script_,
unrefed_var_syms_edit_script_, added_unrefed_fn_syms_,
deleted_unrefed_fn_syms_, added_unrefed_var_syms_,
deleted_unrefed_var_syms_}): New data members.
(corpus_diff::priv::diff_stats::{num_func_syms_removed,
num_func_syms_added, num_var_syms_removed, num_var_syms_added}):
New data members.
(corpus_diff::priv::diff_stats::diff_stats): Adjust.
(corpus_diff::ensure_lookup_tables_populated): Populate lookup
tables for added/removed symbols that are not referenced by any
debug info.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Compute
stats for the added/removed symbols not referenced by any debug
info.
(corpus_diff::priv::emit_diff_stats): Emit stats about
added/removed symbols that are not referenced by any debug info.
(corpus_diff::length): Adjust to take in account added/removed
symbols not referenced by any debug info.
(show_linkage_name_and_aliases): New static function.
(corpus_diff::report): When emitting a symbol name, emit its
version too, and tell if it aliases other symbols. Avoid emitted
extra new lines. Report added/removed symbols not referenced by
any debug info.
(compute_diff): In the overload for corpus_sptr, compute the diffs
for symbols not referenced by debug info.
* include/abg-corpus.h
(corpus::get_unreferenced_{function,variable}_symbols): Declare
new member functions.
* src/abg-corpus.cc (corpus_priv::{unrefed_fun_symbols,
unrefed_var_symbols}): New data members.
(corpus_priv::build_unreferenced_symbols_tables): Define new
member function.
(struct comp_elf_symbols_functor): New functor.
(corpus::is_empty): Adjust to take in account added/removed
symbols not referenced by debug info.
(corpus::{get_unreferenced_function_symbols,
corpus::get_unreferenced_variable_symbols}): Define these
accessors.
* include/abg-dwarf-reader.h (enum status): Transform this into
bitfields. Add a STATUS_UNKNOWN value that has the value 0.
(operator|(status, status), operator&(status, status))
(operator|=(status&, status), operator&=(status, status)): New
bit-wise operators to manipulate instances of the status bit-field.
* src/abg-dwarf-reader.cc (get_version_for_symbol): Fix this to
avoid returning garbage version sometimes.
(read_debug_info_into_corpus): Fix this to return a non-null but
empty corpus_sptr when there is no debug info available.
(operator|(status, status), operator&(status, status))
(operator|=(status&, status), operator&=(status, status)): Define
these new bitwise operators to manipulate instances of the status
bit-field.
(read_corpus_from_elf): Now that the abigail::dwarf_reader::status
is a bit-field, set it to reflect if debug info and/or symbol
tables have been found. Do not bail out if debug info hasn't been
found. Rather, keep going, and go look for symbols-only; this is
a kind of operating in degraded mode.
* include/abg-ir.h (elf_symbol::get_aliases_id_string): Add a flag
that says if the current instance of elf_symbol should be included
in the list of aliases or not.
* src/abg-ir.cc (elf_symbol::get_aliases_id_string): Define it.
* tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.o: New test
input.
* tools/abidiff.cc
(options::show_symbols_not_referenced_by_debug_info): New data
member.
(options:options): Adjust.
(display_usage): Add an info string for the new
--no-unreferenced-symbols command line option.
(parse_command_line): Parse the new --no-unreferenced-symbols
command line.
(set_diff_context_from_opts): Set the diff_context according to
the presence of --no-unreferenced-symbols.
(main): Adjust for the fact that abigail::dwarf_reader::status is
now a bit-field.
* tools/abilint.cc (main): Adjust for the fact that
abigail::dwarf_reader::status is now a bit-field..
():
* tests/data/test-diff-dwarf/test16-syms-only-report.txt: New test
reference output.
* tests/data/test-diff-dwarf/test16-syms-only-v{0,1}.cc: Source code
for new test input.
* tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.o: New
test input.
* tests/data/test-diff-dwarf/test17-non-refed-syms-v{0,1}.cc: New
source code for test input.
* tests/data/test-diff-dwarf/libtest18-alias-sym-v{0,1}.so: New
test input.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt:
Reference output for new test input.
* tests/data/test-diff-dwarf/test18-alias-sym-v{0,1}.cc: Source
code for new test input.
* tests/data/test-diff-dwarf/test18-alias-sym-version-script:
Source code for new test input.
* tests/Makefile.am: Add the new test materials to the source
distribution.
* tests/test-diff-dwarf.cc(in_out_specs): Add the new input tests
above to the array of tests to run by this harness.
(main): Emit empty reports for empty resulting diffs.
* tests/data/test-diff-dwarf/test{0,8,9,12,14-inline-report,}-report.txt:
Adjust.
* tests/data/test-diff-filter/test{0,01,2,4,5,7,8,9,10,12,13,15-0,15-1}-report.txt:
Likewise.
* tests/data/test-diff-filter/test{19-enum,20-inline,}-report-0.txt:
Likewise.
* tests/data/test-diff-suppr/test0-type-suppr-report-{1,2}.txt:
Likewise.
* tests/data/test-diff-suppr/test{1,2}-typedef-suppr-report-1.txt:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-22 16:05:31 +00:00
|
|
|
get_aliases_id_string(const string_elf_symbols_map_type& symtab,
|
|
|
|
bool include_symbol_itself = true) const;
|
2014-09-16 12:53:30 +00:00
|
|
|
|
2015-07-01 09:03:16 +00:00
|
|
|
string
|
|
|
|
get_aliases_id_string(bool include_symbol_itself = true) const;
|
|
|
|
|
Add a symbol database to the ABI Corpus & support symbol aliases
* include/abg-corpus.h (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Declare new accessors.
(corpus::lookup_{variable,function}_symbol): Declare new member
functions.
* src/abg-corpus.cc (corpus::{g,s}et_{fun,var}_symbol_map{_sptr}):
Define new accessors.
(corpus::lookup_{variable,function}_symbol): Define new member
functions.
* include/abg-ir.h (string_elf_symbol_sptr_map_type)
(string_elf_symbol_sptr_map_sptr, elf_symbols)
(string_elf_symbols_map_type, string_elf_symbols_map_sptr): New
convenience typedefs.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Declare new member
functions.
* src/abg-ir.cc (elf_symbol::{get_main_symbol, is_main_symbol,
get_next_alias, has_aliases, add_alias, get_id_string,
get_name_and_version_from_id, operator=}): Define new member
functions.
* include/abg-reader.h (read_corpus_from_file): Take a shared
pointer to corpus.
* src/abg-reader.cc (read_context::{g,s}et_corpus): Define these.
(build_elf_symbol_db, build_elf_symbol_from_reference)
(read_symbol_db_from_input): Define new functions.
(read_corpus_from_input): Adjust. Make it read symbol databases.
(build_elf_symbol): Harden this.
(build_{var,function}_decl): Read the symbol reference. Do not
read the local symbol serialization anymore.
(read_corpus_from_archive): Adjust.
(read_corpus_from_file): Take a reference to a shared pointer to
corpus, rather than a reference to the corpus.
(read_corpus_from_native_xml): Only keep the overload that returns
a corpus. Set the current context with the corpus.
* src/abg-dwarf-reader.cc (addr_elf_symbol_sptr_map_type)
(addr_elf_symbol_sptr_map_sptr): New convenience typedefs.
(read_context::{fun_sym_addr_sym_index_map_,
var_sym_addr_sym_index_map_): Remove.
(read_context::{fun,var}_addr_sym_map_): New. Replace the above
that got removed.
(read_context::{var,fun}_syms_): New.
(read_context::lookup_elf_{fn,var}_symbol_from_address): Adjust.
(read_context::{fun,var}_addr_sym_map{_sptr}): New.
(read_context::{fun,var}_syms{_sptr}): New.
(read_context::load_symbol_maps): Replace
read_context::load_symbol_addr_to_index_maps. Adjust to load all
the new maps.
(read_context::maybe_load_symbol_maps): New.
(read_debug_info_into_corpus): Renamed build_corpus into this.
Update to load symbol maps and set it to the corpus.
* src/abg-writer.cc (write_context::get_fun_symbol_map): New
accessor.
(write_elf_symbol_aliases, write_elf_symbol_reference)
(write_elf_symbols_table): Define new static functions.
(write_var_decl): Write the reference to the underlying symbol of
the variable. Do not write the full symbol here anymore.
(write_function_decl): Likewise, write the reference to the
underlying symbol of the function. Do not write the full symbol
here anymore.
(write_corpus_to_native_xml): Write the symbol databases at the
beginning of the corpus document.
* src/abg-comparison.cc
(corpus_diff::priv::ensure_lookup_tables_populated): Now that the
corpus has symbols, check if a the symbol of an allegedly deleted
function (resp. variable) is deleted; if not, then do not report
the function (resp. variable) as deleted. Similarly, check if the
symbol of an allegedly added function (resp. variable) is added.
if not, the do not report the function (resp. variable) as added.
* tests/test-write-read-archive.cc (main): Adjust.
* tools/biar.cc (extract_tus_from_archive): Likewise.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-28 14:33:35 +00:00
|
|
|
static bool
|
|
|
|
get_name_and_version_from_id(const string& id,
|
|
|
|
string& name,
|
|
|
|
string& ver);
|
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
bool
|
2014-09-16 09:21:47 +00:00
|
|
|
operator==(const elf_symbol&) const;
|
2014-09-16 12:53:30 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
does_alias(const elf_symbol&) const;
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
}; // end class elf_symbol.
|
|
|
|
|
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream& o, elf_symbol::type t);
|
|
|
|
|
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream& o, elf_symbol::binding t);
|
|
|
|
|
2014-05-14 09:03:42 +00:00
|
|
|
bool
|
|
|
|
string_to_elf_symbol_type(const string&, elf_symbol::type&);
|
|
|
|
|
|
|
|
bool
|
|
|
|
string_to_elf_symbol_binding(const string&, elf_symbol::binding&);
|
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
bool
|
|
|
|
operator==(const elf_symbol_sptr lhs, const elf_symbol_sptr rhs);
|
|
|
|
|
2014-09-16 12:53:30 +00:00
|
|
|
bool
|
|
|
|
elf_symbols_alias(const elf_symbol& s1, const elf_symbol& s2);
|
|
|
|
|
|
|
|
void
|
|
|
|
compute_aliases_for_elf_symbol(const elf_symbol& symbol,
|
|
|
|
const string_elf_symbols_map_type& symtab,
|
Fix symbols comparison
While working on something else, I noticed that the code for handling
copying symbols (and their aliases) was broken, and so comparing two
symbols which main name were different by which had aliases that were
equal was wrongly resulting in the two symbol being different. I think
we shouldn't actually copy symbols and their aliases. Once a symbol
is allocated, interested code should just manipulate that symbol by
address rather than by value an thus do away with the copying.
The patch does that, essentially. In the implementation of a symbol,
the aliases as well as the main symbol are now weak pointers, rather
than naked pointers. Numerous API entry points that were taking
containers of elf_symbol (and were copying elf_symbols over) are not
taking containers of smart pointers to elf_symbol. Copying of
instances of elf_symbol is now thus disabled.
As a result many tests that were exercising elf_symbols (with alias)
comparison have been updated.
As a result, many empty sub-result of PR libabigail/PR17948 are now
fixed.
* include/abg-ir.h (elf_symbol_wptr): New typedef.
(elf_symbol): Make the constructors and assignment operator
private. The type can neither be copied nor created with the new
operator.
(elf_symbol::create): New static member function.
(elf_symbol::{get_main_symbol, get_next_alias, add_alias}):
Adjust.
( compute_aliases_for_elf_symbol): Likewise.
(elf_symbol::operator=): Make this private.
(elf_symbol::get_alias_which_equals): Declare new member function.
* src/abg-comp-filter.cc (function_name_changed_but_not_symbol):
Adjust.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated): Adjust.
* src/abg-corpus.cc
(corpus::priv::build_unreferenced_symbols_tables): Likewise.
* include/abg-dwarf-reader.h (lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf): Adjust.
* src/abg-dwarf-reader.cc (lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, lookup_symbol_from_elf)
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(read_context::lookup_elf_symbol_from_index): Likewise.
(read_context::lookup_elf_fn_symbol_from_address): Likewise.
(read_context::lookup_elf_var_symbol_from_address): Likewise.
(read_context::lookup_public_function_symbol_from_elf): Likewise.
(read_context::lookup_public_variable_symbol_from_elf): Likewise.
(read_context::load_symbol_maps): Likewise.
(build_var_decl, build_function_decl): Likewise.
* src/abg-ir.cc (elf_symbol::priv::{main_symbol_, next_alias_}):
Change the type of these from elf_symbol* to elf_symbol_wptr.
(elf_symbol::priv::priv): Adjust.
(elf_symbol::{create, get_alias_which_equals}): Define new functions.
(textually_equals): Likewise.
(elf_symbol::{get_main_symbol, is_main_symbol, get_next_alias,
add_alias}): Adjust to return or take elf_symbol_sptr type, rather
than a elf_symbol* one.
(elf_symbol::{get_aliases_id_string, does_alias}): Adjust.
(compute_alias_for_elf_symbol): Likewise.
(elf_symbol::operator==): Two symbols A and B are now equal if A
has at least one alias that is textually equal to B.
(equals): In the overload for function_decls, in the part where we
compare the decl_base part of the functions without considering
their decl names, we now also omit considering their linkage
names, because we compared they symbols before.
* tools/abisym.cc (main): Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test12-report.txt: Adjust.
* tests/data/test-diff-dwarf/test18-alias-sym-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/test8-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test13-report.txt: Adjust.
* tests/data/test-diff-filter/test2-report.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust.
* tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust.
* tests/data/test-diff-filter/test9-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-06-01 22:07:02 +00:00
|
|
|
vector<elf_symbol_sptr>& alias_set);
|
2014-09-16 12:53:30 +00:00
|
|
|
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
/// The abstraction of the version of an ELF symbol.
|
|
|
|
class elf_symbol::version
|
|
|
|
{
|
|
|
|
struct priv;
|
|
|
|
shared_ptr<priv> priv_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
version();
|
|
|
|
|
|
|
|
version(const string& v,
|
2014-08-25 21:04:53 +00:00
|
|
|
bool is_default);
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
|
|
|
|
version(const version& v);
|
|
|
|
|
|
|
|
operator const string&() const;
|
|
|
|
|
|
|
|
const string&
|
|
|
|
str() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
str(const string& s);
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_default() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
is_default(bool f);
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_empty() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const version& o) const;
|
|
|
|
|
|
|
|
version&
|
|
|
|
operator=(const version& o);
|
|
|
|
};// end class elf_symbol::version
|
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
class context_rel;
|
|
|
|
/// A convenience typedef for shared pointers to @ref context_rel
|
|
|
|
typedef shared_ptr<context_rel> context_rel_sptr;
|
|
|
|
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
/// The abstraction of the relationship between an entity and its
|
|
|
|
/// containing scope (its context). That relationship can carry
|
|
|
|
/// properties like access rights (if the parent is a class_decl),
|
|
|
|
/// etc.
|
|
|
|
///
|
|
|
|
/// But importantly, this relationship carries a pointer to the
|
|
|
|
/// actualy parent.
|
|
|
|
class context_rel
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
scope_decl* scope_;
|
|
|
|
enum access_specifier access_;
|
|
|
|
bool is_static_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
context_rel()
|
|
|
|
: scope_(0),
|
|
|
|
access_(no_access),
|
|
|
|
is_static_(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
context_rel(scope_decl* s)
|
|
|
|
: scope_(s),
|
|
|
|
access_(no_access),
|
|
|
|
is_static_(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
context_rel(scope_decl* s,
|
|
|
|
access_specifier a,
|
|
|
|
bool f)
|
|
|
|
: scope_(s),
|
|
|
|
access_(a),
|
|
|
|
is_static_(f)
|
|
|
|
{}
|
|
|
|
|
|
|
|
scope_decl*
|
|
|
|
get_scope() const
|
|
|
|
{return scope_;}
|
|
|
|
|
|
|
|
access_specifier
|
|
|
|
get_access_specifier() const
|
|
|
|
{return access_;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_access_specifier(access_specifier a)
|
|
|
|
{access_ = a;}
|
|
|
|
|
|
|
|
bool
|
|
|
|
get_is_static() const
|
|
|
|
{return is_static_;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_is_static(bool s)
|
|
|
|
{is_static_ = s;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_scope(scope_decl* s)
|
|
|
|
{scope_ = s;}
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const context_rel& o)const
|
|
|
|
{
|
|
|
|
return (access_ == o.access_
|
|
|
|
&& is_static_ == o.is_static_);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~context_rel();
|
|
|
|
};// end class context_rel
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
class class_decl;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer on a @ref class_decl
|
|
|
|
typedef shared_ptr<class_decl> class_decl_sptr;
|
|
|
|
|
Delay non-complete class type resolution up to end of corpus reading
From the DWARF emitted by GCC 4.4.7 for libstdc++ we encountered an
interesting construct.
A non-complete version of std::runtime_error is declared in
libstdc++-v3/src/functexcept.cc and is represented in DWARF as:
[ 37344] class_type
name (strp) "runtime_error"
declaration (flag)
Then a bit later, that *non-complete* class is used as a base class
for a class, *without* being fully defined! This shouldn't happen
but, well, it does:
[ 3b3a1] class_type
specification (ref4) [ 3733e]
byte_size (data1) 16
decl_file (data1) 5
decl_line (data1) 141
containing_type (ref4) [ 3734a]
sibling (ref4) [3b405]
[ 3b3b1] inheritance
type (ref4) [ 37344] <---- here.
The thing is that, later, in another translation unit
(libstdc++-v3/src/stdexcept.cc), that same class is defined fully:
[ 7e9f9] class_type
name (strp) "runtime_error"
declaration (flag)
[...]
[ 80c95] class_type
specification (ref4) [ 7e9f9]
byte_size (data1) 16
decl_file (data1) 4
decl_line (data1) 108
containing_type (ref4) [ 7e9ff]
sibling (ref4) [ 80d2b]
[...] <---------- and the definition goes here.
But then you see that the DIE offset of the "version" of the
runtime_error class that is "defined" libstdc++-v3/src/stdexcept.cc in
is different from the version that is only declared in
libstdc++-v3/src/functexcept.cc. But virtue of the "One Definition
Rule", we can assume that they designate the same type. But still,
runtime_error should have been defined in
libstdc++-v3/src/stdexcept.cc. Anyhow, libabigail needs to be able to
handle this. That is, it needs to wait until the entire ABI corpus is
loaded from DWARF, then lookup the definition of all the non-complete
types we have encountered.
And then only after that non-complete type resolution has taken place,
we can proceed with type canonicalizing, rather than doing it after
the loading of each translation unit like what we were doing
previously.
This is what this patch does.
* include/abg-fwd.h (lookup_type_in_corpus): Declare new function.
* src/abg-corpus.cc (lookup_type_in_corpus): Define new function
here.
* include/abg-ir.h (function_types_type): Declare new typedef.
(translation_unit::get_canonical_function_type): Remove member function.
(translation_unit::bind_function_type_life_time): Declare new
member function.
(classes_type): New typedef.
* src/abg-ir.cc
(translation_unit::priv::canonical_function_types_): Remove data
member.
(translation_unit::priv::function_types): New data member.
(translation_unit::get_canonical_function_type): Remove this
function definition.
(translation_unit::bind_function_type_life_time): New function
definition.
(lookup_node_in_scope): Ensure that the type returned is
complete.
* src/abg-dwarf-reader.cc (string_classes_map): New typedef.
(read_context::decl_only_classes_map_): New data member.
(read_context::declaration_only_classes): New accessor.
(read_context::{maybe_schedule_declaration_only_class_for_resolution,
is_decl_only_class_scheduled_for_resolution,
resolve_declaration_only_classes, current_elf_file_is_executable,
current_elf_file_is_dso}): Define new member functions.
(read_context::clear_per_translation_unit_data): Do not clear the
data structures that associate DIEs to decls/types or that contain
the types to canonicalize here. Rather, clear them ...
(read_context::clear_per_corpus_data): ... here instead.
(read_context::build_translation_unit_and_add_to_ir): Do not
perform late type canonicalizing here. Rather, do it ...
(read_debug_info_into_corpus): ... here instead. And before that,
call read_context::clear_per_corpus_data() and the new
read_context::resolve_declaration_only_classes() here.
(build_class_type_and_add_to_ir): Schedule the non-complete types
for resolution to complete types. Assert that base classes that
are non-complete are scheduled to be completed.
(build_function_decl): Do not try to canonicalize function types
this early, systematically. Now, all the non-complete types needs
to be completed before starting canonicalizing. So let function
types go through the normal processes of deciding when to
canonicalize them. But then, bind the life time of the function
type to the life time of the current translation unit.
(maybe_canonicalize_type): If a class type is non-complete,
schedule it for late canonicalizing.
* src/abg-hash.cc (class_decl::hash::operator()(const class_decl&)
const): During hashing, a base class should be complete.
* src/abg-reader.cc
(read_context::clear_per_translation_unit_data): Do not clear
id/xml node, and type maps here. Rather, clear it ...
(read_context::clear_per_corpus_data): ... here instead.
(read_translation_unit_from_input): Do not perform late
canonicalizing here. Rather, do it ...
(read_corpus_from_input): ... here. Also, call the new
read_context::clear_per_corpus_data() here.
(build_function_decl): Do not canonicalize function types here so
early. Rather, bind the life time of the function type to the
life time of the translation unit.
* src/abg-writer.cc (write_translation_unit): Do not clear the
type/ID map here.
* tests/data/test-read-dwarf/test2.so.abi: Adjust test input.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-17 09:54:12 +00:00
|
|
|
/// Convenience typedef for a vector of @ref class_decl_sptr
|
|
|
|
typedef vector<class_decl_sptr> classes_type;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
/// Convenience typedef for a weak pointer on a @ref class_decl.
|
|
|
|
typedef weak_ptr<class_decl> class_decl_wptr;
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
/// A bitfield that gives callers of abigail::ir::equals() some
|
|
|
|
/// insight about how different two internal representation artifacts
|
|
|
|
/// are.
|
|
|
|
enum change_kind
|
|
|
|
{
|
|
|
|
NO_CHANGE_KIND = 0,
|
|
|
|
|
|
|
|
/// This means that a given IR artifact has local differences, with
|
|
|
|
/// respect to the other artifact it was compared against. A local
|
|
|
|
/// change is a change that is carried by the artifact itself,
|
|
|
|
/// rather than by one off its sub-types.
|
|
|
|
LOCAL_CHANGE_KIND = 1,
|
|
|
|
|
|
|
|
/// This means that a given IR artifact has changes in some of its
|
|
|
|
/// sub-types, with respect to the other artifact it was compared
|
|
|
|
/// against.
|
|
|
|
SUBTYPE_CHANGE_KIND = 1 << 1
|
|
|
|
};// end enum change_kink
|
|
|
|
|
|
|
|
change_kind
|
|
|
|
operator|(change_kind, change_kind);
|
|
|
|
|
|
|
|
change_kind
|
|
|
|
operator&(change_kind, change_kind);
|
|
|
|
|
|
|
|
change_kind&
|
|
|
|
operator|=(change_kind&, change_kind);
|
|
|
|
|
|
|
|
change_kind&
|
|
|
|
operator&=(change_kind&, change_kind);
|
|
|
|
|
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const decl_base&, const decl_base&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
class type_or_decl_base;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to @ref
|
|
|
|
/// type_or_decl_base.
|
|
|
|
typedef shared_ptr<type_or_decl_base> type_or_decl_base_sptr;
|
|
|
|
|
|
|
|
/// The base class of both types and declarations.
|
|
|
|
class type_or_decl_base : public ir_traversable_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~type_or_decl_base();
|
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const = 0;
|
|
|
|
}; // end class type_or_decl_base
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const type_or_decl_base&, const type_or_decl_base&);
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const type_or_decl_base_sptr&, const type_or_decl_base_sptr&);
|
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
/// The base type of all declarations.
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
class decl_base : public virtual type_or_decl_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
mutable priv_sptr priv_;
|
|
|
|
|
|
|
|
bool
|
|
|
|
hashing_started() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
hashing_started(bool b) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
peek_hash_value() const;
|
|
|
|
|
|
|
|
const string&
|
|
|
|
peek_qualified_name() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_qualified_name(const string&) const;
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Facility to hash instances of decl_base.
|
|
|
|
struct hash;
|
2013-02-28 23:38:28 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
/// ELF visibility
|
2013-03-31 18:04:17 +00:00
|
|
|
enum visibility
|
|
|
|
{
|
|
|
|
VISIBILITY_NONE,
|
|
|
|
VISIBILITY_DEFAULT,
|
|
|
|
VISIBILITY_PROTECTED,
|
|
|
|
VISIBILITY_HIDDEN,
|
|
|
|
VISIBILITY_INTERNAL
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
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 12:24:08 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
/// ELF binding
|
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 12:24:08 +00:00
|
|
|
enum binding
|
|
|
|
{
|
|
|
|
BINDING_NONE,
|
|
|
|
BINDING_LOCAL,
|
|
|
|
BINDING_GLOBAL,
|
2013-05-10 12:31:24 +00:00
|
|
|
BINDING_WEAK
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Forbidden
|
|
|
|
decl_base();
|
|
|
|
|
2013-12-20 15:14:21 +00:00
|
|
|
virtual void
|
2013-08-02 03:16:22 +00:00
|
|
|
set_scope(scope_decl*);
|
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
protected:
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
const context_rel*
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
get_context_rel() const;
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
context_rel*
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
get_context_rel();
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
void
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
set_context_rel(context_rel_sptr c);
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
public:
|
2013-08-06 17:18:35 +00:00
|
|
|
decl_base(const std::string& name, location locus,
|
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 12:24:08 +00:00
|
|
|
const std::string& mangled_name = "",
|
2013-08-06 17:18:35 +00:00
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base(location);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
decl_base(const decl_base&);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-06 22:28:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~decl_base();
|
|
|
|
|
2014-03-20 12:34:00 +00:00
|
|
|
virtual size_t
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
get_hash() const;
|
|
|
|
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
get_qualified_name(string& qualified_name) const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
virtual const string&
|
|
|
|
get_qualified_name() const;
|
|
|
|
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
void
|
|
|
|
set_hash(size_t) const;
|
|
|
|
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
bool
|
|
|
|
get_is_in_public_symbol_table() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_is_in_public_symbol_table(bool);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
location
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
get_location() const;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
|
|
|
void
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
set_location(const location& l);
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
const string&
|
2014-02-21 15:10:41 +00:00
|
|
|
get_name() const;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
const string&
|
2014-02-21 15:10:41 +00:00
|
|
|
get_qualified_parent_name() const;
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
void
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
set_name(const string& n);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
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 12:24:08 +00:00
|
|
|
const string&
|
Rename decl_base::get_mangled_name into decl_base::get_linkage_name
* include/abg-ir.h (decl_base::get_linkage_name): Renamed
decl_base::get_mangled_name into this.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated)
(function_decl_diff::report, type_decl_diff::report)
(corpus_diff::priv::ensure_lookup_tables_populated)
(corpus_diff::report, compute_diff): Adjust.
* src/abg-corpus.cc ({var_comp, func_comp}::operator()): Likewise.
(corpus::priv::build_symbol_table): Likewise.
* src/abg-dwarf-reader.cc (die_linkage_name): Renamed
die_mangled_name into this.
(die_loc_and_name, build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_type, build_class_type_and_add_to_ir)
(build_typedef_type, build_var_decl, build_function_decl, ): Adjust.
* src/abg-hash.cc (decl_base::hash::operator()): Likewise.
* src/abg-ir.cc (decl_base::priv::linkage_name_): Renamed
decl_base::priv::mangled_name_ into this.
(decl_base::priv::priv, decl_base::{decl_base, operator==})
(get_linkage_name, typedef_decl::typedef_decl, var_decl::var_decl)
(function_decl::function_decl, class_decl::base_spec::base_spec)
(class_decl::method_decl::method_decl): Adjust.
(decl_base::{g,s}et_linkage_name): Renamed
decl_base::{g,s}et_mangled_name into this.
* src/abg-writer.cc (write_decl, write_typedef_decl)
(write_var_decl, write_function_decl, dump): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-07 15:51:25 +00:00
|
|
|
get_linkage_name() const;
|
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 12:24:08 +00:00
|
|
|
|
|
|
|
void
|
Rename decl_base::get_mangled_name into decl_base::get_linkage_name
* include/abg-ir.h (decl_base::get_linkage_name): Renamed
decl_base::get_mangled_name into this.
* src/abg-comparison.cc
(class_diff::ensure_lookup_tables_populated)
(function_decl_diff::report, type_decl_diff::report)
(corpus_diff::priv::ensure_lookup_tables_populated)
(corpus_diff::report, compute_diff): Adjust.
* src/abg-corpus.cc ({var_comp, func_comp}::operator()): Likewise.
(corpus::priv::build_symbol_table): Likewise.
* src/abg-dwarf-reader.cc (die_linkage_name): Renamed
die_mangled_name into this.
(die_loc_and_name, build_translation_unit_and_add_to_ir)
(build_namespace_decl_and_add_to_ir, build_type_decl)
(build_enum_type, build_class_type_and_add_to_ir)
(build_typedef_type, build_var_decl, build_function_decl, ): Adjust.
* src/abg-hash.cc (decl_base::hash::operator()): Likewise.
* src/abg-ir.cc (decl_base::priv::linkage_name_): Renamed
decl_base::priv::mangled_name_ into this.
(decl_base::priv::priv, decl_base::{decl_base, operator==})
(get_linkage_name, typedef_decl::typedef_decl, var_decl::var_decl)
(function_decl::function_decl, class_decl::base_spec::base_spec)
(class_decl::method_decl::method_decl): Adjust.
(decl_base::{g,s}et_linkage_name): Renamed
decl_base::{g,s}et_mangled_name into this.
* src/abg-writer.cc (write_decl, write_typedef_decl)
(write_var_decl, write_function_decl, dump): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-07 15:51:25 +00:00
|
|
|
set_linkage_name(const std::string& m);
|
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 12:24:08 +00:00
|
|
|
|
2013-03-31 17:35:41 +00:00
|
|
|
scope_decl*
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
get_scope() const;
|
2013-03-04 15:29:31 +00:00
|
|
|
|
2013-03-31 18:04:17 +00:00
|
|
|
visibility
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
get_visibility() const;
|
2013-03-31 18:04:17 +00:00
|
|
|
|
|
|
|
void
|
Pimplify decl_base and add decl_base::{s,g}et_is_in_public_symbol_table
* include/abg-ir.h (struct decl_base::priv): New pimpl type.
(decl_base::priv_): New pimpl.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Declare new protected
methods.
(decl_base::{get_context_rel, set_qualified_name, get_location,
set_location, set_name, set_mangled_name, get_visibility,
set_visibility}): Move these out-of-line.
(decl_base::{g,s}et_is_public_symbol_table):
(class_decl::hashing_started): Remove this as we now have
decl_base::hashing_started.
(decl_base::{hash_, hashing_started, location_, context_, name_,
qualified_parent_name_, qualified_name_, mangled_name_,
visibility_}): Move all these members into the new ...
* src/abg-ir.cc (struct decl_base::priv): ... pimpl type.
(decl_base::decl_base): Move these out-of-line here. Adjust the
other overloads.
(decl_base::{hashing_started, peek_hash_value,
peek_qualified_name, set_qualified_name}): Define these new
protected methods.
(decl_base::{get_context_rel, set_context_rel, get_location,
set_location, set_name, get_mangled_name, set_mangled_name,
get_visibility, set_visibility}): Define these out-of-line here.
(decl_base::{get_hash, set_hash, get_scope,
get_qualified_parent_name, get_qualified_name, operator==,
set_scope}): Adjust.
(qualified_type_def::get_qualified_name): Likewise.
(pointer_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(var_decl::set_scope): Likewise.
(class_decl::base_spec): Likewise.
(class_decl::method_decl::set_scope): Likewise.
(decl_base::{g,s}et_is_in_public_symbol_table): Define new accessors.
* src/abg-hash.cc ({decl_base, type_decl, scope_decl,
scope_type_decl, qualified_type_def, pointer_type_def,
reference_type_def, enum_type_decl, typedef_decl, var_decl,
class_decl}::hash::operator): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-21 14:48:13 +00:00
|
|
|
set_visibility(visibility v);
|
2013-03-31 18:04:17 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
friend bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const decl_base&, const decl_base&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
|
|
|
friend bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const var_decl&, const var_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
friend decl_base_sptr
|
|
|
|
add_decl_to_scope(decl_base_sptr dcl, scope_decl* scpe);
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
|
2014-02-19 15:37:54 +00:00
|
|
|
friend void
|
|
|
|
remove_decl_from_scope(decl_base_sptr);
|
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
friend decl_base_sptr
|
|
|
|
insert_decl_into_scope(decl_base_sptr,
|
2013-12-12 14:40:52 +00:00
|
|
|
vector<shared_ptr<decl_base> >::iterator,
|
|
|
|
scope_decl*);
|
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
friend enum access_specifier
|
|
|
|
get_member_access_specifier(const decl_base& d);
|
|
|
|
|
|
|
|
friend enum access_specifier
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
get_member_access_specifier(const decl_base_sptr& d);
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
|
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_access_specifier(decl_base& d,
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
access_specifier a);
|
|
|
|
|
|
|
|
friend bool
|
|
|
|
get_member_is_static(const decl_base& d);
|
|
|
|
|
|
|
|
friend bool
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
get_member_is_static(const decl_base_sptr& d);
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
|
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_is_static(const decl_base_sptr& d, bool s);
|
|
|
|
|
|
|
|
friend void
|
|
|
|
set_member_is_static(decl_base& d, bool s);
|
2013-12-12 14:40:52 +00:00
|
|
|
|
2014-04-14 12:56:51 +00:00
|
|
|
friend bool
|
2014-09-30 16:16:03 +00:00
|
|
|
get_member_function_is_virtual(const function_decl& f);
|
2014-04-14 12:56:51 +00:00
|
|
|
|
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_is_virtual(function_decl&, bool);
|
2014-04-14 12:56:51 +00:00
|
|
|
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
friend class class_decl;
|
2013-10-05 20:54:38 +00:00
|
|
|
};// end class decl_base
|
2013-04-22 18:59:50 +00:00
|
|
|
|
Initial un-debugged implementation of scope diffing
* include/abg-comparison.h (class scope_diff): New type.
(compute_diff(scope_decl_sptr, scope_decl_sptr, scope_diff)): New
declaration.
(report_changes): New declaration.
* src/abg-comparison.cc (struct scope_diff::priv): Define.
(scope_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, scope_diff, member_changes,
deleted_member_at, inserted_member_at, changed_types,
changed_decls}): Define these new member functions.
(compute_diff): Define.
* include/abg-ir.h (decl_base_sptr): New typedef.
(operator==(decl_base_sptr, decl_base_sptr)): Declare new
operator.
* src/abg-ir.cc (operator==(decl_base_sptr, decl_base_sptr)):
Define.
(scope_decl::{operator==, traverse}): Adjust for using vectors to
store scope members now, rather than lists.
(scope_decl::{declarations, scopes}): Make these types be vector.
This makes the members of a scopes be vector, rather than lists.
This enables them to be diffed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-05 21:11:22 +00:00
|
|
|
bool
|
2014-04-02 15:23:56 +00:00
|
|
|
operator==(const decl_base_sptr, const decl_base_sptr);
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const type_base_sptr, const type_base_sptr);
|
Initial un-debugged implementation of scope diffing
* include/abg-comparison.h (class scope_diff): New type.
(compute_diff(scope_decl_sptr, scope_decl_sptr, scope_diff)): New
declaration.
(report_changes): New declaration.
* src/abg-comparison.cc (struct scope_diff::priv): Define.
(scope_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, scope_diff, member_changes,
deleted_member_at, inserted_member_at, changed_types,
changed_decls}): Define these new member functions.
(compute_diff): Define.
* include/abg-ir.h (decl_base_sptr): New typedef.
(operator==(decl_base_sptr, decl_base_sptr)): Declare new
operator.
* src/abg-ir.cc (operator==(decl_base_sptr, decl_base_sptr)):
Define.
(scope_decl::{operator==, traverse}): Adjust for using vectors to
store scope members now, rather than lists.
(scope_decl::{declarations, scopes}): Make these types be vector.
This makes the members of a scopes be vector, rather than lists.
This enables them to be diffed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-05 21:11:22 +00:00
|
|
|
|
Add diff support for typedef_decl and type_decl
* include/abg-ir.h (operator<<(std::ostream&,
decl_base::visibility)): Declare new streaming operator.
* src/abg-ir.cc (operator<<(std::ostream&,
decl_base::visibility)): Define it.
(type_decl::{operator==, get_pretty_representation}): Likewise,
define these new overloads.
(decl_base::{operator==, get_pretty_representation}): New overloads.
* include/abg-comparison.h (type_decl_diff type_decl_diff_sptr,
typedef_diff, typedef_diff_sptr): Declare new classes and
typedefs.
* src/abg-comparison.cc (type_decl_diff::{type_decl_diff,
first_type_decl, second_type_decl, length, report}): New methods
definitions.
(compute_diff): New function definition that takes pointers of
type_decl.
(typedef_diff::{typedef_diff, first_typedef_decl,
second_typedef_decl, underlying_type_diff, length, report}): New
methods.
(compute_diff): New function definition that takes pointers of
typedef_decl.
(try_to_diff_types): New template function, factorized out of ...
(compute_diff_for_types): ... this. Add support diffing type_decl
and typedef_decl.
(pointer_diff::report): Fix indentation of emitted report.
* tools/bidiff.cc (parse_command_line): Fix style.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:58:56 +00:00
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream&, decl_base::visibility);
|
|
|
|
|
2013-11-20 18:13:55 +00:00
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream&, decl_base::binding);
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const scope_decl&, const scope_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref scope_decl.
|
Initial un-debugged implementation of scope diffing
* include/abg-comparison.h (class scope_diff): New type.
(compute_diff(scope_decl_sptr, scope_decl_sptr, scope_diff)): New
declaration.
(report_changes): New declaration.
* src/abg-comparison.cc (struct scope_diff::priv): Define.
(scope_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, scope_diff, member_changes,
deleted_member_at, inserted_member_at, changed_types,
changed_decls}): Define these new member functions.
(compute_diff): Define.
* include/abg-ir.h (decl_base_sptr): New typedef.
(operator==(decl_base_sptr, decl_base_sptr)): Declare new
operator.
* src/abg-ir.cc (operator==(decl_base_sptr, decl_base_sptr)):
Define.
(scope_decl::{operator==, traverse}): Adjust for using vectors to
store scope members now, rather than lists.
(scope_decl::{declarations, scopes}): Make these types be vector.
This makes the members of a scopes be vector, rather than lists.
This enables them to be diffed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-05 21:11:22 +00:00
|
|
|
typedef shared_ptr<scope_decl> scope_decl_sptr;
|
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
/// A declaration that introduces a scope.
|
2013-08-06 22:28:56 +00:00
|
|
|
class scope_decl : public virtual decl_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
2013-08-06 17:18:35 +00:00
|
|
|
public:
|
2013-11-20 09:54:15 +00:00
|
|
|
|
|
|
|
/// Convenience typedef for a vector of @ref decl_base_sptr.
|
|
|
|
typedef std::vector<decl_base_sptr > declarations;
|
|
|
|
/// Convenience typedef for a vector of @ref scope_decl_sptr.
|
|
|
|
typedef std::vector<scope_decl_sptr> scopes;
|
2013-08-06 17:18:35 +00:00
|
|
|
|
|
|
|
private:
|
2013-10-05 20:54:38 +00:00
|
|
|
declarations members_;
|
|
|
|
scopes member_scopes_;
|
2013-02-28 23:38:28 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
scope_decl();
|
2013-05-23 15:40:05 +00:00
|
|
|
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
protected:
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
virtual decl_base_sptr
|
2013-12-12 14:27:42 +00:00
|
|
|
add_member_decl(const decl_base_sptr member);
|
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 15:56:00 +00:00
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
virtual decl_base_sptr
|
2013-12-12 14:40:52 +00:00
|
|
|
insert_member_decl(const decl_base_sptr member,
|
|
|
|
declarations::iterator before);
|
|
|
|
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
virtual void
|
|
|
|
remove_member_decl(const decl_base_sptr member);
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
public:
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
struct hash;
|
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
scope_decl(const std::string& name, location locus,
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
visibility vis = VISIBILITY_DEFAULT)
|
2013-08-02 23:30:56 +00:00
|
|
|
: decl_base(name, locus, /*mangled_name=*/name, vis)
|
2013-10-04 15:03:34 +00:00
|
|
|
{}
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
scope_decl(location l) : decl_base("", l)
|
2013-10-04 15:03:34 +00:00
|
|
|
{}
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const declarations&
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
get_member_decls() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return members_;}
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
|
2013-12-12 14:40:52 +00:00
|
|
|
declarations&
|
|
|
|
get_member_decls()
|
|
|
|
{return members_;}
|
|
|
|
|
|
|
|
scopes&
|
|
|
|
get_member_scopes()
|
2013-09-26 14:45:00 +00:00
|
|
|
{return member_scopes_;}
|
2013-05-23 15:40:05 +00:00
|
|
|
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
const scopes&
|
|
|
|
get_member_scopes() const
|
|
|
|
{return member_scopes_;}
|
|
|
|
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
bool
|
|
|
|
is_empty() const
|
2013-10-04 15:03:34 +00:00
|
|
|
{return get_member_decls().empty();}
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-12-12 14:40:52 +00:00
|
|
|
bool
|
|
|
|
find_iterator_for_member(const decl_base*, declarations::iterator&);
|
|
|
|
|
|
|
|
bool
|
|
|
|
find_iterator_for_member(const decl_base_sptr, declarations::iterator&);
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
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-20 10:30:04 +00:00
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~scope_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
friend decl_base_sptr
|
|
|
|
add_decl_to_scope(decl_base_sptr dcl, scope_decl* scpe);
|
2013-12-12 14:40:52 +00:00
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
friend decl_base_sptr
|
2013-12-12 14:40:52 +00:00
|
|
|
insert_decl_into_scope(decl_base_sptr decl,
|
|
|
|
scope_decl::declarations::iterator before,
|
|
|
|
scope_decl* scope);
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
|
|
|
|
friend void
|
|
|
|
remove_decl_from_scope(decl_base_sptr decl);
|
2013-10-05 20:54:38 +00:00
|
|
|
};//end class scope_decl
|
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 15:56:00 +00:00
|
|
|
|
2015-03-13 11:54:25 +00:00
|
|
|
bool
|
|
|
|
operator==(scope_decl_sptr, scope_decl_sptr);
|
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
/// Hasher for the @ref scope_decl type.
|
|
|
|
struct scope_decl::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const scope_decl& d) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const scope_decl* d) const;
|
|
|
|
};
|
|
|
|
|
2013-12-12 14:27:42 +00:00
|
|
|
/// Convenience typedef for shared pointer on @ref global_scope.
|
|
|
|
typedef shared_ptr<global_scope> global_scope_sptr;
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
/// This abstracts the global scope of a given translation unit.
|
|
|
|
///
|
|
|
|
/// Only one instance of this class must be present in a given
|
|
|
|
/// translation_unit. That instance is implicitely created the first
|
|
|
|
/// time translatin_unit::get_global_scope is invoked.
|
|
|
|
class global_scope : public scope_decl
|
|
|
|
{
|
2013-12-12 14:27:42 +00:00
|
|
|
translation_unit* translation_unit_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-05-23 15:30:27 +00:00
|
|
|
global_scope(translation_unit *tu)
|
2013-08-02 03:16:22 +00:00
|
|
|
: decl_base("", location()), scope_decl("", location()),
|
2013-09-26 14:45:00 +00:00
|
|
|
translation_unit_(tu)
|
2013-10-10 08:11:35 +00:00
|
|
|
{}
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
friend class translation_unit;
|
|
|
|
|
|
|
|
translation_unit*
|
|
|
|
get_translation_unit() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return translation_unit_;}
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
|
|
|
|
virtual ~global_scope();
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
Introduce/use translation_unit & global_scope types
* abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove.
(abi_corpus::add): New function to add a translation unit.
(abi_corpus::get_translation_units): New declaration.
* abg-corpus.cc (abi_corpus::*): Remove all the definitions of
abi_corpus for now, as the abi_corpus type is not used anymore --
for now at least.
* src/abg-ir.h (add_decl_to_scope, get_global_scope)
(get_translation_unit, is_global_scope, is_decl_at_global_scope)
(class translation_unit, class global_scope): New declarations
* src/abg-ir.cc (translation_unit::translation_unit)
(translation_unit::get_global_scope)
(translation_unit::get_loc_mgr, translation_unit::get_loc_mgr)
(translation_unit::is_empty, get_global_scope)
(get_translation_unit, is_global_scope, is_global_scope)
(is_decl_at_global_scope, global_scope::~global_scope): New
definitions.
(scope_decl::scope_decl, scope_decl::scope_decl)
(scope_decl::add_member_decl, scope_decl::get_member_decls): Move
to abg-ir.h, inline.
* src/abg-reader.h (read_file): Don't use abi_corpus in the api.
Rather, use translation_unit.
* src/abg-reader.cc (read_context::get_cur_scope): Now that we
have a specific instance of global_scope to represent global
scope, don't play games with empty scopes to detect a global
scope.
(read_context::get_translation_unit): New definition.
(read_context::finish_decl_creation, finish_type_decl_creation):
(read_input, read_file, read_location, handle_element)
(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):
Don't use abi_corpus anymore. Rather, the translation unit a decl
belongs to is accessible from the decl itself.
* src/abg-writer.h (write_to_ostream): Use translation_unit in
this API, rather than abi_corpus.
* src/abg-writer.cc (write_translation_unit): Rename write_corpus
into this. And stop using abi_corpus here.
(write_to_ostream, write_corpus, write_location, write_decl)
(write_type_decl, write_namespace_decl, write_qualified_type_def)
(write_pointer_type_def, write_reference_type_def)
(write_enum_type_decl, write_typedef_decl, write_var_decl): Stop
using abi_corpus. Use the translation_unit that is accessible
from the decl being serialized, if need be.
* test-read-write.cc (main): De-serialize the input into an
instance of translation_unit, not an abi_corpus anymore, and
serialize that translation_unit.
2013-04-03 12:36:22 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const type_base&, const type_base&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
/// An abstraction helper for type declarations
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
class type_base : public virtual type_or_decl_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
Initial implementation of canonical type comparison in the IR
Comparing types that are equal showed up high in profiles. This patch
is an answer to that. It implements the notion of canonical type for
types known to libabigail. Then when comparing two types, if they
have a canonical types, just comparing the pointer value of their
canonical type is enough. This speeds up type comparison somewhat;
comparing the Xorg binaries from rhel 6 and 7 goes from more than 20h
(I gave up after that) to under 15 minutes.
* include/abg-ir.h (class type_base): Pimplify this class.
(type_base::canonical_types_map_type): New typedef.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Declare new member functions.
(enable_canonical_equality): Declare new function.
(struct type_base::hash): Declare this functor here.
* src/abg-ir.cc ():
* src/abg-dwarf-reader.cc (build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Enable canonical
equality for the resulting type returned by these functions.
* src/abg-hash.cc (type_base::hash::operator()(const type_base&)):
Adjust as this is now out-of-line. Also, add two overloads for
type_base* and type_base_sptr.
(struct type_base::priv): Define new type for private data of
type_base.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Define new member functions.
(enable_canonical_equality): Define new function
(type_base::{type_base, set_size_in_bits, get_size_in_bits,
set_alignment_in_bits, get_alignment_in_bits}): Adjust.
({type_decl, scope_type_decl, qualified_type_def,
pointer_type_def, reference_type_def, array_type_def,
enum_type_decl, typedef_decl, function_type,
class_decl}::operator==): If the types being compared have
canonical type then use them for comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-09 15:38:44 +00:00
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
// Forbid this.
|
2013-02-28 23:38:28 +00:00
|
|
|
type_base();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
Initial implementation of canonical type comparison in the IR
Comparing types that are equal showed up high in profiles. This patch
is an answer to that. It implements the notion of canonical type for
types known to libabigail. Then when comparing two types, if they
have a canonical types, just comparing the pointer value of their
canonical type is enough. This speeds up type comparison somewhat;
comparing the Xorg binaries from rhel 6 and 7 goes from more than 20h
(I gave up after that) to under 15 minutes.
* include/abg-ir.h (class type_base): Pimplify this class.
(type_base::canonical_types_map_type): New typedef.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Declare new member functions.
(enable_canonical_equality): Declare new function.
(struct type_base::hash): Declare this functor here.
* src/abg-ir.cc ():
* src/abg-dwarf-reader.cc (build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Enable canonical
equality for the resulting type returned by these functions.
* src/abg-hash.cc (type_base::hash::operator()(const type_base&)):
Adjust as this is now out-of-line. Also, add two overloads for
type_base* and type_base_sptr.
(struct type_base::priv): Define new type for private data of
type_base.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Define new member functions.
(enable_canonical_equality): Define new function
(type_base::{type_base, set_size_in_bits, get_size_in_bits,
set_alignment_in_bits, get_alignment_in_bits}): Adjust.
({type_decl, scope_type_decl, qualified_type_def,
pointer_type_def, reference_type_def, array_type_def,
enum_type_decl, typedef_decl, function_type,
class_decl}::operator==): If the types being compared have
canonical type then use them for comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-09 15:38:44 +00:00
|
|
|
|
|
|
|
static type_base_sptr
|
|
|
|
get_canonical_type_for(type_base_sptr);
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// A hasher for type_base types.
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
/// A hasher for types. It gets the dynamic type of the current
|
|
|
|
/// instance of type and hashes it accordingly. Note that the hashing
|
|
|
|
/// function of this hasher must be updated each time a new kind of
|
|
|
|
/// type is added to the IR.
|
|
|
|
struct dynamic_hash;
|
|
|
|
|
|
|
|
/// A hasher for shared_ptr<type_base> that will hash it based on the
|
|
|
|
/// runtime type of the type pointed to.
|
|
|
|
struct shared_ptr_hash;
|
|
|
|
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
struct cached_hash;
|
|
|
|
|
2013-03-04 15:29:31 +00:00
|
|
|
type_base(size_t s, size_t a);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2015-02-19 10:30:43 +00:00
|
|
|
friend type_base_sptr
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
canonicalize(type_base_sptr);
|
Initial implementation of canonical type comparison in the IR
Comparing types that are equal showed up high in profiles. This patch
is an answer to that. It implements the notion of canonical type for
types known to libabigail. Then when comparing two types, if they
have a canonical types, just comparing the pointer value of their
canonical type is enough. This speeds up type comparison somewhat;
comparing the Xorg binaries from rhel 6 and 7 goes from more than 20h
(I gave up after that) to under 15 minutes.
* include/abg-ir.h (class type_base): Pimplify this class.
(type_base::canonical_types_map_type): New typedef.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Declare new member functions.
(enable_canonical_equality): Declare new function.
(struct type_base::hash): Declare this functor here.
* src/abg-ir.cc ():
* src/abg-dwarf-reader.cc (build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Enable canonical
equality for the resulting type returned by these functions.
* src/abg-hash.cc (type_base::hash::operator()(const type_base&)):
Adjust as this is now out-of-line. Also, add two overloads for
type_base* and type_base_sptr.
(struct type_base::priv): Define new type for private data of
type_base.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Define new member functions.
(enable_canonical_equality): Define new function
(type_base::{type_base, set_size_in_bits, get_size_in_bits,
set_alignment_in_bits, get_alignment_in_bits}): Adjust.
({type_decl, scope_type_decl, qualified_type_def,
pointer_type_def, reference_type_def, array_type_def,
enum_type_decl, typedef_decl, function_type,
class_decl}::operator==): If the types being compared have
canonical type then use them for comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-09 15:38:44 +00:00
|
|
|
|
|
|
|
type_base_sptr
|
|
|
|
get_canonical_type() const;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~type_base();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
void
|
|
|
|
set_size_in_bits(size_t);
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Make type_base::get_{size,alignment}_in_bits virtual
* include/abg-ir.h (type_base::get_{size,alignment}_in_bits): Make
this virtual.
(typedef_decl::get_{size,alignment}_in_bits): Add new member
functions. Get the size,alignment from the underlying type and
update the current size/alignment if they differ. Keep in mind
that the size of an underlying class_decl can change over its
lifetime, given how the dwarf reader reads the type information,
i.e, there can be a DIE for a class type with no size information
that will lead to the creation of a class_decl with size zero.
Later during the DWARF reading process, another DIE will
supplement the type information, adding size information to that
class_decl. In between, a typedef_decl might have been created
with the first version of the class_decl that has a zero size. I
guess this should be extended to the other type constructs that
have an underlying type (qualified types, references and pointers).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 08:08:10 +00:00
|
|
|
virtual size_t
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
get_size_in_bits() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_alignment_in_bits(size_t);
|
|
|
|
|
Make type_base::get_{size,alignment}_in_bits virtual
* include/abg-ir.h (type_base::get_{size,alignment}_in_bits): Make
this virtual.
(typedef_decl::get_{size,alignment}_in_bits): Add new member
functions. Get the size,alignment from the underlying type and
update the current size/alignment if they differ. Keep in mind
that the size of an underlying class_decl can change over its
lifetime, given how the dwarf reader reads the type information,
i.e, there can be a DIE for a class type with no size information
that will lead to the creation of a class_decl with size zero.
Later during the DWARF reading process, another DIE will
supplement the type information, adding size information to that
class_decl. In between, a typedef_decl might have been created
with the first version of the class_decl that has a zero size. I
guess this should be extended to the other type constructs that
have an underlying type (qualified types, references and pointers).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 08:08:10 +00:00
|
|
|
virtual size_t
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
get_alignment_in_bits() const;
|
2013-10-05 20:54:38 +00:00
|
|
|
};//end class type_base
|
2013-03-27 22:34:07 +00:00
|
|
|
|
Initial implementation of canonical type comparison in the IR
Comparing types that are equal showed up high in profiles. This patch
is an answer to that. It implements the notion of canonical type for
types known to libabigail. Then when comparing two types, if they
have a canonical types, just comparing the pointer value of their
canonical type is enough. This speeds up type comparison somewhat;
comparing the Xorg binaries from rhel 6 and 7 goes from more than 20h
(I gave up after that) to under 15 minutes.
* include/abg-ir.h (class type_base): Pimplify this class.
(type_base::canonical_types_map_type): New typedef.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Declare new member functions.
(enable_canonical_equality): Declare new function.
(struct type_base::hash): Declare this functor here.
* src/abg-ir.cc ():
* src/abg-dwarf-reader.cc (build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Enable canonical
equality for the resulting type returned by these functions.
* src/abg-hash.cc (type_base::hash::operator()(const type_base&)):
Adjust as this is now out-of-line. Also, add two overloads for
type_base* and type_base_sptr.
(struct type_base::priv): Define new type for private data of
type_base.
(type_base::{get_canonical_types_map, get_canonical_type_for,
get_canonical_type}): Define new member functions.
(enable_canonical_equality): Define new function
(type_base::{type_base, set_size_in_bits, get_size_in_bits,
set_alignment_in_bits, get_alignment_in_bits}): Adjust.
({type_decl, scope_type_decl, qualified_type_def,
pointer_type_def, reference_type_def, array_type_def,
enum_type_decl, typedef_decl, function_type,
class_decl}::operator==): If the types being compared have
canonical type then use them for comparison.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-09 15:38:44 +00:00
|
|
|
/// Hash functor for instances of @ref type_base.
|
|
|
|
struct type_base::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const type_base& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const type_base* t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const type_base_sptr t) const;
|
|
|
|
}; // end struct type_base::hash
|
|
|
|
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
/// A predicate for deep equality of instances of
|
|
|
|
/// type_base*
|
|
|
|
struct type_ptr_equal
|
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const type_base* l, const type_base* r) const
|
|
|
|
{
|
|
|
|
if (!!l != !!r)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (l == r)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (l)
|
|
|
|
return *l == *r;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-19 14:01:59 +00:00
|
|
|
/// A predicate for deep equality of instances of
|
|
|
|
/// shared_ptr<type_base>
|
2013-03-28 14:27:15 +00:00
|
|
|
struct type_shared_ptr_equal
|
|
|
|
{
|
|
|
|
bool
|
Initial un-debugged implementation of scope diffing
* include/abg-comparison.h (class scope_diff): New type.
(compute_diff(scope_decl_sptr, scope_decl_sptr, scope_diff)): New
declaration.
(report_changes): New declaration.
* src/abg-comparison.cc (struct scope_diff::priv): Define.
(scope_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, scope_diff, member_changes,
deleted_member_at, inserted_member_at, changed_types,
changed_decls}): Define these new member functions.
(compute_diff): Define.
* include/abg-ir.h (decl_base_sptr): New typedef.
(operator==(decl_base_sptr, decl_base_sptr)): Declare new
operator.
* src/abg-ir.cc (operator==(decl_base_sptr, decl_base_sptr)):
Define.
(scope_decl::{operator==, traverse}): Adjust for using vectors to
store scope members now, rather than lists.
(scope_decl::{declarations, scopes}): Make these types be vector.
This makes the members of a scopes be vector, rather than lists.
This enables them to be diffed.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-05 21:11:22 +00:00
|
|
|
operator()(const type_base_sptr l, const type_base_sptr r) const
|
2013-03-28 14:27:15 +00:00
|
|
|
{
|
2013-10-16 15:39:40 +00:00
|
|
|
if (!!l != !!r)
|
2013-03-28 14:27:15 +00:00
|
|
|
return false;
|
|
|
|
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
if (l.get() == r.get())
|
|
|
|
return true;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
if (l)
|
|
|
|
return *l == *r;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const type_decl&, const type_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref type_decl.
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
typedef shared_ptr<type_decl> type_decl_sptr;
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// A basic type declaration that introduces no scope.
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
class type_decl : public virtual decl_base, public virtual type_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
2013-03-04 15:29:31 +00:00
|
|
|
// Forbidden.
|
2013-02-28 23:38:28 +00:00
|
|
|
type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Facility to hash instance of type_decl
|
|
|
|
struct hash;
|
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
type_decl(const std::string& name,
|
|
|
|
size_t size_in_bits, size_t alignment_in_bits,
|
|
|
|
location locus, const std::string& mangled_name = "",
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2015-05-05 08:45:15 +00:00
|
|
|
static type_decl_sptr&
|
2014-06-23 15:24:54 +00:00
|
|
|
get_void_type_decl();
|
|
|
|
|
2015-05-05 08:05:45 +00:00
|
|
|
static type_decl_sptr&
|
|
|
|
get_variadic_parameter_type_decl();
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Add diff support for typedef_decl and type_decl
* include/abg-ir.h (operator<<(std::ostream&,
decl_base::visibility)): Declare new streaming operator.
* src/abg-ir.cc (operator<<(std::ostream&,
decl_base::visibility)): Define it.
(type_decl::{operator==, get_pretty_representation}): Likewise,
define these new overloads.
(decl_base::{operator==, get_pretty_representation}): New overloads.
* include/abg-comparison.h (type_decl_diff type_decl_diff_sptr,
typedef_diff, typedef_diff_sptr): Declare new classes and
typedefs.
* src/abg-comparison.cc (type_decl_diff::{type_decl_diff,
first_type_decl, second_type_decl, length, report}): New methods
definitions.
(compute_diff): New function definition that takes pointers of
type_decl.
(typedef_diff::{typedef_diff, first_typedef_decl,
second_typedef_decl, underlying_type_diff, length, report}): New
methods.
(compute_diff): New function definition that takes pointers of
typedef_decl.
(try_to_diff_types): New template function, factorized out of ...
(compute_diff_for_types): ... this. Add support diffing type_decl
and typedef_decl.
(pointer_diff::report): Fix indentation of emitted report.
* tools/bidiff.cc (parse_command_line): Fix style.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:58:56 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const type_decl&) const;
|
|
|
|
|
2013-11-21 13:44:44 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
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-20 10:30:04 +00:00
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~type_decl();
|
Add missing virtual keywords for traverse() method
* 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>
2013-12-14 09:07:02 +00:00
|
|
|
};// end class type_decl.
|
2013-02-28 23:38:28 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const scope_type_decl&, const scope_type_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2015-03-13 11:54:25 +00:00
|
|
|
bool
|
|
|
|
operator==(type_decl_sptr, type_decl_sptr);
|
|
|
|
|
2013-02-28 23:38:28 +00:00
|
|
|
/// A type that introduces a scope.
|
2013-04-23 07:35:31 +00:00
|
|
|
class scope_type_decl : public scope_decl, public virtual type_base
|
2013-02-28 23:38:28 +00:00
|
|
|
{
|
|
|
|
scope_type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for instances of scope_type_decl
|
|
|
|
struct hash;
|
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
scope_type_decl(const std::string& name, size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits, location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~scope_type_decl();
|
2013-03-04 15:29:31 +00:00
|
|
|
};
|
|
|
|
|
2013-12-12 14:27:42 +00:00
|
|
|
/// Convenience typedef for a shared pointer on namespace_decl.
|
|
|
|
typedef shared_ptr<namespace_decl> namespace_decl_sptr;
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
/// The abstraction of a namespace declaration
|
2013-03-04 15:29:31 +00:00
|
|
|
class namespace_decl : public scope_decl
|
|
|
|
{
|
2013-02-28 23:38:28 +00:00
|
|
|
public:
|
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
namespace_decl(const std::string& name, location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
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-20 10:30:04 +00:00
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
Parse type-decl and namespace-decl elements
* configure.ac: Add libxml2 dependencies.
* src/abg-corpus.{h,cc}: New files.
* src/abg-hash.{h,cc}: Likewise.
* src/abg-libxml-utils.{h,cc}: Likewise.
* src/abg-reader.{h,cc}: Likewise.
* src/abg-serialize.{h,cc}: Likewise.
* src/abg-writer.h: Likewise.
* src/Makefile.am: Build the new files above.
* src/abg-ir.h (class location): Add public accessors for the value, and
a truth operator. Make the methods be inline.
(class decl_base): Renamed decl into this. Renamed what_decl_kind
into what_kind. Renamed get_context into get_scope. Add virtual
destructor, accessors for location and name.
(class {scope_decl, type_base, type_decl} ): Add virtual dtor.
Re-style.
(struct {decl_base_hash, type_decl_hash}): New hashing functors.
(class {scope_type_decl, namespace_decl}): Add virtual dtor.
* src/abg-ir.cc (location::*): Remove location definitions. There
are now inline in the header.
(class decl_base): Renamed decl into this. Remove most of the
definitions from here as their are now inline in the header.
(scope_decl::~scope_decl, type_base::~type_base)
(type_decl::~type_decl, scope_type_decl::~scope_type_decl): New
definitions.
2013-03-08 12:49:05 +00:00
|
|
|
virtual ~namespace_decl();
|
2013-10-10 08:11:35 +00:00
|
|
|
};// end class namespace_decl
|
2013-03-27 22:34:07 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const qualified_type_def&, const qualified_type_def&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-25 22:14:58 +00:00
|
|
|
typedef shared_ptr<qualified_type_def> qualified_type_def_sptr;
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
/// The abstraction of a qualified type.
|
2013-10-10 08:11:35 +00:00
|
|
|
class qualified_type_def : public virtual type_base, public virtual decl_base
|
2013-03-27 22:34:07 +00:00
|
|
|
{
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
// Forbidden.
|
|
|
|
qualified_type_def();
|
2013-08-02 23:30:56 +00:00
|
|
|
|
2014-02-21 15:10:41 +00:00
|
|
|
protected:
|
|
|
|
string build_name(bool) const;
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
public:
|
2013-08-02 23:30:56 +00:00
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// A Hasher for instances of qualified_type_def
|
|
|
|
struct hash;
|
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
/// Bit field values representing the cv qualifiers of the
|
|
|
|
/// underlying type.
|
|
|
|
enum CV
|
|
|
|
{
|
|
|
|
CV_NONE = 0,
|
|
|
|
CV_CONST = 1,
|
2013-06-21 07:39:13 +00:00
|
|
|
CV_VOLATILE = 1 << 1,
|
|
|
|
CV_RESTRICT = 1 << 2
|
2013-03-27 22:34:07 +00:00
|
|
|
};
|
|
|
|
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
qualified_type_def(type_base_sptr type, CV quals, location locus);
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2014-04-16 08:45:23 +00:00
|
|
|
virtual size_t
|
|
|
|
get_size_in_bits() const;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
CV
|
2013-03-27 22:34:07 +00:00
|
|
|
get_cv_quals() const;
|
|
|
|
|
|
|
|
void
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
set_cv_quals(CV cv_quals);
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2014-02-21 15:10:41 +00:00
|
|
|
string
|
|
|
|
get_cv_quals_string_prefix() const;
|
|
|
|
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
type_base_sptr
|
2013-03-27 22:34:07 +00:00
|
|
|
get_underlying_type() const;
|
|
|
|
|
2014-02-21 15:10:41 +00:00
|
|
|
virtual void
|
|
|
|
get_qualified_name(string& qualified_name) const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
virtual const string&
|
|
|
|
get_qualified_name() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-03-27 22:34:07 +00:00
|
|
|
virtual ~qualified_type_def();
|
2013-11-25 22:14:58 +00:00
|
|
|
}; // end class qualified_type_def.
|
2013-03-27 22:34:07 +00:00
|
|
|
|
2013-08-27 11:55:45 +00:00
|
|
|
qualified_type_def::CV
|
2013-08-02 23:30:56 +00:00
|
|
|
operator|(qualified_type_def::CV, qualified_type_def::CV);
|
2013-06-21 07:39:13 +00:00
|
|
|
|
2013-11-25 22:14:58 +00:00
|
|
|
std::ostream&
|
|
|
|
operator<<(std::ostream&, qualified_type_def::CV);
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const pointer_type_def&, const pointer_type_def&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref pointer_type_def
|
2013-10-15 07:44:53 +00:00
|
|
|
typedef shared_ptr<pointer_type_def> pointer_type_def_sptr;
|
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
/// The abstraction of a pointer type.
|
2013-10-10 08:11:35 +00:00
|
|
|
class pointer_type_def : public virtual type_base, public virtual decl_base
|
2013-03-28 14:27:15 +00:00
|
|
|
{
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
type_base_wptr pointed_to_type_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
// Forbidden.
|
|
|
|
pointer_type_def();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// A hasher for instances of pointer_type_def
|
|
|
|
struct hash;
|
|
|
|
|
Make determining of compatible types complete
Until now, two types that are different were considered compatible if
one type is a typedef of the other. This is useful because two
different types, if compatible, are not ABI-incompatible. This patch
extends the concept of compatible types to types which might have
sub-types that are typedefs of each others, including function types.
Note implementing this required that I fixed various other things left
and right. Like style fixes, crash avoiding fixes, etc.
* include/abg-fwd.h (is_reference_type, is_function_type)
(is_method_type): Declare new predicates.
* include/abg-ir.h (class qualified_type_def): Pimpl this class.
(qualified_type_def::qualified_type_def): Use the convenience
type_base_sptr typedef.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Use the
qualified_type_def::CV type rather than char.
(qualified_type_def::get_underlying_type): Use the convenience
type_base_sptr typedef.
(pointer_type_def::pointer_type_def): Likewise.
(function_decl::parameter::parameter): Add a new constructor.
* src/abg-ir.cc (is_reference_type, is_function_type)
(is_method_type): Define new predicates.
(class qualified_type_def::priv): Define this new private type,
for the purpose of Pimpl-ifying the qualified_type_def class.
(qualified_type_def::{qualified_type_def, build_name,
get_cv_quals_string_prefix, get_underlying_type}): Adjust for the
purpose of Pimpl-ifying the qualified_type_def class.
(equals): In the qualified_type_def, reference_type_def overloads,
trust the fact that we have operator== overload for the
type_base_sptr. This avoids crashes for when the (possible)
underlying type is null.
(pointer_type_def::operator==): Likewise.
(strip_typedef): Make this recursively strip
typedefs from sub-types.
(types_are_compatible): Handle null types.
(qualified_type_def::{get_cv_quals, set_cv_quals}): Handle
qualified_type_def::CV rather than char.
(pointer_type_def::pointer_type_def): Use the convenience
type_base_sptr typedef.
* include/abg-comparison.h (distinct_diff::compatible_child_diff):
Declare new member function.
* src/abg-comparison.cc (distinct_diff::compatible_child_diff):
Define new member function.
(distinct_diff::chain_into_hierarchy):
Chain the compatible child diff node that might be present.
(distinct_diff::report): Now when a distinct diff carries a
compatible change, mention it in the report.
* src/abg-comp-filter.cc (is_compatible_change): A compatible
change can now involve types that are not typedefs. Only their
sub-types need to be involved with typedef-ness.
* tests/data/test-diff-dwarf/test{2,4,5}-report.txt: Adjust.
* tests/data/test-diff-filter/libtest21-compatible-vars-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest21-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-0.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-report-1.txt Likewise.
* tests/data/test-diff-filter/test21-compatible-vars-v0.cc: Source
code for the first data input binary above.
* tests/data/test-diff-filter/test21-compatible-vars-v1.cc: Source
code for the second data input binary above.
* tests/data/test-diff-filter/libtest22-compatible-fns-v0.so: New
test data input.
* tests/data/test-diff-filter/libtest22-compatible-fns-v1.so Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-report-0.txt:
New test data input.
* tests/data/test-diff-filter/test22-compatible-fns-report-1.txt: Likewise.
* tests/data/test-diff-filter/test22-compatible-fns-v0.c: Source
code for the first test data input binary above.
* tests/data/test-diff-filter/test22-compatible-fns-v1.c: Source
code for the second test data input binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test data
input above to the list of test data this harness has to be run
over.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-10 06:25:01 +00:00
|
|
|
pointer_type_def(const type_base_sptr& pointed_to_type, size_t size_in_bits,
|
2013-08-02 23:30:56 +00:00
|
|
|
size_t alignment_in_bits, location locus);
|
2013-03-28 14:27:15 +00:00
|
|
|
|
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-28 14:27:15 +00:00
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
const type_base_sptr
|
2013-03-28 14:27:15 +00:00
|
|
|
get_pointed_to_type() const;
|
|
|
|
|
2014-02-21 15:10:41 +00:00
|
|
|
virtual void
|
|
|
|
get_qualified_name(string&) const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
virtual const string&
|
|
|
|
get_qualified_name() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-03-28 14:27:15 +00:00
|
|
|
virtual ~pointer_type_def();
|
2013-10-10 08:11:35 +00:00
|
|
|
}; // end class pointer_type_def
|
2013-03-29 14:30:34 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const reference_type_def&, const reference_type_def&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref reference_type_def
|
2013-10-15 07:44:53 +00:00
|
|
|
typedef shared_ptr<reference_type_def> reference_type_def_sptr;
|
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
/// Abstracts a reference type.
|
2013-10-10 08:11:35 +00:00
|
|
|
class reference_type_def : public virtual type_base, public virtual decl_base
|
2013-03-29 14:30:34 +00:00
|
|
|
{
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
type_base_wptr pointed_to_type_;
|
2013-09-26 14:45:00 +00:00
|
|
|
bool is_lvalue_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
// Forbidden.
|
|
|
|
reference_type_def();
|
|
|
|
|
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
|
|
|
|
/// Hasher for intances of reference_type_def.
|
|
|
|
struct hash;
|
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
reference_type_def(const type_base_sptr pointed_to_type,
|
2013-08-02 23:30:56 +00:00
|
|
|
bool lvalue, size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits, location locus);
|
2013-03-29 14:30:34 +00:00
|
|
|
|
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-29 14:30:34 +00:00
|
|
|
|
2015-02-13 19:47:35 +00:00
|
|
|
type_base_sptr
|
2013-03-29 14:30:34 +00:00
|
|
|
get_pointed_to_type() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_lvalue() const;
|
|
|
|
|
2014-02-21 15:10:41 +00:00
|
|
|
virtual void
|
|
|
|
get_qualified_name(string& qualified_name) const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
virtual const string&
|
|
|
|
get_qualified_name() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-03-29 14:30:34 +00:00
|
|
|
virtual ~reference_type_def();
|
2013-10-10 08:11:35 +00:00
|
|
|
}; // end class reference_type_def
|
2013-03-29 14:30:34 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const array_type_def&, const array_type_def&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
Support C and C++ array type.
* include/abg-comparison.h (array_diff): Declare new class.
(array_diff_sptr): Shared pointer to type array_diff.
(compute_diff): Overload the function to take type
array_diff_sptr as the first two arguments.
* include/abg-fwd.h (array_type_def): Declare new class.
(subrange_type): Likewise.
(is_array_def): Declare new function.
* include/abg-ir.h (array_type_def_sptr): Shared pointer
to type array_type_def.
(array_type_def): Declare new class.
(ir_node_visitor::visit): Declare a new virtual function
taking a pointer to type array_type_def as an argument.
* src/abg-comparison.cc (compute_diff_for_types): Add
try_to_diff for two instances of type array_type_def.
(array_diff::priv): declare struct for holding private members
of type array_diff.
(array_diff::array_diff): Define constructor.
(array_diff::{first,second}_array):Define new
member functions.
(array_diff::element_type_diff): Likewise.
(array_diff::{length,report,traverse}): Likewise.
(compute_diff): Define function overloaded in
include/abg-comparison.h.
* src/abg-dwarf-reader.cc (build_array_type): Define new
function. Handle DW_TAG_array_type and DW_TAG_subrange type.
(build_ir_node_from_die): Amend case DW_TAG_array_type with
a call to build_array_type.
* src/abg-hash.cc (array_type_def::hash): Declare new struct.
(type_base::dynamic_hash::operator()): Attempt to dynamic_cast
the argument to type array_type_def as well.
(array_type_def::hash): Declare new struct.
* src/abg-ir.cc (array_type_def::array_type_def): Define
constructors.
(array_type_def::priv): declare struct for holding private members
of type array_type_def.
(array_type_def::operator==(const decl_base&):
Define new operator.
(array_type_def::operator==(const type_base&):
Likewise.
(array_type_def::append_subrange{,s}): Define
new functions.
(array_type_def::{set,get}_size_in_bits): Likewise.
(array_type_def::get_dimension_count): Likewise.
(array_type_def::get_qualified_name): Likewise.
(array_type_def::get_pretty_representation): Likewise.
(array_type_def::get_subrange_representation): Likewise.
(array_type_def::traverse): Likewise.
(array_type_def::get_{element_type,location,subranges}): Likewise.
(array_type_def::is_infinite): Likewise.
(array_type_def::~array_type_def): Define destructor.
(ir_node_visitor::visit): Define function, taking
pointer to array_type_def as an argument.
* src/abg-reader.cc (map_id_and_node): Check if node
is an array.
(is_array_def): Check if object is an array.
(handle_element_node): Handle array_type_def as well.
(build_subrange_type): Define new function.
(build_array_type_def): Likewise.
(build_type): Build type array_type_def as well.
(build_type_composition): Likewise.
(handle_array_type_def): Define new function.
* src/abg-writer.cc: (write_decl): Output arrays
as well.
(write_member_type): Likewise.
(write_type_composition): Likewise.
(write_array_type_def): Define new function.
* tests/data/test-diff-dwarf/test{10,11}-v{0,1}.{cc,o}: New test source
files
* tests/data/test-diff-dwarf/test{10,11}-report.txt: Likewise.
* tests/data/test-diff-dwarf/test10-report.txt: New test input.
* tests/data/test-read-dwarf/test7.cc: New test source
file.
* tests/data/test-read-dwarf/test7.so: New input binary
to read.
* tests/data/test-read-dwarf/test7.so.abi: New reference
test to compare against.
* tests/data/test-read-write/test25.xml: New test source
file.
* tests/test-diff-dwarf.cc: Adjust to launch the new test.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* test/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-18 09:56:43 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref array_type_def
|
|
|
|
typedef shared_ptr<array_type_def> array_type_def_sptr;
|
|
|
|
|
|
|
|
/// The abstraction of an array type.
|
|
|
|
class array_type_def : public virtual type_base, public virtual decl_base
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
|
|
|
// Forbidden.
|
|
|
|
array_type_def();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Hasher for intances of array_type_def.
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
class subrange_type;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer on a @ref
|
|
|
|
/// function_decl::subrange
|
|
|
|
typedef shared_ptr<subrange_type> subrange_sptr;
|
|
|
|
|
|
|
|
/// Convenience typedef for a vector of @ref subrange_sptr
|
|
|
|
typedef std::vector<subrange_sptr> subranges_type;
|
|
|
|
|
|
|
|
/// Abtraction for an array dimension
|
|
|
|
class subrange_type
|
|
|
|
{
|
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
|
|
|
// Forbidden.
|
|
|
|
subrange_type();
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Hasher for an instance of array::subrange
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
subrange_type(size_t lower_bound, size_t upper_bound,
|
|
|
|
location loc);
|
|
|
|
|
|
|
|
subrange_type(size_t upper_bound, location loc);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_upper_bound() const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_lower_bound() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_upper_bound(size_t ub);
|
|
|
|
|
|
|
|
void
|
|
|
|
set_lower_bound(size_t lb);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_length() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_infinite() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const subrange_type& o) const;
|
|
|
|
|
|
|
|
location
|
|
|
|
get_location() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
array_type_def(const type_base_sptr type,
|
|
|
|
const std::vector<subrange_sptr>& subs,
|
|
|
|
location locus);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
get_qualified_name(string& qualified_name) const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
virtual const string&
|
Support C and C++ array type.
* include/abg-comparison.h (array_diff): Declare new class.
(array_diff_sptr): Shared pointer to type array_diff.
(compute_diff): Overload the function to take type
array_diff_sptr as the first two arguments.
* include/abg-fwd.h (array_type_def): Declare new class.
(subrange_type): Likewise.
(is_array_def): Declare new function.
* include/abg-ir.h (array_type_def_sptr): Shared pointer
to type array_type_def.
(array_type_def): Declare new class.
(ir_node_visitor::visit): Declare a new virtual function
taking a pointer to type array_type_def as an argument.
* src/abg-comparison.cc (compute_diff_for_types): Add
try_to_diff for two instances of type array_type_def.
(array_diff::priv): declare struct for holding private members
of type array_diff.
(array_diff::array_diff): Define constructor.
(array_diff::{first,second}_array):Define new
member functions.
(array_diff::element_type_diff): Likewise.
(array_diff::{length,report,traverse}): Likewise.
(compute_diff): Define function overloaded in
include/abg-comparison.h.
* src/abg-dwarf-reader.cc (build_array_type): Define new
function. Handle DW_TAG_array_type and DW_TAG_subrange type.
(build_ir_node_from_die): Amend case DW_TAG_array_type with
a call to build_array_type.
* src/abg-hash.cc (array_type_def::hash): Declare new struct.
(type_base::dynamic_hash::operator()): Attempt to dynamic_cast
the argument to type array_type_def as well.
(array_type_def::hash): Declare new struct.
* src/abg-ir.cc (array_type_def::array_type_def): Define
constructors.
(array_type_def::priv): declare struct for holding private members
of type array_type_def.
(array_type_def::operator==(const decl_base&):
Define new operator.
(array_type_def::operator==(const type_base&):
Likewise.
(array_type_def::append_subrange{,s}): Define
new functions.
(array_type_def::{set,get}_size_in_bits): Likewise.
(array_type_def::get_dimension_count): Likewise.
(array_type_def::get_qualified_name): Likewise.
(array_type_def::get_pretty_representation): Likewise.
(array_type_def::get_subrange_representation): Likewise.
(array_type_def::traverse): Likewise.
(array_type_def::get_{element_type,location,subranges}): Likewise.
(array_type_def::is_infinite): Likewise.
(array_type_def::~array_type_def): Define destructor.
(ir_node_visitor::visit): Define function, taking
pointer to array_type_def as an argument.
* src/abg-reader.cc (map_id_and_node): Check if node
is an array.
(is_array_def): Check if object is an array.
(handle_element_node): Handle array_type_def as well.
(build_subrange_type): Define new function.
(build_array_type_def): Likewise.
(build_type): Build type array_type_def as well.
(build_type_composition): Likewise.
(handle_array_type_def): Define new function.
* src/abg-writer.cc: (write_decl): Output arrays
as well.
(write_member_type): Likewise.
(write_type_composition): Likewise.
(write_array_type_def): Define new function.
* tests/data/test-diff-dwarf/test{10,11}-v{0,1}.{cc,o}: New test source
files
* tests/data/test-diff-dwarf/test{10,11}-report.txt: Likewise.
* tests/data/test-diff-dwarf/test10-report.txt: New test input.
* tests/data/test-read-dwarf/test7.cc: New test source
file.
* tests/data/test-read-dwarf/test7.so: New input binary
to read.
* tests/data/test-read-dwarf/test7.so.abi: New reference
test to compare against.
* tests/data/test-read-write/test25.xml: New test source
file.
* tests/test-diff-dwarf.cc: Adjust to launch the new test.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* test/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-18 09:56:43 +00:00
|
|
|
get_qualified_name() const;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
const type_base_sptr
|
Support C and C++ array type.
* include/abg-comparison.h (array_diff): Declare new class.
(array_diff_sptr): Shared pointer to type array_diff.
(compute_diff): Overload the function to take type
array_diff_sptr as the first two arguments.
* include/abg-fwd.h (array_type_def): Declare new class.
(subrange_type): Likewise.
(is_array_def): Declare new function.
* include/abg-ir.h (array_type_def_sptr): Shared pointer
to type array_type_def.
(array_type_def): Declare new class.
(ir_node_visitor::visit): Declare a new virtual function
taking a pointer to type array_type_def as an argument.
* src/abg-comparison.cc (compute_diff_for_types): Add
try_to_diff for two instances of type array_type_def.
(array_diff::priv): declare struct for holding private members
of type array_diff.
(array_diff::array_diff): Define constructor.
(array_diff::{first,second}_array):Define new
member functions.
(array_diff::element_type_diff): Likewise.
(array_diff::{length,report,traverse}): Likewise.
(compute_diff): Define function overloaded in
include/abg-comparison.h.
* src/abg-dwarf-reader.cc (build_array_type): Define new
function. Handle DW_TAG_array_type and DW_TAG_subrange type.
(build_ir_node_from_die): Amend case DW_TAG_array_type with
a call to build_array_type.
* src/abg-hash.cc (array_type_def::hash): Declare new struct.
(type_base::dynamic_hash::operator()): Attempt to dynamic_cast
the argument to type array_type_def as well.
(array_type_def::hash): Declare new struct.
* src/abg-ir.cc (array_type_def::array_type_def): Define
constructors.
(array_type_def::priv): declare struct for holding private members
of type array_type_def.
(array_type_def::operator==(const decl_base&):
Define new operator.
(array_type_def::operator==(const type_base&):
Likewise.
(array_type_def::append_subrange{,s}): Define
new functions.
(array_type_def::{set,get}_size_in_bits): Likewise.
(array_type_def::get_dimension_count): Likewise.
(array_type_def::get_qualified_name): Likewise.
(array_type_def::get_pretty_representation): Likewise.
(array_type_def::get_subrange_representation): Likewise.
(array_type_def::traverse): Likewise.
(array_type_def::get_{element_type,location,subranges}): Likewise.
(array_type_def::is_infinite): Likewise.
(array_type_def::~array_type_def): Define destructor.
(ir_node_visitor::visit): Define function, taking
pointer to array_type_def as an argument.
* src/abg-reader.cc (map_id_and_node): Check if node
is an array.
(is_array_def): Check if object is an array.
(handle_element_node): Handle array_type_def as well.
(build_subrange_type): Define new function.
(build_array_type_def): Likewise.
(build_type): Build type array_type_def as well.
(build_type_composition): Likewise.
(handle_array_type_def): Define new function.
* src/abg-writer.cc: (write_decl): Output arrays
as well.
(write_member_type): Likewise.
(write_type_composition): Likewise.
(write_array_type_def): Define new function.
* tests/data/test-diff-dwarf/test{10,11}-v{0,1}.{cc,o}: New test source
files
* tests/data/test-diff-dwarf/test{10,11}-report.txt: Likewise.
* tests/data/test-diff-dwarf/test10-report.txt: New test input.
* tests/data/test-read-dwarf/test7.cc: New test source
file.
* tests/data/test-read-dwarf/test7.so: New input binary
to read.
* tests/data/test-read-dwarf/test7.so.abi: New reference
test to compare against.
* tests/data/test-read-write/test25.xml: New test source
file.
* tests/test-diff-dwarf.cc: Adjust to launch the new test.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* test/Makefile.am: Add the new test inputs to the source
distribution.
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-08-18 09:56:43 +00:00
|
|
|
get_element_type() const;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
append_subrange(subrange_sptr sub);
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
append_subranges(const std::vector<subrange_sptr>& subs);
|
|
|
|
|
|
|
|
virtual int
|
|
|
|
get_dimension_count() const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
is_infinite() const;
|
|
|
|
|
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
|
|
|
virtual string
|
|
|
|
get_subrange_representation() const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor& v);
|
|
|
|
|
|
|
|
location
|
|
|
|
get_location() const;
|
|
|
|
|
|
|
|
const std::vector<subrange_sptr>&
|
|
|
|
get_subranges() const;
|
|
|
|
|
|
|
|
virtual ~array_type_def();
|
|
|
|
|
|
|
|
}; // end class array_type_def
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const enum_type_decl&, const enum_type_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
Support diff for enum_type_decl
* include/abg-ir.h (enum_type_decl_sptr): New typedef.
(enum_type_decl::enumerator::enumerator): Make default constructor
public so that enumerators can be stored in vectors. Maybe I
should have made stored pointers to enumerators instead ...
(enum_type_decl::enumerator::get_qualified_name): Define new
method.
* include/abg-comparison.h (string_enumerator_map)
(changed_enumerator, string_changed_enumerator_map)
(enum_diff_sptr): New convenience typedefs.
(class enum_diff): Declare new class.
(compute_diff): New overload for enum_type_decl.
* src/abg-comparison.cc (enum diff_kind, report_mem_header): Move
these at the beginning of the file.
(struct enum_diff::priv): Define this.
(enum_diff::{clear_lookup_tables, lookup_tables_empty,
ensure_lookup_tables_populated, enum_diff, first_enum,
second_enum, underlying_type_diff, deleted_enumerators,
inserted_enumerators, changed_enumerators, length, report}):
Define these new methods.
(compute_diff): New overload for enum_diff.
(compute_diff_for_types): Add support enum_type_decl here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-27 10:47:19 +00:00
|
|
|
/// Convenience typedef for shared pointer on enum_type_decl.
|
|
|
|
typedef shared_ptr<enum_type_decl> enum_type_decl_sptr;
|
|
|
|
|
2013-03-30 18:02:51 +00:00
|
|
|
/// Abstracts a declaration for an enum type.
|
2013-10-10 08:11:35 +00:00
|
|
|
class enum_type_decl : public virtual type_base, public virtual decl_base
|
2013-03-30 18:02:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
|
|
|
|
/// A hasher for an enum_type_decl.
|
|
|
|
struct hash;
|
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
/// Enumerator Datum.
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
class enumerator;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a list of @ref enumerator.
|
2013-11-26 08:30:22 +00:00
|
|
|
typedef std::vector<enumerator> enumerators;
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
private:
|
2013-03-30 18:02:51 +00:00
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
|
|
|
// Forbidden
|
|
|
|
enum_type_decl();
|
|
|
|
|
|
|
|
public:
|
2013-03-30 18:02:51 +00:00
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
/// Constructor of an enum type declaration.
|
|
|
|
///
|
|
|
|
/// @param name the name of the enum
|
|
|
|
///
|
|
|
|
/// @param locus the locus at which the enum appears in the source
|
|
|
|
/// code.
|
|
|
|
///
|
|
|
|
/// @param underlying_type the underlying type of the enum
|
|
|
|
///
|
2014-01-17 14:42:47 +00:00
|
|
|
/// @param enms a list of enumerators for this enum.
|
|
|
|
///
|
|
|
|
/// @param mangled_name the mangled name of the enum type.
|
|
|
|
///
|
|
|
|
/// @param vis the visibility of instances of this type.
|
2013-11-20 09:54:15 +00:00
|
|
|
enum_type_decl(const string& name, location locus,
|
|
|
|
type_base_sptr underlying_type,
|
2013-08-06 17:18:35 +00:00
|
|
|
enumerators& enms, const std::string& mangled_name = "",
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-30 18:02:51 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
type_base_sptr
|
2013-03-30 18:02:51 +00:00
|
|
|
get_underlying_type() const;
|
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const enumerators&
|
2013-03-30 18:02:51 +00:00
|
|
|
get_enumerators() const;
|
|
|
|
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
enumerators&
|
|
|
|
get_enumerators();
|
|
|
|
|
2013-11-28 13:58:11 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
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 12:24:08 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-30 18:02:51 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-03-30 18:02:51 +00:00
|
|
|
virtual ~enum_type_decl();
|
2013-10-10 08:11:35 +00:00
|
|
|
}; // end class enum_type_decl
|
2013-03-30 18:02:51 +00:00
|
|
|
|
2015-03-13 11:54:25 +00:00
|
|
|
bool
|
|
|
|
operator==(enum_type_decl_sptr l, enum_type_decl_sptr r);
|
Make overloads of decl_base::get_qualified_name() return a reference
* incude/abg-ir.h (decl::get_{qualified_name,
qualified_parent_name}): Return a reference to a string rather
than a copy of a string.
(qualified_type_def::get_qualified_name): Likewise.
(reference_type_def::get_qualified_name): Likewise.
(array_type_def::get_qualified_name): Likewise.
(class enum_type_decl::enumerator): Make this is an out-of-line
pimpled class implementation.
(enum_type_decl::enumerator::{get, set}_enum_type): Declare new
method.
(enum_type_decl::enumerator::get_qualified_name): Change this so
that it doesn't take the name of the enum type anymore.
* src/abg-comparison.cc (enum_diff::report): Adjust for
enum_type_decl::enumerator::get_qualified_name() not taking the
name of the enum type anymore.
* src/abg-ir.cc (decl_base::get_qualified_parent_name): Return a
reference to string.
(decl_base::get_qualified_name): Likewise.
(decl_base::get_qualified_name(string&)): Use the new verson of
decl_base::get_qualified_name() that returns a reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name()): Return a string reference.
({qualified_type_def, pointer_type_def, reference_type_def,
array_type_def}::get_qualified_name(string& qualified_name)
const): Use the new qualified_type_def::get_qualified_name() that
returns a string reference.
(class enum_type_decl::priv): New type.
(enum_type_decl::{get_underlying_type, get_enumerators}): Adjust.
(enum_type_decl::{enumerator::enumerator, enumerator::operator==,
enumerator::get_name, enumerator::get_qualified_name,
enumerator::set_name, enumerator::get_value,
enumerator::set_value, enumerator::get_enum_type,
enumerator::set_enum_type}): Define methodes out-of-line here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-09 13:29:25 +00:00
|
|
|
/// The abstraction of an enumerator
|
|
|
|
class enum_type_decl::enumerator
|
|
|
|
{
|
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enumerator();
|
|
|
|
|
|
|
|
enumerator(const string& name, size_t value);
|
|
|
|
|
|
|
|
enumerator(const enumerator&);
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const enumerator& other) const;
|
|
|
|
|
|
|
|
const string&
|
|
|
|
get_name() const;
|
|
|
|
|
|
|
|
const string&
|
|
|
|
get_qualified_name() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_name(const string& n);
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_value() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_value(size_t v);
|
|
|
|
|
|
|
|
enum_type_decl*
|
|
|
|
get_enum_type() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_enum_type(enum_type_decl*);
|
|
|
|
}; // end class enum_type_def::enumerator
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const typedef_decl&, const typedef_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref typedef_decl.
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
typedef shared_ptr<typedef_decl> typedef_decl_sptr;
|
|
|
|
|
2013-03-30 20:51:43 +00:00
|
|
|
/// The abstraction of a typedef declaration.
|
2013-10-10 08:11:35 +00:00
|
|
|
class typedef_decl : public virtual type_base, public virtual decl_base
|
2013-03-30 20:51:43 +00:00
|
|
|
{
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
type_base_wptr underlying_type_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-03-30 20:51:43 +00:00
|
|
|
// Forbidden
|
|
|
|
typedef_decl();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for the typedef_decl type.
|
|
|
|
struct hash;
|
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
typedef_decl(const string& name, const shared_ptr<type_base> underlying_type,
|
2013-09-26 14:45:00 +00:00
|
|
|
location locus, const std::string& mangled_name = "",
|
2013-08-02 23:30:56 +00:00
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-03-30 20:51:43 +00:00
|
|
|
|
Make type_base::get_{size,alignment}_in_bits virtual
* include/abg-ir.h (type_base::get_{size,alignment}_in_bits): Make
this virtual.
(typedef_decl::get_{size,alignment}_in_bits): Add new member
functions. Get the size,alignment from the underlying type and
update the current size/alignment if they differ. Keep in mind
that the size of an underlying class_decl can change over its
lifetime, given how the dwarf reader reads the type information,
i.e, there can be a DIE for a class type with no size information
that will lead to the creation of a class_decl with size zero.
Later during the DWARF reading process, another DIE will
supplement the type information, adding size information to that
class_decl. In between, a typedef_decl might have been created
with the first version of the class_decl that has a zero size. I
guess this should be extended to the other type constructs that
have an underlying type (qualified types, references and pointers).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-07 08:08:10 +00:00
|
|
|
virtual size_t
|
|
|
|
get_size_in_bits() const;
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
get_alignment_in_bits() const;
|
|
|
|
|
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 12:24:08 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-03-30 20:51:43 +00:00
|
|
|
|
Add diff support for typedef_decl and type_decl
* include/abg-ir.h (operator<<(std::ostream&,
decl_base::visibility)): Declare new streaming operator.
* src/abg-ir.cc (operator<<(std::ostream&,
decl_base::visibility)): Define it.
(type_decl::{operator==, get_pretty_representation}): Likewise,
define these new overloads.
(decl_base::{operator==, get_pretty_representation}): New overloads.
* include/abg-comparison.h (type_decl_diff type_decl_diff_sptr,
typedef_diff, typedef_diff_sptr): Declare new classes and
typedefs.
* src/abg-comparison.cc (type_decl_diff::{type_decl_diff,
first_type_decl, second_type_decl, length, report}): New methods
definitions.
(compute_diff): New function definition that takes pointers of
type_decl.
(typedef_diff::{typedef_diff, first_typedef_decl,
second_typedef_decl, underlying_type_diff, length, report}): New
methods.
(compute_diff): New function definition that takes pointers of
typedef_decl.
(try_to_diff_types): New template function, factorized out of ...
(compute_diff_for_types): ... this. Add support diffing type_decl
and typedef_decl.
(pointer_diff::report): Fix indentation of emitted report.
* tools/bidiff.cc (parse_command_line): Fix style.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:58:56 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
2015-02-13 19:47:35 +00:00
|
|
|
type_base_sptr
|
2013-03-30 20:51:43 +00:00
|
|
|
get_underlying_type() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
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-20 10:30:04 +00:00
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
2013-03-30 20:51:43 +00:00
|
|
|
virtual ~typedef_decl();
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
};// end class typedef_decl
|
2013-03-30 20:51:43 +00:00
|
|
|
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
class dm_context_rel;
|
|
|
|
|
|
|
|
/// A convenience typedef for a shared pointer to dm_context_rel.
|
|
|
|
typedef shared_ptr<dm_context_rel> dm_context_rel_sptr;
|
|
|
|
|
|
|
|
/// The abstraction for a data member context relationship. This
|
|
|
|
/// relates a data member to its parent class.
|
|
|
|
///
|
|
|
|
/// The relationship carries properties like the offset of the data
|
|
|
|
/// member, if applicable.
|
|
|
|
class dm_context_rel : public context_rel
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
bool is_laid_out_;
|
|
|
|
size_t offset_in_bits_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
dm_context_rel()
|
|
|
|
: context_rel(),
|
|
|
|
is_laid_out_(!is_static_),
|
|
|
|
offset_in_bits_(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
dm_context_rel(scope_decl* s,
|
|
|
|
bool is_laid_out,
|
|
|
|
size_t offset_in_bits,
|
|
|
|
access_specifier a,
|
|
|
|
bool is_static)
|
|
|
|
: context_rel(s, a, is_static),
|
|
|
|
is_laid_out_(is_laid_out),
|
|
|
|
offset_in_bits_(offset_in_bits)
|
|
|
|
{}
|
|
|
|
|
|
|
|
dm_context_rel(scope_decl* s)
|
|
|
|
: context_rel(s),
|
|
|
|
is_laid_out_(!is_static_),
|
|
|
|
offset_in_bits_(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool
|
|
|
|
get_is_laid_out() const
|
|
|
|
{return is_laid_out_;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_is_laid_out(bool f)
|
|
|
|
{is_laid_out_ = f;}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
get_offset_in_bits() const
|
|
|
|
{return offset_in_bits_;}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_offset_in_bits(size_t o)
|
|
|
|
{offset_in_bits_ = o;}
|
|
|
|
|
|
|
|
bool
|
2014-10-13 09:46:45 +00:00
|
|
|
operator==(const dm_context_rel& o) const
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
{
|
|
|
|
if (!context_rel::operator==(o))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return (is_laid_out_ == o.is_laid_out_
|
|
|
|
&& offset_in_bits_ == o.offset_in_bits_);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~dm_context_rel();
|
|
|
|
};// end class class_decl::dm_context_rel
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const var_decl&, const var_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref var_decl
|
2013-10-16 20:01:28 +00:00
|
|
|
typedef shared_ptr<var_decl> var_decl_sptr;
|
|
|
|
|
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 12:24:08 +00:00
|
|
|
/// Abstracts a variable declaration.
|
2013-08-06 22:28:56 +00:00
|
|
|
class var_decl : public virtual decl_base
|
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 12:24:08 +00:00
|
|
|
{
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
struct priv;
|
|
|
|
shared_ptr<priv> priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
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 12:24:08 +00:00
|
|
|
// Forbidden
|
|
|
|
var_decl();
|
|
|
|
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
virtual void
|
|
|
|
set_scope(scope_decl*);
|
|
|
|
|
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 12:24:08 +00:00
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for a var_decl type.
|
|
|
|
struct hash;
|
|
|
|
|
2014-02-07 11:14:38 +00:00
|
|
|
/// Equality functor to compare pointers to variable_decl.
|
|
|
|
struct ptr_equal;
|
|
|
|
|
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 12:24:08 +00:00
|
|
|
var_decl(const std::string& name,
|
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-04-11 20:02:08 +00:00
|
|
|
shared_ptr<type_base> type,
|
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 12:24:08 +00:00
|
|
|
location locus,
|
|
|
|
const std::string& mangled_name,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_NONE);
|
|
|
|
|
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
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 12:24:08 +00:00
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
const type_base_sptr
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
get_type() const;
|
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 12:24:08 +00:00
|
|
|
|
|
|
|
binding
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
get_binding() const;
|
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 12:24:08 +00:00
|
|
|
|
|
|
|
void
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
set_binding(binding b);
|
|
|
|
|
|
|
|
void
|
|
|
|
set_symbol(elf_symbol_sptr sym);
|
|
|
|
|
|
|
|
elf_symbol_sptr
|
|
|
|
get_symbol() const;
|
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 12:24:08 +00:00
|
|
|
|
2014-05-20 16:22:14 +00:00
|
|
|
var_decl_sptr
|
|
|
|
clone() const;
|
|
|
|
|
Build the set of exported decls directly during DWARF loading
Until now, after the ABI corpus was built from DWARF, the translation
units of the corpus were walked and each function was considered for
addition into the set of exported decls. During that walking, a first
version of the set was put into a std::list and then, a set of filters
(user-provided tunables like a list of regular expressions to keep or
remove some functions from the exported decls) is applied to that list
and the final set of exported decls is put in a std::vector.
Profiling has shown that this process of building the set of exported
decls is a hot spot and also that the current use of std::list was a
big memory consumer especially on binaries with large exported symbol
tables.
So this patch builds the set of exported decls "on the fly", during
DWARF reading, as opposed to waiting after the DWARF is read and
having to walk the corpus again. The corpus defines a policy object
that encapsulates the methods for determining if a function or
variable ought to be part of the set of exported decls. The DWARF
reader uses that policy object to determine which functions and
variables among those built during the reading ought be part of the
exported decls; the policy object also has a reference to the final
vector (managed by the corpus) that must hold the exported decls, so
the decls are put in that vector directly without unnecessary copying.
Profiling also showed that the string copying done by
{var_decl,function_decl}::get_id() was a hot spot. So the patch
returns a reference there.
With this patch applied, the peak memory consumption of abidiff on
libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of
resident and takes 2 minutes and 16s (on my slow system). Without the
patch the peak consumption was more than 300MB and it was taking
slightly longer.
For the test of bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory
consumtion and wall clock time spent is down from 3.4GB and 1m59s to
760MB and 0m43s.
* include/abg-ir.h ({var,function}_decl::get_id): Return a
reference.
* src/abg-ir.cc ({var,function}_decl::get_id): Return a reference
to the string rather than copying it over.
* include/abg-corpus.h (class corpus::exported_decls_builder):
Declare new type.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Declare new methods.
* src/abg-corpus.h (corpus::exported_decls_builder::priv): Define
new type.
(class symtab_build_visitor_type): Remove this type that is
useless now.
(corpus::exported_decls_builder::{exported_decls_builder,
exported_functions, exported_variables,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new functions.
(corpus::priv::is_public_decl_table_built): Remove this data
member. It's now useless.
(corpus::priv::priv): Adjust.
(corpus::priv::build_public_decl_table): Remove this member
function. It's now useless.
(corpus::{priv::build_unreferenced_symbols_tables, get_functions,
get_variables}): No need to build the public decls table here.
It's already built by the time the corpus is read from DWARF now.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Define new member functions.
* src/abg-dwarf-reader.cc (read_context::exported_decls_builder):
New data member.
(read_context::read_context): Initialize it.
(read_context::{exported_decls_builder,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new member functions.
(read_debug_info_into_corpus): Get the the new
'exported_decls_builder' object from the corpus and stick it into
the read context so the DWARF reading code can use it to build the
exported decls set. When the DWARF reading is done, sort the set
of exported functions and variables that was built.
(build_ir_node_from_die): When a function or variable is built,
consider putting it into the set of exported decls.
* tools/abicompat.cc (main): Now that the exported decls is built
*before* we had a chance to stick the list of symbol IDs to keep,
call corpus::maybe_drop_some_exported_decls() to update the set of
exported decls we should consider for the corpus.
was applied to that list and the final
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
|
|
|
const string&
|
2014-08-26 12:37:14 +00:00
|
|
|
get_id() const;
|
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
2013-10-24 06:21:07 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
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 12:24:08 +00:00
|
|
|
virtual ~var_decl();
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
|
|
|
|
friend void
|
|
|
|
set_data_member_offset(var_decl_sptr m, size_t o);
|
|
|
|
|
|
|
|
friend size_t
|
|
|
|
get_data_member_offset(const var_decl_sptr m);
|
|
|
|
|
|
|
|
friend size_t
|
|
|
|
get_data_member_offset(const var_decl& m);
|
|
|
|
|
|
|
|
friend void
|
|
|
|
set_data_member_is_laid_out(var_decl_sptr m, bool l);
|
|
|
|
|
|
|
|
friend bool
|
|
|
|
get_data_member_is_laid_out(const var_decl& m);
|
|
|
|
|
|
|
|
friend bool
|
|
|
|
get_data_member_is_laid_out(const var_decl_sptr m);
|
2013-10-10 08:11:35 +00:00
|
|
|
}; // end class var_decl
|
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 12:24:08 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const function_decl&, const function_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref function_decl
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
typedef shared_ptr<function_decl> function_decl_sptr;
|
|
|
|
|
2013-04-03 22:16:29 +00:00
|
|
|
/// Abstraction for a function declaration.
|
2013-08-06 22:28:56 +00:00
|
|
|
class function_decl : public virtual decl_base
|
2013-04-03 22:16:29 +00:00
|
|
|
{
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
struct priv;
|
|
|
|
shared_ptr<priv> priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-04-03 22:16:29 +00:00
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for function_decl
|
|
|
|
struct hash;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
2014-02-07 11:14:38 +00:00
|
|
|
/// Equality functor to compare pointers to function_decl
|
|
|
|
struct ptr_equal;
|
|
|
|
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
class parameter;
|
2013-11-20 09:54:15 +00:00
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer on a @ref
|
|
|
|
/// function_decl::parameter
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
typedef shared_ptr<parameter> parameter_sptr;
|
2013-11-20 09:54:15 +00:00
|
|
|
|
|
|
|
/// Convenience typedef for a vector of @ref parameter_sptr
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
typedef std::vector<parameter_sptr> parameters;
|
|
|
|
|
2013-04-03 22:16:29 +00:00
|
|
|
/// Abtraction for the parameter of a function.
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
class parameter;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
function_decl(const std::string& name,
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
function_type_sptr function_type,
|
|
|
|
bool declared_inline,
|
|
|
|
location locus,
|
|
|
|
const std::string& mangled_name,
|
|
|
|
visibility vis,
|
|
|
|
binding bind);
|
2013-04-03 22:16:29 +00:00
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
function_decl(const std::string& name,
|
|
|
|
shared_ptr<type_base> fn_type,
|
|
|
|
bool declared_inline,
|
|
|
|
location locus,
|
|
|
|
const std::string& mangled_name = "",
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_GLOBAL);
|
|
|
|
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
Sort functions & variables diff nodes in the diff tree
Since the work on un-sharing diff tree nodes, it looks like some
reports of regression tests on i686 order functions and variables in
different orders, leading to test failures on 32 bits platforms
because they are different fromthe 64 bits platforms that we use as a
reference. This patch sorts (lexicographically) the children diff
nodes of a given diff node in general, and also sorts the set of diff
nodes for functions and variables that have sub-type changes, in a
given corpus_diff. That way, the result of the diff report should be
sorted the same way, whatever the platform.
* include/abg-comparison.h (function_decl_diff_sptrs_type)
(var_diff_sptrs_type): New typedefs.
(corpus_diff::{changed_functions, changed_variables}): Declare new
methods.
* src/abg-comparison.cc (sort_string_function_decl_diff_sptr_map)
(sort_string_var_diff_sptr_map): Forward declare these static
functions there were already defined later.
(struct diff_less_than_functor): Define new comparison functor.
(diff::append_child_node): Sort the children diff nodes of a given
diff node.
(corpus_diff::priv::changed_fns_map_): Renamed the data member
corpus_diff::priv::changed_fns_ into this.
(corpus_diff::priv::changed_fns_): New data member that is a
sorted vector of changed functions.
(corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables}):
Adjust changed_fns_ -> changed_fns_map_ and changed_vars_ ->
changed_vars_map_.
(corpus_diff::priv::ensure_lookup_tables_populated): Likewise.
Sort the changed functions and changed variables.
(corpus_diff::priv::apply_filters_and_compute_diff_stats): Adjust
changed_fns_ -> changed_fns_map_ and changed_vars_ ->
changed_vars_map_. Also, walk the changed functions and variables
diff nodes in their sorted order.
(corpus_diff::priv::{categorize_redundant_changed_sub_nodes,
clear_redundancy_categorization, maybe_dump_diff_tree}): Walk the
changed functions and variables diff nodes in their sorted order.
* include/abg-ir.h
(function_decl::get_pretty_representation_of_declarator):
Declarenew method.
* src/abg-ir.cc
(function_decl::get_pretty_representation_of_declarator): Define
new function. Its content got split out of ...
(function_decl::get_pretty_representation): ... this one.
* src/abg-comparison.cc (corpus_diff::chain_into_hierarchy):
Consider the sorted the children nodes of a diff tree node.
(corpus_diff::append_child_node): Keep the children nodes of a
diff tree node sorted.
(corpus_diff::{changed_functions, changed_variables, length,
report}): Adjust.
(corpus_diff::{changed_functions_sorted,
changed_variables_sorted}): Define new functions.
(function_comp::operator()): First compare the qualified function
names along with the parameter declarations, then the rest.
(sort_string_function_decl_diff_sptr_map)
(sort_string_var_diff_sptr_map): Adjust.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-01-09 13:45:11 +00:00
|
|
|
string
|
|
|
|
get_pretty_representation_of_declarator () const;
|
|
|
|
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
const std::vector<parameter_sptr >&
|
2013-06-01 13:41:59 +00:00
|
|
|
get_parameters() const;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
|
|
|
void
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
append_parameter(parameter_sptr parm);
|
2013-04-03 22:16:29 +00:00
|
|
|
|
|
|
|
void
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
append_parameters(std::vector<parameter_sptr >& parms);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2014-03-18 10:27:02 +00:00
|
|
|
parameters::const_iterator
|
|
|
|
get_first_non_implicit_parm() const;
|
|
|
|
|
2014-10-27 19:45:32 +00:00
|
|
|
const function_type_sptr
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
get_type() const;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
2015-02-13 19:47:35 +00:00
|
|
|
const type_base_sptr
|
2013-06-01 13:41:59 +00:00
|
|
|
get_return_type() const;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
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-04-23 09:27:32 +00:00
|
|
|
void
|
2015-02-13 19:47:35 +00:00
|
|
|
set_type(function_type_sptr fn_type);
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
set_symbol(elf_symbol_sptr sym);
|
|
|
|
|
|
|
|
elf_symbol_sptr
|
|
|
|
get_symbol() const;
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-04-03 22:16:29 +00:00
|
|
|
bool
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
is_declared_inline() const;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
|
|
|
binding
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
get_binding() const;
|
2013-04-03 22:16:29 +00:00
|
|
|
|
2014-05-20 16:22:14 +00:00
|
|
|
function_decl_sptr
|
|
|
|
clone() const;
|
|
|
|
|
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-04-11 20:02:08 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base& o) const;
|
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-04-11 20:02:08 +00:00
|
|
|
|
2013-06-01 13:41:59 +00:00
|
|
|
/// Return true iff the function takes a variable number of
|
|
|
|
/// parameters.
|
|
|
|
///
|
2013-08-02 03:16:22 +00:00
|
|
|
/// @return true if the function taks a variable number
|
2013-06-01 13:41:59 +00:00
|
|
|
/// of parameters.
|
|
|
|
bool
|
Initial support for elf symbol (versionning) during decl comparison
* include/abg-fwd.h (get_linkage_name): Remove.
* include/abg-dwarf-reader.h (enum symbol_type)
(enum symbol_binding): Move these into abg-ir.h.
(lookup_symbol_from_elf, lookup_public_function_symbol_from_elf):
Adjust.
* src/abg-dwarf-reader.cc (eval_last_constant_dwarf_sub_expr):
Declare this before using it.
(die_address_attribute, die_location_address)
(stt_to_elf_symbol_type, stb_to_elf_symbol_binding)
(find_hash_table_section_index, find_symbol_table_section)
(find_symbol_table_section_index, find_text_section)
(find_bss_section, compare_symbol_name)
(get_symbol_versionning_sections get_version_for_symbol)
(lookup_symbol_from_sysv_hash_tab)
(lookup_symbol_from_gnu_hash_tab, get_elf_class_size_in_bytes)
(bloom_word_at, setup_gnu_ht, lookup_symbol_from_elf_hash_tab)
(lookup_symbol_from_symtab, maybe_adjust_fn_sym_address)
(maybe_adjust_var_sym_address): New static functions.
(enum hash_table_kind): New enum.
(struct gnu_ht): New struct.
(read_context::var_decls_to_add_): Renamed var_decls_to_add into
this.
(read_context::{fun, var}_sym_addr_sym_index_map_): New member.
(read_context::{lookup_symbol_from_elf,
lookup_elf_symbol_from_index, lookup_elf_fn_symbol_from_address,
lookup_elf_var_symbol_from_address, fun_sym_addr_sym_index_map,
var_sym_addr_sym_index_map, load_symbol_addr_to_index_maps,
get_function_address, get_variable_address}): New member
functions.
(read_context::lookup_public_{variable,
function}_symbol_from_elf): Adjust.
(op_pushes_constant_value): Fix a bug here.
(lookup_symbol_from_elf): Adjust. Support cases where there is no
elf hash table, e.g, for relocatable files.
(lookup_public_function_symbol_from_elf)
(lookup_public_variable_symbol_from_elf): Adjust.
(build_var_decl): Allow updating the var_decl to associate it with
its underlying symbol. In that case, if the linkage name is not
set, set it to the symbol name.
(build_function_decl): Likewise for function_decl.
(operator<<(std::ostream&, symbol_type)):
(operator<<(std::ostream&, symbol_binding)): Move these do
abg-ir.cc.
* include/abg-ir.h (class elf_symbol): Declare new class. Move
enum symbol_binding and enum symbol_type (from abg-dwarf-reader.h) to
elf_symbol::binding and elf_symbol::type here.
(operator<<(std::ostream&, elf_symbol::type))
(operator<<(std::ostream&, elf_symbol::binding))
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New
operators.
(class elf_symbol::version): Declare new class.
(class var_decl): Make this pimpl, and add ...
(var_decl::{g,s}et_symbol): ... new member functions.
(class function_decl): Likewise, make this pimpl and add ...
(function_decl::{g,s}et_symbol): ... new member functions.
* src/abg-ir.cc (struct elf_symbol, elf_symbol::priv): New
types.
(elf_symbol::*): Lots of new members and member functions.
(operator==(const elf_symbol_sptr, const elf_symbol_sptr)): New.
(operator<<(std::ostream&, elf_symbol::type)): New.
(operator<<(std::ostream&, elf_symbol::binding)): New.
(elf_symbol::version::priv): New type.
(elf_symbol::version::*): Lots of member functions.
(get_linkage_name): Removed.
(var_decl::priv): New type. Pimplify the thing.
(var_decl::{s,g}et_symbol): New.
(var_decl::operator==): Take symbols in account in the comparison.
(function_decl::priv): New type.
(function_decl::*): Pimplify.
(function_decl::{s,g}et_symbol): New.
(function_decl::operator==): Take symbols in account in the
comparison.
* include/abg-comparison.h (diff_context::show_linkage_name): New
member function.
* src/abg-comparison.cc (diff_context::priv::show_linkage_name_):
New member.
(diff_context::priv::priv): Initialize it.
(diff_context::show_linkage_names): New member function.
(corpus_diff::report): If the user used --show-linkage-names,
display the linkage name after the name of the functions. Add
missing "'" in the some spots.
* tools/bidiff.cc (options.show_linkage_names): New member.
(display_usage, parse_command_line): Support --linkage-names.
* tools/bisym.cc (show_help): Add '\n' at the end of help string
for --demangle. Add --no-absolute-path option.
(parse_command_line): Support --no-absolute-path.
(main): Adjust for symbol (versionning) support. Consider that
the program successfully completed even when the symbol wasn't
found. Support --no-absolute-path.
* tests/data/test-lookup-syms/test0-report.txt: New.
* tests/data/test-lookup-syms/test01-report.txt: New.
* tests/data/test-lookup-syms/test02-report.txt: New.
* tests/data/test-read-dwarf/test0.abi: Adjust.
* tests/data/test-read-dwarf/test1.abi: Adjust.
* tests/data/test-diff-dwarf/test7-report.txt: Adjust.
* tests/data/test-diff-filter/test10-report.txt: Adjust.
* tests/data/test-diff-filter/test12-report.txt: Adjust.
* tests/data/test-lookup-syms/test1-[123]-report.txt: New.
* tests/data/test-lookup-syms/test1.c: New.
* tests/data/test-lookup-syms/test1.version-script: New.
* tests/test-lookup-syms.cc: Adjust for new tests.
* test/Makefile.am: Adjust makefile.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-05-08 09:31:57 +00:00
|
|
|
is_variadic() const;
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2014-04-08 13:56:18 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
Build the set of exported decls directly during DWARF loading
Until now, after the ABI corpus was built from DWARF, the translation
units of the corpus were walked and each function was considered for
addition into the set of exported decls. During that walking, a first
version of the set was put into a std::list and then, a set of filters
(user-provided tunables like a list of regular expressions to keep or
remove some functions from the exported decls) is applied to that list
and the final set of exported decls is put in a std::vector.
Profiling has shown that this process of building the set of exported
decls is a hot spot and also that the current use of std::list was a
big memory consumer especially on binaries with large exported symbol
tables.
So this patch builds the set of exported decls "on the fly", during
DWARF reading, as opposed to waiting after the DWARF is read and
having to walk the corpus again. The corpus defines a policy object
that encapsulates the methods for determining if a function or
variable ought to be part of the set of exported decls. The DWARF
reader uses that policy object to determine which functions and
variables among those built during the reading ought be part of the
exported decls; the policy object also has a reference to the final
vector (managed by the corpus) that must hold the exported decls, so
the decls are put in that vector directly without unnecessary copying.
Profiling also showed that the string copying done by
{var_decl,function_decl}::get_id() was a hot spot. So the patch
returns a reference there.
With this patch applied, the peak memory consumption of abidiff on
libabigail.so itself (abidiff libabigail.so libabigail.so) is 54MB of
resident and takes 2 minutes and 16s (on my slow system). Without the
patch the peak consumption was more than 300MB and it was taking
slightly longer.
For the test of bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17948, memory
consumtion and wall clock time spent is down from 3.4GB and 1m59s to
760MB and 0m43s.
* include/abg-ir.h ({var,function}_decl::get_id): Return a
reference.
* src/abg-ir.cc ({var,function}_decl::get_id): Return a reference
to the string rather than copying it over.
* include/abg-corpus.h (class corpus::exported_decls_builder):
Declare new type.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Declare new methods.
* src/abg-corpus.h (corpus::exported_decls_builder::priv): Define
new type.
(class symtab_build_visitor_type): Remove this type that is
useless now.
(corpus::exported_decls_builder::{exported_decls_builder,
exported_functions, exported_variables,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new functions.
(corpus::priv::is_public_decl_table_built): Remove this data
member. It's now useless.
(corpus::priv::priv): Adjust.
(corpus::priv::build_public_decl_table): Remove this member
function. It's now useless.
(corpus::{priv::build_unreferenced_symbols_tables, get_functions,
get_variables}): No need to build the public decls table here.
It's already built by the time the corpus is read from DWARF now.
(corpus::{sort_functions, sort_variables,
maybe_drop_some_exported_decls, get_exported_decls_builder}):
Define new member functions.
* src/abg-dwarf-reader.cc (read_context::exported_decls_builder):
New data member.
(read_context::read_context): Initialize it.
(read_context::{exported_decls_builder,
maybe_add_fn_to_exported_fns, maybe_add_var_to_exported_vars}):
Define new member functions.
(read_debug_info_into_corpus): Get the the new
'exported_decls_builder' object from the corpus and stick it into
the read context so the DWARF reading code can use it to build the
exported decls set. When the DWARF reading is done, sort the set
of exported functions and variables that was built.
(build_ir_node_from_die): When a function or variable is built,
consider putting it into the set of exported decls.
* tools/abicompat.cc (main): Now that the exported decls is built
*before* we had a chance to stick the list of symbol IDs to keep,
call corpus::maybe_drop_some_exported_decls() to update the set of
exported decls we should consider for the corpus.
was applied to that list and the final
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-23 19:39:32 +00:00
|
|
|
const string&
|
2014-08-26 12:37:14 +00:00
|
|
|
get_id() const;
|
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
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-20 10:30:04 +00:00
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
2013-04-03 22:16:29 +00:00
|
|
|
virtual ~function_decl();
|
2014-02-07 19:18:11 +00:00
|
|
|
}; // end class function_decl
|
2013-04-03 22:16:29 +00:00
|
|
|
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
bool
|
|
|
|
equals(const function_decl::parameter&,
|
|
|
|
const function_decl::parameter&,
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
change_kind*);
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
|
|
|
|
/// Abstraction of a function parameter.
|
|
|
|
class function_decl::parameter : public decl_base
|
|
|
|
{
|
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Hasher for an instance of function::parameter
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
parameter(const type_base_sptr type,
|
|
|
|
unsigned index,
|
|
|
|
const std::string& name,
|
|
|
|
location loc,
|
|
|
|
bool variadic_marker = false);
|
|
|
|
|
|
|
|
parameter(const type_base_sptr type,
|
|
|
|
unsigned index,
|
|
|
|
const std::string& name,
|
|
|
|
location loc,
|
|
|
|
bool variadic_marker,
|
|
|
|
bool is_artificial);
|
|
|
|
|
|
|
|
parameter(const type_base_sptr type,
|
|
|
|
const std::string& name,
|
|
|
|
location loc,
|
|
|
|
bool variadic_marker = false,
|
|
|
|
bool is_artificial = false);
|
|
|
|
|
|
|
|
parameter(const type_base_sptr type,
|
|
|
|
unsigned index = 0,
|
|
|
|
bool variadic_marker = false);
|
|
|
|
|
|
|
|
const type_base_sptr
|
|
|
|
get_type()const;
|
|
|
|
|
|
|
|
const string
|
|
|
|
get_type_name() const;
|
|
|
|
|
|
|
|
const string
|
|
|
|
get_type_pretty_representation() const;
|
|
|
|
|
|
|
|
const string
|
|
|
|
get_name_id() const;
|
|
|
|
|
|
|
|
unsigned
|
|
|
|
get_index() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_index(unsigned i);
|
|
|
|
|
|
|
|
bool
|
|
|
|
get_artificial() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_artificial(bool f);
|
|
|
|
|
|
|
|
bool
|
|
|
|
get_variadic_marker() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
operator==(const parameter& o) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor& v);
|
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
get_qualified_name(string& qualified_name) const;
|
2015-05-06 08:13:02 +00:00
|
|
|
|
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
}; // end class function_decl::parameter
|
|
|
|
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
bool
|
|
|
|
operator==(const function_decl::parameter_sptr&,
|
|
|
|
const function_decl::parameter_sptr&);
|
|
|
|
|
Un-share diff nodes in the comparison IR
Until now, the diff nodes of the comparison IR were shared. That is,
two diffs about the same subjects were represented by the same diff
node that would appear twice in the tree.
This was preventing us from spotting e.g, the first occurrence of a
diff node that would later (in the tree) turn to be redundant because
all redundant diff nodes are represented by the same diff node
pointer.
This patch now makes each diff node be different, as far of pointer
comparison is concerned. But it introduces the concept of canonical
diff node to ease the comparison between two diff nodes. Two diff
nodes that are equal have the same canonical diff node.
With this facility, it's now possible to tell the difference between
diff nodes that are (structurally) equal. It's not possible to say
things like "this is the first or second occurrence of the redundant
diff node foo'.
* include/abg-ir.h: Prefix the doc string with "///", rather than
writing it inside a /**/ comment.
* include/abg-comparison.h (function_decl_diff)
(function_decl_diff_sptr, fn_parm_diff, fn_parm_diff_sptr)
(var_diff_sptr, base_diff, class_diff, class_diff_sptr): Move
these class & typedef decls to the top of the file.
(string_changed_base_map, string_changed_parm_map)
(unsigned_changed_parm_map, changed_function_ptr)
(string_changed_function_ptr_map): Remove these typedefs.
(string_base_diff_sptr_map, string_fn_parm_diff_sptr_map)
(unsigned_fn_parm_diff_sptr_map, string_var_diff_sptr_map)
(unsigned_var_diff_sptr_map, string_function_decl_diff_sptr_map)
(string_var_diff_ptr_map): New typedefs.
(diff_context::{has_diff_for,add_diff}): Make these member
functions private.
(diff_context::{set_canonical_diff_for,
set_or_get_canonical_diff_for}): Declare new private member
functions.
(diff_context::{get_canonical_diff_for,
initialize_canonical_diff}): New public member functions.
(diff_context::maybe_apply_filters): Set the default value of the
'traverse_nodes_once' parameter to false.
(compute_diff): Make the overload for class_decl_sptr friend of
the diff_context class.
(class diff): Make the diff_context class a friend of this one.
(diff::set_canonical_diff): Declare new private member function.
(diff::get_canonical_diff): Declare new public member function.
(diff::children_nodes): Make this return a vector<diff_sptr>, rather
than a vector<diff*>.
(diff::append_child_node): Make this take a diff_sptr rather than
a diff*.
(class fn_parm_diff): Declare new type.
(compute_diff): Declare new overload for the new
function_decl::parameter_sptr.
(function_decl_diff::subtype_changed_parms): Return a
string_fn_parm_diff_sptr_map rather than a string_changed_parm.
(function_decl_diff::children_nodes): Return a vector<diff_sptr>.
(function_decl_diff::append_child_node): Take a diff_sptr.
(function_decl_diff::changed_functions): Return a
string_function_decl_diff_sptr_map.
(function_decl_diff::changed_variables): Return a
string_var_diff_sptr.
(class function_decl::parameter): Make this a pimpled class.
Also, make it inherit decl_base.
(equals): New overload for function_decl::parameter.
(struct function_decl::parameter::hash): Declare this.
(ir_node_visitor::visit): Declare new overload for
function_decl::parameter.
* src/abg-comparison.cc: Add doc-string about the internal
representation of the comparison engine and also about the concept
of canonical diff of the comparison engine.
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2)
(RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER3): Consider the
canonical diff when trying to know if the current node was
reported earlier.
(diff_context::priv::canonical_diffs): New data member.
(diff_context::{get_canonical_diff_for, set_canonical_diff_for,
set_or_get_canonical_diff_for, initialize_canonical_diff}): Define
new member functions.
(diff_context::{diff_has_been_traversed, mark_diff_as_traversed):
Consider canonical diff for these tests and actions.
(diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(diff::canonical_diff_): New data member.
(diff::diff): Initialize the diff::canonical_diff_ data member.
(diff::begin_traversing): Mark the canonical diff node too.
(diff::is_traversing): Consider the canonical diff node in this
test.
(diff::end_traversing): Make the canonical diff node too. Also
mark the current node as having been traversed.
(diff::children_nodes): Return a vector<diff_sptr> type.
(diff::{get_canonical_diff, set_canonical_diff}): Define new
member functions.
(diff::append_child_node): Take a diff_sptr type parameter.
(diff::{reported_once, currently_reporting}): Flag the canonical
diff node too. And consider the canonical diff node when checking
the flag.
(diff::traverse): No need to mark the node as being traversed
because the diff::end_traversing() function does it now. Adjust
the code because diff::children_nodes() now returns
vector<diff_sptr>.
({distinct_diff, var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, function_decl_diff, typedef_diff,
corpus_diff}::chain_into_hierarchy): Adjust to the new type that
diff::append_child_node() takes. Also, take into account that the
diff nodes are now un-shared.
(compute_diff_for_distinct_kinds, compute_diff_for_types)
(compute_diff): Do not share diff nodes anymore. Initialize the
canonical diff node for the new created node.
(represent): Take a var_diff_sptr rather than two var_decl_sptr.
Adjust. Also take in account the fact that diff nodes are not
shared anymore, and that they do have canonical diffs.
(var_diff::type_diff): Make the computation of the type_diff of
the var_diff be lazy. This avoids infinite (recursive) creation
of diff nodes when a class diff node has a sub-type of data member
that is a class diff node too.
(var_diff::report): Detect redundant reporting of this kind of
diff node.
(class_diff::priv::changed_bases_): Change the type of this to
string_base_diff_sptr_map.
(class_diff::priv::subtype_changed_dm_): Change the type of this
to string_var_diff_sptr_map.
(class_diff::priv::changed_dm_): Change the type of this to
unsigned_var_diff_sptr_map.
(class_diff::priv::{count_filtered_subtype_changed_dm,
count_filtered_bases}): Do not take a diff_context_sptr anymore.
(class_diff::ensure_lookup_tables_populated): changed_bases_
subtype_changed_dm_ and changed_dm_ are now *NOT* shared diff
nodes anymore.
(class_diff::priv::base_has_changed): Adjust.
(class_diff::priv::subtype_changed_dm): Adjust.
(class_diff::priv::count_filtered_bases): Adjust as changed_bases_
is now a map of un-shared diff nodes.
(class_diff::priv::count_filtered_subtype_changed_dm): Adjust as
subtype_changed_dm_ is now a map of un-shared diff nodes.
(class_diff::priv::{count_filtered_changed_mem_fns,
count_filtered_inserted_mem_fns, count_filtered_deleted_mem_fns,
}): Adjust for change of the default parameter value of
diff_context::maybe_apply_filters().
(class_diff::~class_diff): New destructor.
(class_diff::changed_bases): Return a string_base_diff_sptr_map&
type.
(class_diff::{inserted_data_members, deleted_data_members,
changed_member_fns}): Add doc strings.
(struct changed_data_member_comp): Remove.
(struct var_diff_comp): New comparison functor.
(sort_changed_data_members): Remove.
(sort_var_diffs): Define new sorting function.
(class_diff::report): Adjust.
(fn_parm_diff::*): Define member types and functions of the new
fn_parm_diff type.
(function_decl_diff::priv::{subtype_changed_parms_,
changed_parms_by_id_}): Make these take a map of fn_parm_diff_sptr
nodes.
(function_decl_diff::ensure_lookup_tables_populated): Adjust to
the fact that priv_->subtype_changed_parms_ and
priv_->priv_->changed_parms_by_id_ now are maps of un-shared
fn_parm_diff_sptr nodes.
(function_decl_diff::subtype_changed_parms): Adjust.
(struct changed_parm_comp): Remove.
(struct fn_parm_diff_comp): New comparison functor.
(sort_changed_parm_map): Remove.
(sort_string_fn_parm_diff_sptr_map): New sorting function.
(function_decl_diff::report): Adjust.
(corpus_diff::priv::children_): Change the type of this to
vector<diff_sptr>.
(corpus_diff::priv::changed_fns_): Changed the type of this to
string_function_decl_diff_sptr_map.
(corpus_diff::priv::changed_vars_): Changed the type of this to
string_var_diff_sptr_map.
(corpus_diff::priv::ensure_lookup_tables_populated): Adjust.
(corpus_diff::priv::apply_filters_and_compute_diff_stats}):
Adjust. Do not need to clear redundancy categorization anymore
because the diff nodes are not shared anymore.
(corpus_diff::priv::categorize_redundant_changed_sub_nodes):
Adjust.
(corpus_diff::priv::clear_redundancy_categorization): Adjust.
(corpus_diff::changed_variables): Adjust.
(struct changed_function_ptr_comp): Remove.
(struct function_decl_diff_comp): New comparison functor.
(sort_string_changed_function_ptr_map): Remove.
(sort_string_function_decl_diff_sptr_map): Define new sorting
function.
(struct changed_vars_comp): Remove.
(struct var_diff_sptr_comp): New comparison functor.
(sort_changed_vars): Remove.
(sort_string_var_diff_sptr_map): Define new sorting function.
(corpus_diff::report): Adjust.
(corpus_diff::traverse): Adjust.
({category_propagation_visitor,
suppression_categorization_visitor}::visit_end): Adjust.
(clear_redundancy_categorization): Adjust.
* src/abg-hash.cc (function_decl::parameter::hash::operator):
Adjust.
* src/abg-ir.cc (struct function_decl::parameter::priv): Define
here as part of pimpl-ifying the function_decl::parameter type.
(function_decl::parameter::*): Define here the member functions as
part of pimpl-ifying the function_decl::parameter type.
(equals): Define the overload for function_decl::parameter here
too.
(ir_node_visitor::visit(function_decl::parameter*)): Define this.
* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Adjust.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Adjust.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest21-redundant-fn-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-v0.cc: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test21-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v0.so: New
test input data.
* tests/data/test-diff-dwarf/libtest22-changed-parm-c-v1.so:
Likewise.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v0.c: Source
code for test input binary above.
* tests/data/test-diff-dwarf/test22-changed-parm-c-v1.c: Likewise.
* tests/test-diff-dwarf.cc (in_out_spec): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: New
test input data.
* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v0.so: New test
input binary.
* tests/data/test-diff-suppr/libtest8-redundant-fn-v1.so: Likewise.
* tests/data/test-diff-suppr/test8-redundant-fn-v0.cc: Source code
code for binary test input above.
* tests/data/test-diff-suppr/test8-redundant-fn-v1.cc: Likewise.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt:
New test input data.
* tests/data/test-diff-suppr/test9-changed-parm-c-report-1.txt:
Likewise.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v0.so: New
test input binary.
* tests/data/test-diff-suppr/libtest9-changed-parm-c-v1.so: New
test input binary.
* tests/data/test-diff-suppr/test9-changed-parm-c-v0.c: Source
code for binary test input above.
* tests/data/test-diff-suppr/test9-changed-parm-c-v1.c: Likewise.
* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
data to the vector the test inputs to run this harness over.
* tests/data/Makefile.am: Add the new files to the source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-26 12:22:16 +00:00
|
|
|
/// A hashing functor for a function_decl::parameter.
|
|
|
|
struct function_decl::parameter::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const function_decl::parameter&) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const function_decl::parameter*) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const function_decl::parameter_sptr) const;
|
|
|
|
}; // end struct function_decl::parameter::hash
|
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const function_type&, const function_type&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
2013-06-01 13:41:59 +00:00
|
|
|
/// Abstraction of a function type.
|
|
|
|
class function_type : public virtual type_base
|
|
|
|
{
|
2014-10-27 20:07:35 +00:00
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for an instance of function_type
|
|
|
|
struct hash;
|
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref
|
|
|
|
/// function_decl::parameter
|
2013-08-06 17:18:35 +00:00
|
|
|
typedef shared_ptr<function_decl::parameter> parameter_sptr;
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a vector of @ref parameter_sptr
|
2013-08-06 17:18:35 +00:00
|
|
|
typedef std::vector<parameter_sptr> parameters;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
|
|
|
private:
|
2013-08-06 17:18:35 +00:00
|
|
|
function_type();
|
2013-06-01 13:41:59 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-10-27 20:07:35 +00:00
|
|
|
function_type(type_base_sptr return_type,
|
|
|
|
const parameters& parms,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2014-10-27 20:07:35 +00:00
|
|
|
function_type(type_base_sptr return_type,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2014-10-27 20:07:35 +00:00
|
|
|
function_type(size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
type_base_sptr
|
2014-10-27 20:07:35 +00:00
|
|
|
get_return_type() const;
|
2013-06-01 13:41:59 +00:00
|
|
|
|
|
|
|
void
|
2014-10-27 20:07:35 +00:00
|
|
|
set_return_type(type_base_sptr t);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const parameters&
|
2014-10-27 20:07:35 +00:00
|
|
|
get_parameters() const;
|
2013-06-01 13:41:59 +00:00
|
|
|
|
Initial support for function suppressions
* include/abg-comparison.h (enum visiting_kind): Change the
meaning of this. It was to determine if traversal was to be done
in a pre or post manner. But with the recent addition of
diff_node_visitor::visit_{begin,end}() notifiers, the pre/post
handling is taken care of in a different way. So now the meaning
of this enum is changed to handle whether diff node children
should be visited or not. So the enumerators are now
DEFAULT_VISITING_KIND, and SKIP_CHILDREN_VISITING_KIND. And it's
a bit-field.
(operator{&,~}): Declare more bit manipulation operators for the
enum visiting_kind.
(function_suppression_sptr, function_suppressions_type): New
typedefs.
(function_suppression, function_suppression::parameter_spec):
Declare new types.
(read_function_suppressions): Declare new function.
(diff_node_visitor::diff_node_visitor): Adjust for the enum
visiting_kind change. Value-initialize the visiting_kind_ data
member.
* src/abg-comparison.cc (operator{&,~}): Define these operators
for enum visiting_kind.
(read_type_suppressions): Forward declare this static function.
(read_function_suppression, read_parameter_spec_from_string):
Define new static functions.
(read_suppressions): Update to read function suppressions too,
using the new read_function_suppression function above.
(class function_suppression::parameter_spec::priv): Define new
type.
(function_suppression::parameter_spec::*): Define the member
functions of the new function_suppression::parameter_spec type.
(class function_suppression::priv): Define new type.
(function_suppression::*): Define the member functions of the new
function_suppression type.
(diff::traverse): There is no more {PRE,POST}_VISITING_KIND
enumerator. So nuke the code that was dealing with it.
(redundancy_marking_visitor::skip_children_nodes_): New data
member flag.
(redundancy_marking_visitor::visit_begin): If the current diff
node is not be reported (is filtered out), do not bother visit its
children nodes for the purpose of marking redundant nodes. So use
the new skip_children_nodes_ flag above to know we are in that case.
(redundancy_marking_visitor::visit_end): Unset the new
skip_children_nodes_ flag above when appropriate.
* include/abg-fwd.h (is_function_decl): Declare new function.
* include/abg-ir.h
(function_type::get_parm_at_index_from_first_non_implicit_parm):
Declare new member function.
* src/abg-ir.cc (is_function_decl): Define new function.
(function_type::get_parm_at_index_from_first_non_implicit_parm):
Define new member function.
* src/abg-comp-filter.cc (apply_filter): Adjust for the enum
visiting_kind change. No need to set it for filters anymore
* doc/suppr-doc.txt: Update examples of function suppression.
* doc/manuals/libabigail-concepts.rst: Update the manual for the
function suppression addition.
* tests/data/test-diff-suppr/libtest5-fn-suppr-v0.so: New test input.
* tests/data/test-diff-suppr/libtest5-fn-suppr-v1.so: New test input.
* tests/data/test-diff-suppr/libtest6-fn-suppr-v0.so: New test input.
* tests/data/test-diff-suppr/libtest6-fn-suppr-v1.so: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-0.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-1.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-2.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-3.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-4.suppr: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: New test input.
* tests/data/test-diff-suppr/test5-fn-suppr-v0.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test5-fn-suppr-v1.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-0.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-1.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-2.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-3.suppr: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt: New test input.
* tests/data/test-diff-suppr/test6-fn-suppr-v0.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-v1.cc: Source code for
new test input.
* tests/data/test-diff-suppr/test6-fn-suppr-version-script: New
test input.
* tests/Makefile.am: Add the new files above to source
the distribution.
* tests/test-diff-suppr.cc (in_out_specs): Add the test inputs
above to the list of tests to be run by this harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-28 10:32:15 +00:00
|
|
|
const parameter_sptr
|
|
|
|
get_parm_at_index_from_first_non_implicit_parm(size_t) const;
|
|
|
|
|
2013-06-01 13:41:59 +00:00
|
|
|
void
|
2014-10-27 20:07:35 +00:00
|
|
|
set_parameters(const parameters &p);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
|
|
|
void
|
2014-10-27 20:07:35 +00:00
|
|
|
append_parameter(parameter_sptr parm);
|
2013-06-01 13:41:59 +00:00
|
|
|
|
|
|
|
bool
|
2014-10-27 20:07:35 +00:00
|
|
|
is_variadic() const;
|
2013-06-01 13:41:59 +00:00
|
|
|
|
2014-03-18 10:27:02 +00:00
|
|
|
parameters::const_iterator
|
|
|
|
get_first_non_implicit_parm() const;
|
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
2013-06-01 13:41:59 +00:00
|
|
|
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor&);
|
|
|
|
|
2013-06-01 13:41:59 +00:00
|
|
|
virtual ~function_type();
|
2013-10-10 08:11:35 +00:00
|
|
|
};//end class function_type
|
2013-06-01 13:41:59 +00:00
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
/// The hashing functor for @ref function_type.
|
|
|
|
struct function_type::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const function_type& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const function_type* t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const function_type_sptr t) const;
|
|
|
|
};// end struct function_type::hash
|
|
|
|
|
2013-12-20 15:19:58 +00:00
|
|
|
/// Convenience typedef for shared pointer to @ref method_type.
|
|
|
|
typedef shared_ptr<method_type> method_type_sptr;
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
/// Abstracts the type of a class member function.
|
|
|
|
class method_type : public function_type
|
|
|
|
{
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
class_decl_wptr class_type_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
method_type();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher for intances of method_type
|
|
|
|
struct hash;
|
|
|
|
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
method_type(shared_ptr<type_base> return_type,
|
|
|
|
shared_ptr<class_decl> class_type,
|
|
|
|
const std::vector<shared_ptr<function_decl::parameter> >& parms,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
|
|
|
|
|
|
|
method_type(shared_ptr<type_base> return_type,
|
|
|
|
shared_ptr<type_base> class_type,
|
|
|
|
const std::vector<shared_ptr<function_decl::parameter> >& parms,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
|
|
|
|
|
|
|
method_type(shared_ptr<class_decl> class_type,
|
|
|
|
size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
|
|
|
|
|
|
|
method_type(size_t size_in_bits,
|
|
|
|
size_t alignment_in_bits);
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
class_decl_sptr
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
get_class_type() const
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
{return class_decl_sptr(class_type_);}
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
|
|
|
void
|
2013-08-02 23:30:56 +00:00
|
|
|
set_class_type(shared_ptr<class_decl> t);
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
Add support for abicompat weak mode
This patch implements the weak mode of abicompat. In this mode, just
the application and the new version of the library are provided. The
types of functions and variables of the library that are consumed by
the application are compared to the types of the functions and
variables expected by the application. The goal is to check if the
types of the declarations consumed by the application and provided by
the library are compatible with what the application expects.
The abicompat first gets the set of symbols undefined in the
application and exported by the library. It then builds the set of
declarations exported by the library that have those symbols. We call
these the set of declarations of the library that are consumed by the
application.
Note that the debug information for the application does not contain
the declarations of the functions/variables whose symbols are
undefined. So we can not just read them to compare them to
declarations exported by the library.
But the *types* of the variables and the *sub-types* of the functions
whose symbols are undefined in the application are present in the
debug information of the application.
So in the weak mode, abicompat compare the *types* of the declarations
consumed by the application as expected by the application (described
by the debug information of the application) with the types of the
declarations exported by the library.
To do this a number of changes were necessary.
The patch builds a representation of all the types found in the
application's debug info. Before that, only the types that are
reachable from exported declarations were represented.
The abidw tool got a new --load-all-types to test this new ability of
loading all types.
The patch also adds support for looking a type, not by name, but by
its internal representation.
In the comparison engine, function_type_diff is introduced to
represent changes between two function types. For this, a new class
type_or_decl_base has been introduced in the IR. It's now the base
class for both decl_base and type_base. And abigail::comparison::diff
now takes two pointers of type_or_decl, not decl_base anymore. So
function_type_diff can take two function_type now; not that a
function_type has no declaration so it doesn't inherit decl_base. A
bunch of changes got made just to adjust to this modification.
A number of fixes were made too, to make this work, like adding
missing comparison operators, removing asserts that too strong, etc..
The patch also adjust the test suite as well as the documentation.
* include/abg-fwd.h (class type_or_decl_base): Forward declare
this.
(is_decl, is_type, is_function_type, get_name, get_type_name)
(get_function_type_name, get_pretty_representation)
(lookup_function_type_in_corpus, lookup_type_in_translation_unit)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(hash_type_or_decl): New function declarations.
* src/abg-corpus.cc (lookup_type_in_corpus)
(lookup_function_type_in_corpus): Define new functions.
* include/abg-ir.h
(translation_unit::lookup_function_type_in_translation_unit):
Declare new friend function.
(class type_or_decl_base): Declare this.
(operator==(const type_or_decl_base&, const type_or_decl_base&)):
Declare new operator.
(operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(class {decl_base, type_base}): Make these class inherit
type_or_decl_base.
(decl_base::get_member_scopes): New const overload.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr&)): New operator.
(function_type::get_parameters): Remove the non-const overload.
(function_type::get_pretty_representation): Declare new member
function.
(method_type::get_pretty_representation): Likewise.
* src/abg-ir.cc (bool operator==(const type_or_decl_base&, const
type_or_decl_base&)): Define new equality operator.
(bool operator==(const type_or_decl_base_sptr&, const
type_or_decl_base_sptr&)): Likewise.
(strip_typedef): Do not expect canonicalized types anymore. Now
the system accepts (and expects) canonicalized types in certain
cases. For instance, non-complete types and aggregated types that
contain non-complete sub-types.
(get_name, get_function_type_name, get_type_name)
(get_pretty_representation, is_decl, is_type, is_function_type)
(lookup_function_type_in_translation_unit)
(synthesize_function_type_from_translation_unit)
(lookup_type_in_scope, lookup_type_in_translation_unit): Define
new functions or new overloads.
(bool operator==(const function_decl::parameter_sptr&,
const function_decl::parameter_sptr& r)): Define
new operator.
(function_type::get_parameters): Remove non-const overload.
(function_type::get_pretty_representation): Define new function.
(function_type::traverse): Adjust.
(method_type::get_pretty_representation): Likewise.
(function_decl::get_pretty_representation): Avoid emitting the
type of cdtors.
(hash_type_or_decl): Define new function.
* include/abg-dwarf-reader.h (create_read_context)
(read_corpus_from_elf): Take a new 'read_all_types' flag.
* src/abg-dwarf-reader.cc (read_context::load_all_types_): New
flag.
(read_context::read_context): Initialize it.
(read_context::canonical_types_scheduled): If some types still
have non-canonicalized sub-types, then do not canonicalize them.
(read_context::load_all_types): New member functions.
(build_function_decl): Do not represent void return type like
empty type anymore, rather, represent it like a void type node.
(build_ir_node_from_die): When asked, load all types
including those that are not reachable from an exported
declaration.
(create_read_context, read_corpus_from_elf): Take a new
'load_all_types' flag and honour it.
* src/abg-reader.cc (read_context::type_is_from_translation_unit):
Support looking up function types in the current translation unit,
now that we now how to lookup function types.
* include/abg-comparison.h (diff_context::{has_diff_for, add_diff,
set_canonical_diff_for, set_or_get_canonical_diff_for,
get_canonical_diff_for}): Make these take instances of
type_or_decl_base_sptr, instead of decl_base_sptr.
(diff::diff): Likewise.
(diff::{first_subject, second_subject}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(type_diff_base::type_diff_base): Make these take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::distinct_diff): Likewise.
(distinct_diff::{first, second}): Make these return
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::entities_are_of_distinct_kinds): Make these take
instances of type_or_decl_base_sptr instead of decl_base_sptr.
(class function_type_diff): Create this new type. It's a
factorization of the function_decl_diff type.
* src/abg-comparison.cc ():
* src/abg-comp-filter.cc ({harmless, harmful}_filter::visit):
Adjust as diff::{first,second}_subject() now returns a
type_or_decl_base_sptr, no more a decl_base_sptr.
(decls_type, decls_diff_map_type): Remove these typedefs and replace it with ...
(types_or_decls_type, types_or_decls_diff_map_type): ... these.
(struct {decls_hash, decls_equals): Remove these type sand replace them with ...
(struct {types_or_decls_hash, types_or_decls_equals}): ... these.
({type_suppression, variable_suppression}::suppresses_diff):
Adjust.
(diff_context::priv::decls_diff_map): Replace this with ...
(diff_context::priv::types_or_decls_diff_map): ... this.
(diff_context::{has_diff_for, add_diff, get_canonical_diff_for,
set_canonical_diff_for, set_or_get_canonical_diff_for}): Take
type_or_decl_base_sptr instead of decl_base_sptr.
(diff::priv::{first, second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(diff::priv::priv): Adjust for the subjects of the diff being of
type type_or_decl_sptr now, no more decl_base_sptr.
(diff_less_than_functor::operator()(const diff_sptr, const
diff_sptr) const): Adjust.
(diff::diff): djust for the subjects of the diff being of type
type_or_decl_sptr now, no more decl_base_sptr.
(diff::{first,second}_subject): Make the type of these be
type_or_decl_base_sptr, no more decl_base_sptr.
(report_size_and_alignment_changes): Likewise.
(type_diff_base::type_diff_base): Make the type of this be
type_or_decl_base_sptr instead of type_base_sptr.
(distinct_diff::distinct_diff): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(distinct_diff::{first, second, entities_are_of_distinct_kinds}):
Likewise.
(distinct_diff::has_changes): Simplify logic.
(distinct_diff::report): Adjust.
(compute_diff_for_types): Add an additional case to support the
new function_type.
(report_size_and_alignment_changes): Make this take instances of
type_or_decl_base_sptr instead of decl_base_sptr.
(class_diff::priv::member_type_has_changed): Return an instance of
type_or_decl_base_sptr rather than a decl_base_sptr.
(class_diff::report): Adjust.
(diff_comp::operator()(const diff&, diff&) const): Adjust.
(enum function_decl_diff::priv::Flags): Remove.
(function_decl_diff::priv::{first_fn_flags_, second_fn_flags_,
fn_flags_changes_}): Remove.
(function_decl_diff::priv::{fn_is_declared_inline_to_flag,
fn_binding_to_flag}): Remove.
(function_decl_diff::{deleted_parameter_at,
inserted_parameter_at}): Remove.
(function_decl_diff::ensure_lookup_tables_populated): Empty this.
(function_decl_diff::chain_into_hierarchy): Adjust.
(function_decl_diff::function_decl_diff): This now only takes the
subjects. It's body is now empty.
(function_decl_diff::{return_type_diff, subtype_changed_parms,
removed_parms, added_parms, type_diff}): Remove these member
functions.
(function_decl_diff::type_diff): Define new member function.
(function_decl_diff::report): Simplify logic by using the
reporting of the child type diff node.
(compute_diff): Likewise, in the overload for function_decl_sptr
simplify logic by using the child type diff object.
(function_type_diff::priv): Define new type.
(function_type_diff::{function_type_diff,
ensure_lookup_tables_populated, deleted_parameter_at,
inserted_parameter_at, finish_diff_type, first_function_type,
second_function_type, return_type_diff, subtype_changed_parms,
removed_parms, added_parms, get_pretty_representation,
has_changes, has_local_changes, report, chain_into_hierarchy}):
Define new functions.
(compute_diff): Define new overload for function_type_sptr.
* tools/abicompat.cc (options::weak_mode): New data member.
(options::options): Initialize it.
(enum abicompat_status): New enum
(abicompat_status operator|(abicompat_status, abicompat_status))
(abicompat_status& operator|=(abicompat_status &, abicompat_status))
(abicompat_status operator&(abicompat_status, abicompat_status)):
New operators to manipulate the abicompat_status enum.
(display_usage): Add help string for the new --weak-mode option.
(parse_command_line): Add the new --weak-mode command line
argument. If the tool is called with just the application and one
library then assume that we are in the weak mode.
(perform_compat_check_in_normal_mode): Define new function, factorized
from what was in the main function.
(perform_compat_check_in_weak_mode): Define new function.
(struct {fn,var}_change): Define new types.
(main): Use perform_compat_check_in_weak_mode() and
perform_compat_check_in_normal_mode().
* tools/abidiff.cc (main): Adjust.
* tools/abidw.cc: (options::load_all_types): Add new data member.
(options::options): Initialize it.
(display_usage): New help string for --load-all-types.
(parse_command_line): Support the new --load-all-types option.
(main): Adjust and honour the --load-all-types option.
* tools/abilint.cc (main): Adjust.
* doc/manuals/abicompat.rst: Update documentation for the new weak
mode. Also provide stuff that was missing from the examples
provided.
* doc/manuals/abidw.rst: Update documentation for the new
--load-all-types option.
* tests/print-diff-tree.cc (main): Adjust.
* tests/test-diff-dwarf.cc (main): Likewise.
* tests/test-read-dwarf.cc (main): Likewise.
* tests/data/test-abicompat/test0-fn-changed-app: Recompile this.
* tests/data/test-abicompat/libtest5-fn-changed-libapp-v{0,1}.so:
New new test input binaries
* tests/data/test-abicompat/test5-fn-changed-app: Likewise.
* tests/data/test-abicompat/test6-var-changed-app: Likewise.
* tests/data/test-abicompat/libtest6-var-changed-libapp-v{0,1}.so:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-report-0.txt:
Reference output for one test above.
* tests/data/test-abicompat/test6-var-changed-report-0.txt:
Likewise.
* tests/data/test-abicompat/test5-fn-changed-app.cc: Source file
for a binary above.
* tests/data/test-abicompat/test5-fn-changed-libapp-v{0,1}.{h,cc}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-libapp-v{0,1}.{cc,h}:
Likewise.
* tests/data/test-abicompat/test6-var-changed-app.cc: Likewise.
* tests/data/Makefile.am: Add the test related files above to the
source distribution.
* tests/test-abicompat.cc (in_out_spec): Add the new test input
above to the list of inputs to feed to this test harness.
(main): Support taking just the app and one library.
* tests/data/test-read-dwarf/test{0, 1, 2.so, 3.so, 5.o,
8-qualified-this-pointer.so,}.abi: Adjust for void type being
really emitted now, as opposed to just being an empty type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-04-01 10:13:38 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
virtual ~method_type();
|
2013-10-10 08:11:35 +00:00
|
|
|
};// end class method_type.
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
/// Convenience typedef for shared pointer to template parameter
|
|
|
|
typedef shared_ptr<template_parameter> template_parameter_sptr;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to template_decl
|
|
|
|
typedef shared_ptr<template_decl> template_decl_sptr;
|
|
|
|
|
|
|
|
/// Convenience typedef for a weak pointer to template_decl
|
|
|
|
typedef weak_ptr<template_decl> template_decl_wptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// The base class of templates.
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class template_decl : public virtual decl_base
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
|
|
|
template_decl();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
template_decl(const string& name,
|
|
|
|
location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
void
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
add_template_parameter(const template_parameter_sptr p);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
const std::list<template_parameter_sptr>&
|
|
|
|
get_template_parameters() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_decl& o) const;
|
|
|
|
|
|
|
|
virtual ~template_decl();
|
2013-10-10 08:11:35 +00:00
|
|
|
};//end class template_decl
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
/// Base class for a template parameter. Client code should use the
|
|
|
|
/// more specialized type_template_parameter,
|
|
|
|
/// non_type_template_parameter and template_template_parameter below.
|
|
|
|
class template_parameter
|
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
// Forbidden
|
|
|
|
template_parameter();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hashers.
|
|
|
|
struct hash;
|
|
|
|
struct dynamic_hash;
|
|
|
|
struct shared_ptr_hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
template_parameter(unsigned index,
|
|
|
|
template_decl_sptr enclosing_tdecl);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_parameter&) const;
|
|
|
|
|
|
|
|
unsigned
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
get_index() const;
|
|
|
|
|
|
|
|
const template_decl_sptr
|
|
|
|
get_enclosing_template_decl() const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
get_hashing_has_started() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_hashing_has_started(bool f) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
virtual ~template_parameter();
|
2013-10-10 08:11:35 +00:00
|
|
|
};//end class template_parameter
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
struct template_decl::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const template_decl& t) const;
|
|
|
|
};// end struct template_decl::hash
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared pointer to @ref type_tparameter.
|
|
|
|
typedef shared_ptr<type_tparameter> type_tparameter_sptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// Abstracts a type template parameter.
|
2013-10-10 08:11:35 +00:00
|
|
|
class type_tparameter : public template_parameter, public virtual type_decl
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
// Forbidden
|
2013-08-08 06:54:44 +00:00
|
|
|
type_tparameter();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
|
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
type_tparameter(unsigned index,
|
|
|
|
template_decl_sptr enclosing_tdecl,
|
|
|
|
const std::string& name,
|
|
|
|
location locus);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_parameter&) const;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
virtual bool
|
2013-08-08 06:54:44 +00:00
|
|
|
operator==(const type_tparameter&) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~type_tparameter();
|
2013-10-10 08:11:35 +00:00
|
|
|
};// end class type_tparameter.
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
/// Convenience typedef for shared pointer to @ref
|
|
|
|
/// non_type_template_parameter
|
|
|
|
typedef shared_ptr<non_type_tparameter> non_type_tparameter_sptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// Abstracts non type template parameters.
|
2013-10-10 08:11:35 +00:00
|
|
|
class non_type_tparameter : public template_parameter, public virtual decl_base
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
Fix memory leaks due to cycles in types ownership
* include/abg-fwd.h (std::tr1::weak_ptr): Inject this type in the
abigail namespace.
* include/abg-ir.h: Write a memory management guideline for the IR
artifacts.
(Type_base_wptr, function_type_wptr)
(class_decl_wptr): New typedefs.
(translation_unit::get_canonical_function_type): Declare new
member function.
(qualified_type_def::underlying_type_)
(reference_type_def::pointed_to_type_)
(typedef_decl::underlying_type_, function_decl::parameter::type_)
(function_type::return_type_, method_type::class_type_)
(non_type_tparameter::type_, type_composition::type_): Make this a
weak pointer.
(qualified_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type::get_element_type, typedef_decl::get_underlying_type)
(var_decl::get_type, function_decl::parameter::get_type)
(function_type::get_return_type, method_type::get_class_type)
(non_type_tparameter::get_type)
(type_composition::get_composed_type): Adjust to make this return
a shared pointer initialized with the content of the weak pointer.
(function_decl::function_decl, method_decl::method_decl): Remove
the overload that doesn't take a type. This is because now,
function types need to be registered to their containing
translation unit.
(struct function_type::hash): Declare here.
* src/abg-hash.cc (struct function_type::hash): Declare this in
abg-ir.h and just define the methods here.
* src/abg-ir.cc (fn_type_ptr_map): New typedef.
(translation_unit::priv::canonical_types_): Remove this unused
member.
(translation_unit::priv::canonical_function_types_): New member.
(translation_unit::get_canonical_function_type): Define this
function.
(array_type_def::priv::element_type_, var_decl::priv::type_)
(function_decl::priv::type_): Make this a weak pointer.
(qualified_type_def::get_underlying_type)
(pointer_type_def::get_pointed_to_type)
(reference_type_def::get_pointed_to_type)
(array_type_def::get_element_type)
(typedef_decl::get_underlying_type, var_decl::get_type)
(function_decl::get_type): Adjust to make this return a shared
pointer initialized with the content of the weak pointer.
(qualified_type_def::build_name)
(pointer_type_def::get_qualified_name)
(reference_type_def::get_qualified_name): Adjust.
(method_type::set_class_type): Cleanup the logic.
(function_decl::priv::priv): Remove the overload that takes a bare
pointer to a type. This should not be used now that we need the
function type to registered with the translation unit.
(function_decl::function_decl): Remove the overload that doesn't
take a type. This is because now, function types need to be
registered to their containing translation unit.
* src/abg-dwarf-reader.cc (build_function_decl): Register the
function type within its translation type and use its canonical
version. This complies with the new memory management rules.
* src/abg-reader.cc (build_function_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-09-10 15:09:47 +00:00
|
|
|
type_base_wptr type_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
// Forbidden
|
2013-08-08 06:54:44 +00:00
|
|
|
non_type_tparameter();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
non_type_tparameter(unsigned index,
|
|
|
|
template_decl_sptr enclosing_tdecl,
|
|
|
|
const std::string& name,
|
|
|
|
shared_ptr<type_base> type,
|
|
|
|
location locus);
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const template_parameter&) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
const type_base_sptr
|
|
|
|
get_type() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~non_type_tparameter();
|
2013-10-10 08:11:35 +00:00
|
|
|
};// end class non_type_tparameter
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
/// Hasher for the @ref non_type_tparameter type.
|
|
|
|
struct non_type_tparameter::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const non_type_tparameter& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const non_type_tparameter* t) const;
|
|
|
|
};
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class template_tparameter;
|
|
|
|
|
|
|
|
/// Convenience typedef for a shared_ptr to @ref template_tparameter.
|
|
|
|
typedef shared_ptr<template_tparameter> template_tparameter_sptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// Abstracts a template template parameter.
|
2013-10-10 08:11:35 +00:00
|
|
|
class template_tparameter : public type_tparameter, public template_decl
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
// Forbidden
|
2013-08-08 06:54:44 +00:00
|
|
|
template_tparameter();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
/// A hasher for instances of template_tparameter
|
2013-08-07 09:07:29 +00:00
|
|
|
struct hash;
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
template_tparameter(unsigned index,
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
template_decl_sptr enclosing_tdecl,
|
|
|
|
const std::string& name,
|
|
|
|
location locus);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_parameter&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_decl&) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~template_tparameter();
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
/// Convenience typedef for shared pointer to type_composition
|
|
|
|
typedef shared_ptr<type_composition> type_composition_sptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// This abstracts a composition of types based on template type
|
|
|
|
/// parameters. The result of the composition is a type that can be
|
|
|
|
/// referred to by a template non-type parameter. Instances of this
|
|
|
|
/// type can appear at the same level as template parameters, in the
|
|
|
|
/// scope of a template_decl.
|
2013-10-10 08:11:35 +00:00
|
|
|
class type_composition : public template_parameter, public virtual decl_base
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
type_composition();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
struct hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
type_composition(unsigned index,
|
|
|
|
template_decl_sptr tdecl,
|
|
|
|
type_base_sptr composed_type);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
const type_base_sptr
|
|
|
|
get_composed_type() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
void
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
set_composed_type(type_base_sptr t);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~type_composition();
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
/// Hasher for the @ref type_composition type.
|
|
|
|
struct type_composition::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const type_composition& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const type_composition* t) const;
|
|
|
|
|
|
|
|
}; //struct type_composition::hash
|
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref function_tdecl
|
2013-10-10 14:58:30 +00:00
|
|
|
typedef shared_ptr<function_tdecl> function_tdecl_sptr;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
/// Abstract a function template declaration.
|
2013-10-10 08:11:35 +00:00
|
|
|
class function_tdecl : public template_decl, public scope_decl
|
2013-04-30 14:43:20 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
// Forbidden
|
2013-08-08 06:54:44 +00:00
|
|
|
function_tdecl();
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hash functor for function templates.
|
|
|
|
struct hash;
|
|
|
|
struct shared_ptr_hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
function_tdecl(location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_NONE);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
function_tdecl(function_decl_sptr pattern,
|
|
|
|
location locus,
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_NONE);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_decl&) const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
void
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
set_pattern(shared_ptr<function_decl> p);
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
shared_ptr<function_decl>
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
get_pattern() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
|
|
|
binding
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
get_binding() const;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~function_tdecl();
|
2013-10-10 08:11:35 +00:00
|
|
|
}; // end class function_tdecl.
|
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef for a shared pointer on a @ref class_tdecl
|
2013-10-10 14:58:30 +00:00
|
|
|
typedef shared_ptr<class_tdecl> class_tdecl_sptr;
|
2013-04-30 14:43:20 +00:00
|
|
|
|
2013-05-02 13:25:04 +00:00
|
|
|
/// Abstract a class template.
|
2013-08-08 06:54:44 +00:00
|
|
|
class class_tdecl : public template_decl, public scope_decl
|
2013-05-02 13:25:04 +00:00
|
|
|
{
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
|
|
|
|
priv_sptr priv_;
|
2013-08-02 03:16:22 +00:00
|
|
|
|
2013-05-02 13:25:04 +00:00
|
|
|
// Forbidden
|
2013-08-08 06:54:44 +00:00
|
|
|
class_tdecl();
|
2013-05-02 13:25:04 +00:00
|
|
|
|
|
|
|
public:
|
2013-08-27 11:55:45 +00:00
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hashers.
|
|
|
|
struct hash;
|
|
|
|
struct shared_ptr_hash;
|
|
|
|
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
class_tdecl(location locus, visibility vis = VISIBILITY_DEFAULT);
|
2013-05-02 13:25:04 +00:00
|
|
|
|
2013-10-10 08:11:35 +00:00
|
|
|
class_tdecl(shared_ptr<class_decl> pattern,
|
|
|
|
location locus, visibility vis = VISIBILITY_DEFAULT);
|
2013-05-02 13:25:04 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const template_decl&) const;
|
2013-05-02 13:25:04 +00:00
|
|
|
|
|
|
|
virtual bool
|
2013-08-08 06:54:44 +00:00
|
|
|
operator==(const class_tdecl&) const;
|
2013-05-02 13:25:04 +00:00
|
|
|
|
|
|
|
void
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
set_pattern(class_decl_sptr p);
|
2013-05-02 13:25:04 +00:00
|
|
|
|
|
|
|
shared_ptr<class_decl>
|
Fix template parameter hashing: make it know about enclosing template
* include/abg-ir.h (template_parameter_sptr, template_decl_sptr)
(template_decl_wptr): Declare new typedefs.
(class template_decl): Make this virtually inherit decl_base and
pimpl-ify it.
(class template_parameter): Pimpl-ify this. Make the constructor
take the enclosing template parameter.
(struct template_decl::hash): Declare this here, rather than in
src/abg-hash.cc
(class type_tparameter, non_type_tparameter, template_tparameter)
(class type_composition, function_tdecl, class_tdecl): Pimpl-ify
this.
* src/abg-hash.cc (template_parameter::hash::operator()): Hash the
enclosing template parameter. Avoid infinite recursion due to the
loop hash parameter -> hash template -> hash parameter.
(template_decl::hash::operator()) Define this here, now that it's
declared in abg-ir.h. Also, avoid infinite recursion here; this
is complementary to what is done in the hashing for
template_parameter.
({type_tparameter, template_tparameter, }::hash::operator()):
Cache the calculated hash just as what is done for other types
hashed.
(template_decl::priv): Define this new type.
(template_decl::{add_template_parameter, get_template_parameters,
~template_decl}): Define these here to pimpl-ify template_decl.
(template_parameter::priv): Define this new type.
(template_parameter::template_parameter): Define this here to
pimpl-ify template_parameter. Note also that this now takes the
enclosing template decl.
(template_parameter::{get_index, get_enclosing_template_decl,
get_hashing_has_started, set_hashing_has_started, operator::==}):
Define these here to pimpl-ify template_parameter.
(type_tparameter::priv): Define this new type.
(type_tparameter::type_tparameter): Define this here to pimpl-ify
type_tparameter. Also, not that this constructor now takes the
enclosing template decl.
(class non_type_tparameter::priv): Define new type.
(non_type_tparameter::{non_type_tparameter, get_type}): Define
these here to pimpl-ify non_type_tparameter. The constructor now
takes the enclosing template.
(template_tparameter::priv): Define new type.
(template_tparameter::template_tparameter): Define this here to
pimpl-ify template_tparameter. This constructor now takes the
enclosing template.
(class type_composition::priv): New type.
(type_composition::{type_composition, get_composed_type,
set_composed_type}): Define these here to pimpl-ify
type_composition. The constructor now takes the enclosing
template decl.
(class function_tdecl::priv): Define new type.
(function_tdecl::{function_tdecl, set_pattern, get_pattern,
get_binding}): Define this here to pimpl-ify function_tdecl.
(class class_tdecl::priv): Define this new type.
(class_tdecl::class_tdecl): Define this here to pimpl-ify
class_tdecl.
(class_tdecl::set_pattern): Adjust to pimpl-ify.
(class_tdecl::get_pattern): Define new pimpl-ified getter.
* src/abg-reader.cc (build_function_tdecl, build_class_tdecl):
Cleanup. Pass the enclosing template to the template parameters
that are built.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_template_parameter): Take the enclosing template
declaration and pass it to the template parameter being created.
* tests/data/test-read-write/test12.xml: Fix and Adjust.
* tests/data/test-read-write/test13.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-11-07 11:13:53 +00:00
|
|
|
get_pattern() const;
|
2013-05-02 13:25:04 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
2013-05-02 13:25:04 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
virtual ~class_tdecl();
|
2013-10-10 08:11:35 +00:00
|
|
|
};// end class class_tdecl
|
2013-05-02 13:25:04 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const class_decl&, const class_decl&, change_kind*);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
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-04-11 20:02:08 +00:00
|
|
|
/// Abstracts a class declaration.
|
|
|
|
class class_decl : public scope_type_decl
|
|
|
|
{
|
|
|
|
// Forbidden
|
|
|
|
class_decl();
|
|
|
|
|
|
|
|
public:
|
2013-08-07 09:07:29 +00:00
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
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-04-11 20:02:08 +00:00
|
|
|
|
2013-08-08 02:50:07 +00:00
|
|
|
/// Forward declarations.
|
|
|
|
class member_base;
|
|
|
|
class base_spec;
|
|
|
|
class method_decl;
|
|
|
|
class member_function_template;
|
|
|
|
class member_class_template;
|
|
|
|
|
2013-11-20 09:54:15 +00:00
|
|
|
/// Convenience typedef
|
|
|
|
/// @{
|
2013-09-26 14:45:00 +00:00
|
|
|
typedef shared_ptr<base_spec> base_spec_sptr;
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
typedef std::vector<base_spec_sptr> base_specs;
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
typedef std::vector<type_base_sptr> member_types;
|
Get rid of class_decl::data_member
* include/abg-fwd.h (has_scope): Delete the overloads for
type_base.
(get_member_is_static): Add an overload for decl_base*.
({is,get,set}_data_member,{get_,set}_data_member_is_laid_out)
({get,set}_data_member_offset): New access declarations.
* include/abg-ir.h (class context_rel): Move up.
(decl_base::set_context_rel): New definition.
(class dm_context_rel): New type.
(decl_base::hash_as_member): Remove.
(var_decl::set_scope): Declare new virtual member.
(class_decl::data_member): Remove.
(ir_node_visitor::visit): Remove the overload for
class_decl::data_member.
(represent_data_member): Remove the represent overload for
class_decl::data_member into this. Make it take a var_decl.
(represent): Change the overload that takes two
class_decl::data_member take two var_decl. And adjust it.
(class_diff::report): Adjust.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Remove the
overload that takes a class_decl::data_member*. Adjust the
overload that takes a var_decl to recognize (static) data members.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_ir_node_from_die):
Adjust.
* src/abg-hash.cc (var_decl::hash::operator()): Adjust.
(class_decl::data_member::hash::operator()): Remove.
(decl_base::hash::operator()): Take the context relationship in
account here.
(decl_base::hash_as_member::operator()): Remove.
({enum_type_decl,typedef_decl}::hash::operator()): Adjust.
(class_decl::member_function::hash::operator()): Adjust.
(type_base::dynamic_hash::operator()): Adjust.
* src/abg-ir.cc (dm_context_rel::~dm_context_rel): New definition.
(has_scope): Remove overload for type_base.
(get_member_is_static): New overload for decl_base*.
(is_data_member): New function definition.
({get,set}_data_member_{offset,is_laid_out}): Define new
accessors.
(var_decl::set_scope): Define new member function. Make this set
a dm_context_rel as the context relationship.
(var_decl::operator==): Adjust to take in account the new data
member relationship.
(class_decl::class_decl): Adjust.
(class_decl::insert_member_decl): Adjust.
(class_decl::add_data_member): Remove the overload for
class_decl::data_member.
(class_decl::add_data_member): Adjust the overload for var_decl.
(operator==): Remove overload for class_decl::data_member*.
(class_decl::data_member::operator==): Likewise.
(ir_node_visitor::visit): Remove overload for
class_decl::data_member.
* src/abg-writer.cc (write_layout_offset, write_class_decl):
Adjust.
* tests/data/test-read-write/test20.xml: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-19 19:36:55 +00:00
|
|
|
typedef std::vector<var_decl_sptr> data_members;
|
2014-03-20 10:56:56 +00:00
|
|
|
typedef shared_ptr<method_decl> method_decl_sptr;
|
|
|
|
typedef std::vector<method_decl_sptr> member_functions;
|
2013-09-26 14:45:00 +00:00
|
|
|
typedef shared_ptr<member_function_template> member_function_template_sptr;
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
typedef std::vector<member_function_template_sptr> member_function_templates;
|
2013-09-26 14:45:00 +00:00
|
|
|
typedef shared_ptr<member_class_template> member_class_template_sptr;
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
typedef std::vector<member_class_template_sptr> member_class_templates;
|
2013-11-20 09:54:15 +00:00
|
|
|
/// @}
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
private:
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
struct priv;
|
|
|
|
typedef shared_ptr<priv> priv_sptr;
|
|
|
|
priv_sptr priv_;
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
protected:
|
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
virtual decl_base_sptr
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
add_member_decl(decl_base_sptr);
|
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
virtual decl_base_sptr
|
|
|
|
insert_member_decl(decl_base_sptr member, declarations::iterator before);
|
|
|
|
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
virtual void
|
|
|
|
remove_member_decl(decl_base_sptr);
|
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
public:
|
|
|
|
|
2013-08-02 23:30:56 +00:00
|
|
|
class_decl(const std::string& name, size_t size_in_bits,
|
2014-03-10 08:15:09 +00:00
|
|
|
size_t align_in_bits, bool is_struct,
|
|
|
|
location locus, visibility vis,
|
2013-08-06 17:18:35 +00:00
|
|
|
base_specs& bases, member_types& mbrs,
|
|
|
|
data_members& data_mbrs, member_functions& member_fns);
|
2013-08-27 11:55:45 +00:00
|
|
|
|
|
|
|
class_decl(const std::string& name, size_t size_in_bits,
|
2014-03-10 08:15:09 +00:00
|
|
|
size_t align_in_bits, bool is_struct,
|
|
|
|
location locus, visibility vis);
|
|
|
|
class_decl(const std::string& name, bool is_struct,
|
|
|
|
bool is_declaration_only = true);
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
Support diff/reporting for functions & better diff/report in general
* include/abg-ir.h ({decl_base, class_decl,
function_decl}::get_pretty_representation): New virtual member to
get a pretty string name for decls & types.
(class_decl::parameter): Add an index to the parameter type.
(class_decl::parameter::parameter): Update the constructor for the
change above.
(class_decl::parameter::{get_index, set_index}): Accessors for the
new index.
(class_decl::parameter::operator==): Take in account the index.
(function_type::append_parameter): Set the index of the parameter
here.
* include/abg-fwd.h (get_type_name): New declaration.
* src/abg-ir.cc (get_type_name): New definition.
({decl_base, function_decl,
class_decl}::get_pretty_representation): New implementations.
(method_type::set_class_type): Update this to set function
parameter's index by default.
(function_decl::append_parameters): Use the append_parameter
method from function_type.
* include/abg-comparison.h (class function_decl_diff): New type
declaration.
* src/abg-comparison.cc (compute_diff_for_decls, compute_diff):
New definitions.
({pointer_diff, class_diff, scope_diff}::report): Use the new
get_pretty_representation. Output a prettier report.
(function_decl_diff::priv): New type.
(function_decl_diff::{deleted_parameter_at, inserted_parameter_at,
ensure_lookup_tables_populated, function_decl_diff,
first_function_decl, second_function_decl, changed_parms,
removed_parms, added_parms, length, report}): New member function
definitions.
* src/abg-hash.cc (function_decl::parameter::hash): Update this to
take the index in account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
|
|
|
virtual string
|
|
|
|
get_pretty_representation() const;
|
|
|
|
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
bool
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_is_declaration_only() const;
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
2014-03-12 13:59:45 +00:00
|
|
|
void
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
set_is_declaration_only(bool f);
|
2014-03-12 13:59:45 +00:00
|
|
|
|
2014-03-10 08:15:09 +00:00
|
|
|
bool
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
is_struct() const;
|
2014-03-10 08:15:09 +00:00
|
|
|
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
void
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
set_definition_of_declaration(class_decl_sptr);
|
|
|
|
|
2014-02-10 13:13:24 +00:00
|
|
|
const class_decl_sptr&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_definition_of_declaration() const;
|
2013-06-21 15:08:49 +00:00
|
|
|
|
|
|
|
void
|
2014-01-17 10:16:54 +00:00
|
|
|
set_earlier_declaration(decl_base_sptr declaration);
|
Support method type/decl, variadic functions, class declarations-only
* src/abg-ir.h (function_decl::parameter::parameter): New
constructor with variadic parameter marker.
(function_decl::m_type): Make this protected to let method_decl
inheriting class to access it.
(function_decl::get_type): Move this out-of-line.
(class method_type, method_type_hash): New types.
(enum class_decl::access_specifier): Add no_access new enumerator.
(class_decl::data_member::data_member): Move this out-of-line.
(class_decl::data_member::~data_member): Declare virtual
destructor.
(class method_decl): New class.
(class member_function): Make this inherit method_decl, instead of
function_decl.
(class_decl::class_decl): New constructors.
(class_decl::{hashing_started, is_declaration_only,
set_earlier_declaration, get_earlier_declaration}): New methods.
* src/abg-ir.cc (add_decl_to_scope): If a decl is already in a
scope, don't add it to this scope.
(get_global_scope): Make this work when passed an instance of
global_scope.
(dynamic_type_hash::operator()): Add support for method_type.
(method_type::{method_type, set_class_type, ~method_type, })
(method_type_hash::operator()): New defintions.
(function_decl::get_type, class_decl::class_decl): Move these
out-of-line here.
(class_decl::method_decl::{method_decl, ~method_decl, get_type}):
New definitions.
(class_decl::member_function::member_function): Move this
out-of-line here. Support method_decl.
(class_decl::data_member::data_member): Likewise.
(class_decl_hash::operator()): Guard this against endless loop.
* src/abg-reader.cc (write_class_is_declaration_only): New static
function.
(write_var_decl): Take a flag to write the mangled name or not.
(write_function_decl): Take a flag to skip the first parameter.
(write_cdtor_const_static): Use 'yes' instead of 'true' as value
of the properties.
(write_decl, write_function_template_decl): Adjust wrt the new
signatures of write_var_decl and write_function_decl.
(write_enum_type_decl): Simplify call to write_location.
(write_class_decl): Support serializing declaration-only classes.
* src/abg-writer.cc:
* tests/data/test-read-write/test17.xml: New test input.
* tests/test-read-write.cc: De-serialize the above, and serialize it back.
* tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
|
|
|
|
2014-01-17 10:16:54 +00:00
|
|
|
decl_base_sptr
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_earlier_declaration() const;
|
2013-04-25 13:42:04 +00:00
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
void
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
add_base_specifier(shared_ptr<base_spec> b);
|
2013-04-25 13:42:04 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const base_specs&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_base_specifiers() const;
|
2013-04-25 13:42:04 +00:00
|
|
|
|
|
|
|
void
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
insert_member_type(type_base_sptr t,
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
declarations::iterator before);
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
|
|
|
|
void
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
add_member_type(type_base_sptr t);
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
type_base_sptr
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
add_member_type(type_base_sptr t, access_specifier a);
|
2013-04-25 13:42:04 +00:00
|
|
|
|
Prune types that are not ref'ed by public decls
* 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>
2013-12-13 16:30:41 +00:00
|
|
|
void
|
|
|
|
remove_member_type(type_base_sptr t);
|
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const member_types&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_member_types() const;
|
2013-04-25 13:42:04 +00:00
|
|
|
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
void
|
|
|
|
add_data_member(var_decl_sptr v, access_specifier a,
|
|
|
|
bool is_laid_out, bool is_static,
|
|
|
|
size_t offset_in_bits);
|
2013-04-25 13:42:04 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const data_members&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_data_members() const;
|
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-04-23 09:27:32 +00:00
|
|
|
|
2015-06-22 09:17:38 +00:00
|
|
|
const data_members&
|
|
|
|
get_non_static_data_members() const;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
void
|
2014-03-20 10:56:56 +00:00
|
|
|
add_member_function(method_decl_sptr f,
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
access_specifier a,
|
2014-04-14 12:56:51 +00:00
|
|
|
bool is_virtual,
|
Avoid missing member types while reading bi files
* include/abg-fwd.h (get_type_declaration): Declare function.
* include/abg-ir.h (class decl_base): Add class_decl as a friend.
This to be able to call decl_base::set_scope from class_decl.
(scope_decl::add_member_decl): Make this virtual protected, so
that it can be called (virtually) from e.g, class_decl.
(type_decl_sptr, typedef_decl_sptr): New convenience typedefs.
(class_decl::add_member_decl): New virtual overload for
scope_decl::add_member_decl.
(class_decl::{add_member_type, add_data_member,
add_member_function}): New overloads.
* src/abg-ir.cc (add_decl_to_scope): Benign style cleanup.
(get_type_declaration): Define new function.
(class_decl::add_member_decl): New method.
(class_decl::add_member_type): Avoid silently added a new member
type when that member type has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there. Also add a new overload that constructs
the member type out of a classic type and adds it to the class.
(class_decl::{add_data_member, add_member_function}): Likewise.
(class_decl::{add_member_function_template,
add_member_class_template}): Avoid silently added a new member
template when that template has already been (perhaps
inadvertently) added to a scope already. Rather, put a strict
assert in place there.
* src/abg-reader.cc (push_decl_to_current_scope): Take a an extra
flag saying if the current decl should be added to the current
scope as well (in addition to being pushed onto the stack of
scopes maintained in the reader context).
(push_and_key_type_decl): Likewise, take that extra flag and pass
it to push_decl_to_current_scope.
(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_function_tdecl, build_class_tdecl): Likewise.
(build_class_decl): Likewise. When building member data, types,
and functions, make sure /not/ to add the data, type of function to
the current scope before adding it to the class_decl. This was
making the member not being added to the class because it already
had a scope.
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter)
(build_type): Adjust to add the template parm to the current scope
explicitly, like previously.
(handle_type_decl): Use build_type_decl function. Add the
type_decl to the current scope, like previously.
(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): Adjust to add the decl to the current scope,
like previously.
* tests/data/test-read-write/test21.xml: New test input with
member type(def).
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
|
|
|
size_t vtable_offset,
|
|
|
|
bool is_static, bool is_ctor,
|
|
|
|
bool is_dtor, bool is_const);
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const member_functions&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_member_functions() const;
|
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-04-23 09:27:32 +00:00
|
|
|
|
2014-04-14 12:56:51 +00:00
|
|
|
const member_functions&
|
|
|
|
get_virtual_mem_fns() const;
|
2013-10-24 15:15:57 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
void
|
|
|
|
sort_virtual_mem_fns();
|
|
|
|
|
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-04-23 09:27:32 +00:00
|
|
|
void
|
2013-05-02 15:12:55 +00:00
|
|
|
add_member_function_template(shared_ptr<member_function_template>);
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const member_function_templates&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_member_function_templates() const;
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-05-02 15:12:55 +00:00
|
|
|
void
|
2013-08-02 23:30:56 +00:00
|
|
|
add_member_class_template(shared_ptr<member_class_template> m);
|
2013-05-02 15:12:55 +00:00
|
|
|
|
2013-08-06 17:18:35 +00:00
|
|
|
const member_class_templates&
|
Make class_decl pimpl and harden comparison infloop prevention
* include/abg-ir.h (class_decl::{priv}): New private data member.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, get_earlier_declaration,
add_base_specifier, get_base_specifiers, get_member_types,
get_data_members, get_member_functions,
get_member_function_templates, get_member_class_templates}): Move
these methods out-of-line.
(class_decl::{comparison_started_,
declaration_,is_declaration_only_, definition_of_declaration,
is_struct_, bases_, member_types_, data_members_,
member_functions_, member_function_template,
member_class_templates_}): Move these data members into the pimpl
in ...
* src/abg-ir.cc
(class_decl::priv::{declaration_,is_declaration_only_,
definition_of_declaration, is_struct_, bases_, member_types_,
data_members_, member_functions_, member_function_template,
member_class_templates_}): ... here.
(class_decl::priv::classes_being_compared_): New data member.
(class_decl::priv::priv): Initialize the data members.
(class_decl::priv::{mark_as_being_compared,
unmark_as_being_compared, comparison_started): New methods.
(class_decl::{get_is_declaration_only, set_is_declaration_only,
is_struct, get_definition_of_declaration, add_base_specifier,
get_base_specifiers, get_member_types, get_data_members,
get_member_functions, get_member_function_templates,
get_member_class_templates}): Move these out-of-line in here.
(class_decl::{class_decl, set_definition_of_declaration,
set_earlier_declaration, insert_member_type, add_member_type,
add_data_member, add_member_function,
add_member_function_template, add_member_class_template,
has_no_base_nor_member}): Adjust.
(class_decl::operator==): Harden inf-loop prevention during class
comparison using the new priv::mark/unmark_as_being_compared()
functions. Now comparison of a class really compares member
functions again. And it is *slooow*. I should probably change
this to compare only virtual member functions. But at least this
should be correct and robust for now.
* tests/data/test-diff-filter/test0-report.txt: Adjust.
* test01-report.txt: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-13 16:19:53 +00:00
|
|
|
get_member_class_templates() const;
|
2013-05-02 15:12:55 +00:00
|
|
|
|
2013-08-02 03:16:22 +00:00
|
|
|
bool
|
|
|
|
has_no_base_nor_member() const;
|
2013-06-25 13:16:51 +00:00
|
|
|
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
bool
|
|
|
|
has_virtual_member_functions() const;
|
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
virtual bool
|
2013-10-10 14:58:30 +00:00
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const type_base&) const;
|
|
|
|
|
|
|
|
bool
|
2013-04-30 14:43:20 +00:00
|
|
|
operator==(const class_decl&) const;
|
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-04-23 09:27:32 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-02 23:30:56 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
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-20 10:30:04 +00:00
|
|
|
|
2013-04-30 14:43:20 +00:00
|
|
|
virtual ~class_decl();
|
2014-10-02 10:17:48 +00:00
|
|
|
|
|
|
|
friend void
|
|
|
|
fixup_virtual_member_function(method_decl_sptr method);
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
|
|
|
|
friend bool
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
equals(const class_decl&, const class_decl&, change_kind*);
|
2013-10-04 15:03:34 +00:00
|
|
|
};// end class class_decl
|
|
|
|
|
2014-10-02 10:17:48 +00:00
|
|
|
void
|
|
|
|
fixup_virtual_member_function(class_decl::method_decl_sptr method);
|
|
|
|
|
Fix and add missing hashing through the virtual decl_base::get_hash
* include/abg-ir.h (struct {scope_decl, non_type_tparameter,
type_composition, class_decl}::hash): Declare hashers.
({scope_decl, var_decl, non_type_tparameter, type_composition,
class_decl}::get_hash): Provide new overloads of the get_hash.
* src/abg-hash.cc ({type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
enum_type_decl, typedef_decl, var_decl,
function_decl}::hash::operator()): If the hash is being
calculated, do not use the not-yet fully calculated hash value.
Rather, calculate the hash, cache it and return the value.
({class_decl, non_type_tparameter}::hash::operator()): Moved the
{class_decl, non_type_tparameter}::hash declaration out of here
and stick it in include/abg-ir.h. Keep the definition of the
hashing operators here though.
(type_composition::hash::operator()): New operator definition.
* src/abg-ir.cc ({scope_decl, var_decl, class_decl,
non_type_tparameter, type_composition}::get_hash): Define new
virtual overload.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-04-09 15:11:32 +00:00
|
|
|
/// Hasher for the @ref class_decl type
|
|
|
|
struct class_decl::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const class_decl& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const class_decl* t) const;
|
|
|
|
}; // end struct class_decl::hash
|
|
|
|
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
enum access_specifier
|
|
|
|
get_member_access_specifier(const decl_base&);
|
|
|
|
|
|
|
|
enum access_specifier
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
get_member_access_specifier(const decl_base_sptr&);
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
|
|
|
|
void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_access_specifier(decl_base&,
|
|
|
|
access_specifier);
|
|
|
|
|
|
|
|
void
|
|
|
|
set_member_access_specifier(const decl_base_sptr&,
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
access_specifier);
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
|
2013-11-20 18:13:55 +00:00
|
|
|
std::ostream&
|
Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
(as_non_member_type, as_non_member_class_decl): Remove.
(has_scope, is_member_decl, is_member_type): New function
declarations. (get_member_is_static, set_member_is_static):
Likewise. * include/abg-ir.h (enum access_specifier): Move to
the abigail:: namespace, from ...
(class_decl::access_specifier): ... here. (class
context_rel): New type. (decl_base::hash_as_member): New
hasher. (decl_base::context_): Change the type of this to
context_rel_sptr. (decl_base::get_context_rel): New protected
getter. (decl_base::get_scope): Move this out-of-line.
(class_decl::member_type): Remove.
(class_decl::member_types): Adjust this typedef.
(class_decl::{insert,add}_member_type): Make these take a
type_base_sptr now. (class_decl::add_member_type): Change the
overload that returned a member_type to return a
type_base_sptr. (get_member_access_specifier,
set_member_access_specifier): New function declarations. *
include/abg-comparison.h (class member_type_diff): Remove.
(compute_diff): Remove the overload for member_type_diff. *
src/abg-comparison.cc (compute_diff_for_types): Adjust for the
removal of class_decl::member_type.
(maybe_report_diff_for_class_members): New static function.
(report_name_size_and_alignment_changes): Do not report a name
change just because of a struct -> class change. ({var_diff,
enum_diff, function_decl_diff}::report): Use the new
maybe_report_diff_for_class_members. (class_diff::report):
Adjust for the removal of class_decl::member_type. Use the
new maybe_report_diff_for_class_members. (class member_diff):
Remove. * src/abg-dwarf-reader.cc (die_access_specifier)
(get_scope_for_die, build_translation_unit_and_add_to_ir)
(build_class_type_and_add_to_ir, build_function_decl)
(build_ir_node_from_die): Adjust. * abg-hash.cc (struct
decl_base::hash_as_member): Define. ({scope_type_decl,
enum_type_decl, typedef_decl}::hash::operator()): Use the
decl_base::hash_as_member.
* src/abg-ir.cc (decl_base::decl_base): Adjust.
(decl_base::get_scope): New out-of-line getter.
(decl_base::{operator==, set_scope): Adjust.
(has_scope, is_member_decl, is_member_type)
(get_member_access_specifier, set_member_access_specifier)
(get_member_is_static, set_member_is_static, is_at_class_scope):
New function definitions.
(as_non_member_type, as_non_member_class_decl): Remove.
(get_node_name): Adjust.
(class_decl::{class_decl, set_earlier_declaration,
insert_member_decl, insert_member_type, add_member_type):
Likewise.
(class_decl::member_type::*) Remove.
* src/abg-reader.cc (read_access, build_qualified_type_decl)
(build_reference_type_def, build_typedef_decl)
(build_class_decl): Adjust.
* src/abg-writer.cc (write_access, write_member_type)
(write_class_decl): Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 10:13:54 +00:00
|
|
|
operator<<(std::ostream&, access_specifier);
|
2013-11-20 18:13:55 +00:00
|
|
|
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
bool
|
|
|
|
operator==(class_decl_sptr l, class_decl_sptr r);
|
|
|
|
|
2013-08-08 02:50:07 +00:00
|
|
|
/// The base class for member types, data members and member
|
2013-10-04 15:03:34 +00:00
|
|
|
/// functions. Its purpose is mainly to carry the access specifier
|
|
|
|
/// (and possibly other properties that might be shared by all class
|
|
|
|
/// members) for the member.
|
2013-08-08 02:50:07 +00:00
|
|
|
class class_decl::member_base
|
|
|
|
{
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
protected:
|
2013-09-26 14:45:00 +00:00
|
|
|
enum access_specifier access_;
|
|
|
|
bool is_static_;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Fix class scope setting & member type de-serializing from dwarf
* 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>
2014-01-13 11:27:47 +00:00
|
|
|
private:
|
2013-08-08 02:50:07 +00:00
|
|
|
// Forbidden
|
|
|
|
member_base();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
member_base(access_specifier a, bool is_static = false)
|
2013-09-26 14:45:00 +00:00
|
|
|
: access_(a), is_static_(is_static)
|
2013-10-10 08:11:35 +00:00
|
|
|
{}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-02-21 14:08:52 +00:00
|
|
|
/// Getter for the access specifier of this member.
|
|
|
|
///
|
|
|
|
/// @return the access specifier for this member.
|
2013-08-08 02:50:07 +00:00
|
|
|
access_specifier
|
|
|
|
get_access_specifier() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return access_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-02-21 14:08:52 +00:00
|
|
|
/// Setter for the access specifier of this member.
|
|
|
|
///
|
|
|
|
/// @param a the new access specifier.
|
|
|
|
void
|
|
|
|
set_access_specifier(access_specifier a)
|
|
|
|
{access_ = a;}
|
|
|
|
|
2014-02-19 15:04:45 +00:00
|
|
|
/// @return true if the member is static, false otherwise.
|
2013-08-08 02:50:07 +00:00
|
|
|
bool
|
2014-02-19 15:04:45 +00:00
|
|
|
get_is_static() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return is_static_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-02-19 15:04:45 +00:00
|
|
|
/// Set a flag saying if the parameter is static or not.
|
|
|
|
///
|
|
|
|
/// @param f set to true if the member is static, false otherwise.
|
|
|
|
void
|
|
|
|
set_is_static(bool f)
|
|
|
|
{is_static_ = f;}
|
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const member_base& o) const;
|
2013-10-04 15:03:34 +00:00
|
|
|
};// end class class_decl::member_base
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
bool
|
|
|
|
equals(const class_decl::base_spec&,
|
|
|
|
const class_decl::base_spec&,
|
Get out as early as possible when comparing different ABI artefacts
When the the of 'equals' overloaded functions was introduced, it was
to get the possibility to have a hint about the kind of difference
(local or sub-type difference) there was between two different ABI
artifacts. To do that, it was quite common to keep on comparing the
two artifacts even when we knew there were different, because we need
to know all the kinds of the differences there are.
Now, profiling shows that doing this generally is too costly. So,
this patch adds a way to doing it only when necessary.
* include/abg-ir.h (equal): Turn the last parameter of type
change_kind& into a change_kind*. Do this on all the overloads'
declarations.
* src/abg-ir.cc (equal): Do the same for the definitions of the
overloads and adapt them to report about the kind of changes makes
the two ABI artifact different -- only if the change_kind pointer
is non-null. That way, callers have a way to choose if they want
to go the expensive route of knowing what kind of changes there
are.
({decl_base, scope_decl, type_base, scope_type_decl,
qualified_type_def, pointer_type_def, pointer_type_def,
reference_type_def, array_type_def, enum_type_decl, typedef_decl,
var_decl, function_type, function_decl, function_decl::parameter,
class_decl::base_spec, class_decl}::operator==): Adjust to the new
signature of equals; call it with the change_kind* parameter set
to NULL.
* src/abg-comparison.cc ({var_diff, pointer_diff, array_diff,
reference_diff, qualified_type_diff, enum_diff, class_diff,
base_diff, scope_diff, fn_parm_diff, function_decl_diff,
type_decl_diff, typedef_diff}::has_local_changes): Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-05 17:15:35 +00:00
|
|
|
change_kind*);
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
|
2013-08-08 02:50:07 +00:00
|
|
|
/// Abstraction of a base specifier in a class declaration.
|
2014-03-18 10:27:02 +00:00
|
|
|
class class_decl::base_spec : public member_base,
|
|
|
|
public virtual decl_base
|
2013-08-08 02:50:07 +00:00
|
|
|
{
|
|
|
|
|
2013-09-26 14:45:00 +00:00
|
|
|
shared_ptr<class_decl> base_class_;
|
|
|
|
long offset_in_bits_;
|
|
|
|
bool is_virtual_;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
// Forbidden
|
|
|
|
base_spec();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
|
|
|
base_spec(shared_ptr<class_decl> base, access_specifier a,
|
|
|
|
long offset_in_bits = -1, bool is_virtual = false);
|
|
|
|
|
|
|
|
base_spec(shared_ptr<type_base> base, access_specifier a,
|
|
|
|
long offset_in_bits = -1, bool is_virtual = false);
|
|
|
|
|
2014-02-10 13:13:24 +00:00
|
|
|
const shared_ptr<class_decl>&
|
2013-08-08 02:50:07 +00:00
|
|
|
get_base_class() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return base_class_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
get_is_virtual() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return is_virtual_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
long
|
|
|
|
get_offset_in_bits() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return offset_in_bits_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const decl_base&) const;
|
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const member_base&) const;
|
2014-03-20 12:34:00 +00:00
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
get_hash() const;
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
traverse(ir_node_visitor&);
|
2013-10-10 14:58:30 +00:00
|
|
|
};// end class class_decl::base_spec
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
bool
|
Write comparison functions that hint at the kind of changes they see
* include/abg-ir.h (enum change_kind): Declare new enum.
(operator|(change_kind, change_kind), operator&(change_kind,
change_kind), operator|=(change_kind&, change_kind)): Declare new bit-wise
operators for the new enum change_kind.
(equals): Declare this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
(class_decl::base_spec::operator(const decl_base&)): Declare new
equality operator.
* src/abg-ir.cc (operator|(change_kind l, change_kind r))
(operator&(change_kind l, change_kind r), operator|=(change_kind&
l, change_kind r), operator&=(change_kind& l, change_kind r)):
Define these new operators.
(equals): Define this new comparison function for decl_base,
scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl, and
class_decl::base_spec.
({decl_base, scope_decl, type_base, type_decl, scope_type_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_type, class_decl,
class_decl::base_spec}::operator==): Re-write these comparison
operators in terms of their relevant equal() functions.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-13 14:16:12 +00:00
|
|
|
operator==(const class_decl::base_spec_sptr l,
|
|
|
|
const class_decl::base_spec_sptr r);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
class mem_fn_context_rel;
|
|
|
|
|
|
|
|
/// A convenience typedef for a shared pointer to @ref
|
|
|
|
/// mem_fn_context_rel.
|
|
|
|
typedef shared_ptr<mem_fn_context_rel> mem_fn_context_rel_sptr;
|
|
|
|
|
|
|
|
/// Abstraction of a member function context relationship. This
|
|
|
|
/// relates a member function to its parent class.
|
|
|
|
class mem_fn_context_rel : public context_rel
|
|
|
|
{
|
|
|
|
protected:
|
2014-04-14 12:56:51 +00:00
|
|
|
bool is_virtual_;
|
2014-03-20 10:56:56 +00:00
|
|
|
size_t vtable_offset_in_bits_;
|
|
|
|
bool is_constructor_;
|
|
|
|
bool is_destructor_;
|
|
|
|
bool is_const_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
mem_fn_context_rel()
|
|
|
|
: context_rel(),
|
2014-04-14 12:56:51 +00:00
|
|
|
is_virtual_(false),
|
2014-03-20 10:56:56 +00:00
|
|
|
vtable_offset_in_bits_(0),
|
|
|
|
is_constructor_(false),
|
|
|
|
is_destructor_(false),
|
|
|
|
is_const_(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
mem_fn_context_rel(scope_decl* s)
|
|
|
|
: context_rel(s),
|
2014-04-14 12:56:51 +00:00
|
|
|
is_virtual_(false),
|
2014-03-20 10:56:56 +00:00
|
|
|
vtable_offset_in_bits_(0),
|
|
|
|
is_constructor_(false),
|
|
|
|
is_destructor_(false),
|
|
|
|
is_const_(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
mem_fn_context_rel(scope_decl* s,
|
|
|
|
bool is_constructor,
|
|
|
|
bool is_destructor,
|
|
|
|
bool is_const,
|
2014-04-14 12:56:51 +00:00
|
|
|
bool is_virtual,
|
2014-03-20 10:56:56 +00:00
|
|
|
size_t vtable_offset_in_bits,
|
|
|
|
access_specifier access,
|
|
|
|
bool is_static)
|
|
|
|
: context_rel(s, access, is_static),
|
2014-04-14 12:56:51 +00:00
|
|
|
is_virtual_(is_virtual),
|
2014-03-20 10:56:56 +00:00
|
|
|
vtable_offset_in_bits_(vtable_offset_in_bits),
|
|
|
|
is_constructor_(is_constructor),
|
|
|
|
is_destructor_(is_destructor),
|
|
|
|
is_const_(is_const)
|
|
|
|
{}
|
|
|
|
|
2014-04-14 12:56:51 +00:00
|
|
|
bool
|
|
|
|
is_virtual() const
|
|
|
|
{return is_virtual_;}
|
|
|
|
|
|
|
|
void
|
|
|
|
is_virtual(bool is_virtual)
|
|
|
|
{is_virtual_ = is_virtual;}
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
/// Getter for the vtable offset property.
|
|
|
|
///
|
|
|
|
/// This is the vtable offset of the member function of this
|
|
|
|
/// relation.
|
|
|
|
///
|
|
|
|
/// @return the vtable offset property of the relation.
|
|
|
|
size_t
|
|
|
|
vtable_offset() const
|
|
|
|
{return vtable_offset_in_bits_;}
|
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
/// Setter for the vtable offset property.
|
|
|
|
///
|
|
|
|
/// This is the vtable offset of the member function of this
|
|
|
|
/// relation.
|
|
|
|
///
|
|
|
|
/// @partam s the new vtable offset.
|
|
|
|
void
|
|
|
|
vtable_offset(size_t s)
|
|
|
|
{vtable_offset_in_bits_ = s;}
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
/// Getter for the 'is-constructor' property.
|
|
|
|
///
|
|
|
|
/// This tells if the member function of this relation is a
|
|
|
|
/// constructor.
|
|
|
|
///
|
|
|
|
/// @return the is-constructor property of the relation.
|
|
|
|
bool
|
|
|
|
is_constructor() const
|
|
|
|
{return is_constructor_;}
|
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
/// Setter for the 'is-constructor' property.
|
|
|
|
///
|
|
|
|
/// @param f the new value of the the property. Is true if this is
|
|
|
|
/// for a constructor, false otherwise.
|
|
|
|
void
|
|
|
|
is_constructor(bool f)
|
|
|
|
{is_constructor_ = f;}
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
/// Getter for the 'is-destructor' property.
|
|
|
|
///
|
|
|
|
/// Tells if the member function of this relation is a destructor.
|
|
|
|
///
|
|
|
|
/// @return the is-destructor property of the relation;
|
|
|
|
bool
|
|
|
|
is_destructor() const
|
|
|
|
{return is_destructor_;}
|
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
/// Setter for the 'is-destructor' property.
|
|
|
|
///
|
|
|
|
/// @param f the new value of the property. Is true if this is for
|
|
|
|
/// a destructor, false otherwise.
|
|
|
|
void
|
|
|
|
is_destructor(bool f)
|
|
|
|
{is_destructor_ = f;}
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
/// Getter for the 'is-const' property.
|
|
|
|
///
|
|
|
|
/// Tells if the member function of this relation is a const member
|
|
|
|
/// function.
|
|
|
|
///
|
|
|
|
/// @return the 'is-const' property of the relation.
|
|
|
|
bool
|
|
|
|
is_const() const
|
|
|
|
{return is_const_;}
|
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
/// Setter for the 'is-const' property.
|
|
|
|
///
|
|
|
|
/// @param f the new value of the property. Is true if this is for
|
|
|
|
/// a const entity, false otherwise.
|
|
|
|
void
|
|
|
|
is_const(bool f)
|
|
|
|
{is_const_ = f;}
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
virtual ~mem_fn_context_rel();
|
|
|
|
}; // end class mem_fn_context_rel
|
|
|
|
|
2013-08-08 02:50:07 +00:00
|
|
|
/// Abstraction of the declaration of a method. This is an
|
|
|
|
/// implementation detail for class_decl::member_function.
|
|
|
|
class class_decl::method_decl : public function_decl
|
|
|
|
{
|
|
|
|
method_decl();
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
virtual void
|
|
|
|
set_scope(scope_decl*);
|
|
|
|
|
2013-08-08 02:50:07 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
method_decl(const std::string& name, shared_ptr<method_type> type,
|
|
|
|
bool declared_inline, location locus,
|
|
|
|
const std::string& mangled_name = "",
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_GLOBAL);
|
|
|
|
|
|
|
|
method_decl(const std::string& name,
|
|
|
|
shared_ptr<function_type> type,
|
|
|
|
bool declared_inline,
|
|
|
|
location locus,
|
|
|
|
const std::string& mangled_name = "",
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_GLOBAL);
|
|
|
|
|
|
|
|
method_decl(const std::string& name, shared_ptr<type_base> type,
|
|
|
|
bool declared_inline, location locus,
|
|
|
|
const std::string& mangled_name = "",
|
|
|
|
visibility vis = VISIBILITY_DEFAULT,
|
|
|
|
binding bind = BINDING_GLOBAL);
|
|
|
|
|
|
|
|
/// @return the type of the current instance of the
|
|
|
|
/// class_decl::method_decl.
|
|
|
|
const shared_ptr<method_type>
|
|
|
|
get_type() const;
|
|
|
|
|
|
|
|
void
|
|
|
|
set_type(shared_ptr<method_type> fn_type)
|
2014-03-20 10:56:56 +00:00
|
|
|
{function_decl::set_type(fn_type);}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
friend bool
|
|
|
|
get_member_function_is_ctor(const function_decl&);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_is_ctor(function_decl&, bool);
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
friend void
|
|
|
|
set_member_function_is_ctor(const function_decl_sptr&, bool);
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
friend bool
|
|
|
|
get_member_function_is_dtor(const function_decl&);
|
2013-10-10 14:58:30 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_is_dtor(function_decl&, bool);
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
friend void
|
|
|
|
set_member_function_is_dtor(const function_decl_sptr&, bool);
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
friend bool
|
|
|
|
get_member_function_is_static(const function_decl&);
|
2013-10-10 14:58:30 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend void
|
|
|
|
set_member_function_is_static(const function_decl&, bool);
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
friend bool
|
|
|
|
get_member_function_is_const(const function_decl&);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_is_const(function_decl&, bool);
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
friend void
|
|
|
|
set_member_function_is_const(const function_decl_sptr&, bool);
|
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
friend size_t
|
|
|
|
get_member_function_vtable_offset(const function_decl&);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_vtable_offset(function_decl&, size_t);
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
|
Pass a bunch of smart pointers by reference
Some smart pointers handling got high on performance profiles. I am
passing those by reference here.
* include/abg-fwd.h (get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): Declare the smart pointer
parameter of these as being passed by reference.
* include/abg-ir.h (get_member_access_specifier)
(get_member_is_static, get_member_access_specifier)
(set_member_function_is_ctor, set_member_function_is_const)
(set_member_function_vtable_offset): Likewise, for these friend
declarations to the decl_base type.
* src/abg-ir.cc (get_member_access_specifier)
(get_member_is_static, is_member_function)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual): In these definitions, the smart
pointer parameter is passed by reference.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 17:41:44 +00:00
|
|
|
friend void
|
|
|
|
set_member_function_vtable_offset(const function_decl_sptr&, size_t);
|
|
|
|
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
friend bool
|
|
|
|
get_member_function_is_virtual(const function_decl&);
|
|
|
|
|
|
|
|
friend void
|
Make decl_base::get_context_rel() return a naked pointer
Accessing the context relationship of declarations and setting some
member properties appear to be high in performance profiles due to
shared pointer handling. This patch makes the context relationship
accessors return a naked pointer and also passes a bunch of shared
pointer as references around.
* include/abg-fwd.h (set_member_is_static): Add an overload that
takes the member as a reference to a smart pointer.
(set_member_function_{is_dtor, is_ctor, is_const, vtable_offset,
is_virtual}): Pass the member function as a reference.
(set_member_function_is_const, set_member_function_is_virtual):
Pass the member function as a non-const reference.
* include/abg-ir.h (decl_base::get_context_rel): Return a naked
pointer.
(set_member_is_static, set_member_function_is_virtual): Adjust
this friend declaration.
(set_member_access_specifier): Add an overload that takes a
reference to the member. Pass a reference to smart pointer to the
other overload.
(set_member_function_is_{is_ctor,is_dtor,is_const,is_virtual,vtable_offset}):
Take a non-const reference to function_decl.
* src/abg-ir.cc (decl_base::get_context_rel): Likewise.
(equals(const decl_base&, const decl_base&, change_kind*)):
Adjust.
(equals(const var_decl&, const var_decl&, change_kind*)):
Likewise.
(get_member_access_specifier, get_member_is_static)
(set_data_member_offset, get_data_member_offset)
(set_data_member_is_laid_out, get_data_member_is_laid_out)
(get_member_function_is_ctor, set_member_function_is_ctor)
(get_member_function_is_dtor, set_member_function_is_dtor)
(get_member_function_is_const, set_member_function_is_const)
(get_member_function_vtable_offset)
(set_member_function_vtable_offset)
(get_member_function_is_virtual, set_member_function_is_virtual):
Likewise.
(set_member_access_specifier): Add an overload that takes a
reference to decl_base.
(set_member_is_static, set_member_function_{is_dtor, is_ctor,
is_const, vtable_offset, is_virtual}): Pass the member function as
a reference.): Add an overload that takes the member as a
reference, and write the older overload in terms of the new one.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-03-10 10:45:46 +00:00
|
|
|
set_member_function_is_virtual(function_decl&, bool);
|
Fix reading several clones of the same member function from DWARF
* include/abg-fwd.h (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset): Declare new functions.
* include/abg-ir.h (class_decl::sort_virtual_mem_fns): Declare new
member function.
(mem_fn_context_rel::{vtable_offset, is_constructor is_destructor,
is_const}): Add these setters.
(set_member_function_is_ctor, set_member_function_is_dtor)
(set_member_function_is_static, set_member_function_is_const)
(set_member_function_vtable_offset)
(set_member_function_is_virtual): Declare these new friend
function to class class_decl::method_decl.
* src/abg-dwarf-reader.cc (finish_member_function_reading): Split
this out from build_class_type_and_add_to_ir. Use the new setters
for member functions properties introduced above.
(build_class_type_and_add_to_ir): Factorize the creation of member
function by using build_ir_node_from_die. Once that function has
created the member function in a rather generic way, use the new
finish_member_function_reading to set the remaining specific
properties for member functions.
(build_function_decl): When called to read additional properties
of a function_decl, allow this to read and update the elf symbol
properties too. This is useful for building a clone of a function
that already has an elf symbol.
(build_ir_node_from_die): When building a function decl, consider
the case of a DIE that has both DW_AT_specification and
DW_AT_abstract_origin set. That is, DW_AT_abstract_origin is set,
and the origin has DW_AT_specification set. This is basically a
clone of a function that implements an interface (this happens for
destructors, for instance). In this case, really do the cloning
of the interface implementation. If the cloned function happens
to be member function, use finish_member_function_reading to read
the properties relevant to its method-ness.
* src/abg-ir.cc (set_member_function_is_ctor)
(set_member_function_is_dtor, set_member_function_is_const)
(set_member_function_vtable_offset)
(class_decl::sort_virtual_mem_fns): Define new functions.
(sort_virtual_member_functions): Define new static function.
(struct virtual_member_function_less_than): New functor.
(class_decl::add_member_function): Keep virtual member functions
vector sorted.
* data/test-read-dwarf/test1.abi: Adjust. Now, both the
cdtor specification and all the clones that implements the
different are emitted.
* data/test-read-dwarf/test2.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-10-01 15:42:45 +00:00
|
|
|
|
2014-03-20 10:56:56 +00:00
|
|
|
virtual ~method_decl();
|
|
|
|
};// end class class_decl::method_decl
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
/// Abstract a member function template.
|
|
|
|
class class_decl::member_function_template
|
Fix hashing of member types
* 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}::hash::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>
2014-01-17 09:13:49 +00:00
|
|
|
: public member_base, public virtual decl_base
|
2013-08-08 02:50:07 +00:00
|
|
|
{
|
2013-09-26 14:45:00 +00:00
|
|
|
bool is_constructor_;
|
|
|
|
bool is_const_;
|
|
|
|
shared_ptr<function_tdecl> fn_tmpl_;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
// Forbiden
|
|
|
|
member_function_template();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
member_function_template(function_tdecl_sptr f,
|
2013-08-08 06:54:44 +00:00
|
|
|
access_specifier access, bool is_static,
|
2013-10-15 12:17:13 +00:00
|
|
|
bool is_constructor, bool is_const)
|
Fix hashing of member types
* 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}::hash::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>
2014-01-17 09:13:49 +00:00
|
|
|
: decl_base(f->get_name(), location()),
|
|
|
|
member_base(access, is_static), is_constructor_(is_constructor),
|
|
|
|
is_const_(is_const), fn_tmpl_(f)
|
2013-10-15 12:17:13 +00:00
|
|
|
{}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
is_constructor() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return is_constructor_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
is_const() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return is_const_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
operator const function_tdecl& () const
|
2013-10-10 08:11:35 +00:00
|
|
|
{return *fn_tmpl_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
function_tdecl_sptr
|
2013-08-08 06:54:44 +00:00
|
|
|
as_function_tdecl() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return fn_tmpl_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const member_base& o) const;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-08 02:50:07 +00:00
|
|
|
traverse(ir_node_visitor&);
|
2013-10-04 15:03:34 +00:00
|
|
|
};// end class class_decl::member_function_template
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
bool
|
|
|
|
operator==(class_decl::member_function_template_sptr l,
|
|
|
|
class_decl::member_function_template_sptr r);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
/// Abstracts a member class template template
|
2013-08-27 11:55:45 +00:00
|
|
|
class class_decl::member_class_template
|
Fix hashing of member types
* 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}::hash::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>
2014-01-17 09:13:49 +00:00
|
|
|
: public member_base,
|
|
|
|
public virtual decl_base
|
2013-08-08 02:50:07 +00:00
|
|
|
{
|
2013-09-26 14:45:00 +00:00
|
|
|
shared_ptr<class_tdecl> class_tmpl_;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
|
|
|
// Forbidden
|
|
|
|
member_class_template();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// Hasher.
|
|
|
|
struct hash;
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
member_class_template(shared_ptr<class_tdecl> c,
|
2013-08-08 02:50:07 +00:00
|
|
|
access_specifier access, bool is_static)
|
Fix hashing of member types
* 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}::hash::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>
2014-01-17 09:13:49 +00:00
|
|
|
: decl_base(c->get_name(), location()),
|
|
|
|
member_base(access, is_static),
|
|
|
|
class_tmpl_(c)
|
2013-10-10 08:11:35 +00:00
|
|
|
{}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
operator const class_tdecl& () const
|
2013-09-26 14:45:00 +00:00
|
|
|
{ return *class_tmpl_; }
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2015-02-13 19:47:35 +00:00
|
|
|
class_tdecl_sptr
|
2013-08-08 06:54:44 +00:00
|
|
|
as_class_tdecl() const
|
2013-09-26 14:45:00 +00:00
|
|
|
{return class_tmpl_;}
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-10-10 14:58:30 +00:00
|
|
|
virtual bool
|
|
|
|
operator==(const member_base& o) const;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
operator==(const member_class_template&) const;
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2014-03-19 10:01:58 +00:00
|
|
|
virtual bool
|
2013-08-08 02:50:07 +00:00
|
|
|
traverse(ir_node_visitor& v);
|
2013-10-04 15:03:34 +00:00
|
|
|
};// end class class_decl::member_class_template
|
2013-08-08 02:50:07 +00:00
|
|
|
|
Un-debugged initial implementation of class diffing.
* include/abg-ir.h (decl_base::get_qualified_name): New
declaration.
(class_decl::{base_specs, member_types, data_members,
member_functions, member_function_templates,
member_class_templates}): Make all these containers be vectors,
rather than list. This makes these containers (like
class_decl::base_specs, class_decl::member_types, etc) be suitable
to be used by the core diffing algorithms to diff their content.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Declare
these new equality operators. These are to be used by the core
diffing algorithms when comparing two vectors of shared pointers
of members of class_decls.
* src/abg-ir.cc (decl_base::get_qualified_name): Define.
(class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the
containers type change to a vector.
(operator==(class_decl_sptr, class_decl_sptr))
(operator==(class_decl::member_type_sptr, class_decl::member_type_sptr))
(operator==(class_decl::base_spec_sptr,
class_decl::base_spec_sptr))
(operator==(class_decl::data_member_sptr,
class_decl::data_member_sptr))
(operator==(class_decl::member_function_sptr,
class_decl::member_function_sptr))
(operator==(class_decl::member_function_template_sptr,
class_decl::member_function_template_sptr))
(operator==(class_decl::member_class_template_sptr,
class_decl::member_class_template_sptr)): Define
these.
* include/abg-comparison.h (diff::scope_): Remove
(diff::{first_scope_, second_scope_}): New members.
(class_decl_diff::class_decl_diff): Pass the new scopes to this
constructor.
(class_decl_diff::{first_class_decl, second_class_decl})
(report_changes): New declarations.
* src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update
as per the declaration.
(class_decl_diff::{first_class_decl, second_class_decl}): Define
as per the declaration.
(compute_diff): Initial implementation for this.
(report_changes): Define.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
|
|
|
bool
|
|
|
|
operator==(class_decl::member_class_template_sptr l,
|
|
|
|
class_decl::member_class_template_sptr r);
|
2013-08-08 02:50:07 +00:00
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
// Forward declarations for select nested hashers.
|
|
|
|
struct type_base::shared_ptr_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const shared_ptr<type_base> t) const;
|
|
|
|
};
|
2013-08-27 11:55:45 +00:00
|
|
|
|
2013-08-07 09:07:29 +00:00
|
|
|
struct type_base::dynamic_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const type_base* t) const;
|
|
|
|
};
|
|
|
|
|
2014-02-07 19:18:11 +00:00
|
|
|
/// A hasher that manages to cache the computed hash and re-use it if
|
Implement hash caching
* 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, }::hash::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>
2014-01-13 15:02:46 +00:00
|
|
|
/// it is available.
|
|
|
|
struct type_base::cached_hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator() (const type_base* t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator() (const type_base_sptr t) const;
|
|
|
|
};
|
|
|
|
|
2014-02-07 11:14:38 +00:00
|
|
|
/// A hashing functor for instances and pointers of @ref var_decl.
|
|
|
|
struct var_decl::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const var_decl& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const var_decl* t) const;
|
|
|
|
}; //end struct var_decl::hash
|
|
|
|
|
|
|
|
/// A comparison functor for pointers to @ref var_decl.
|
|
|
|
struct var_decl::ptr_equal
|
|
|
|
{
|
|
|
|
/// Return true if the two instances of @ref var_decl are equal.
|
|
|
|
///
|
|
|
|
/// @param l the first variable to compare.
|
|
|
|
///
|
|
|
|
/// @param r the second variable to compare.
|
|
|
|
///
|
|
|
|
/// @return true if @p l equals @p r.
|
|
|
|
bool
|
|
|
|
operator()(const var_decl* l, const var_decl* r) const
|
|
|
|
{
|
|
|
|
if (l == r)
|
|
|
|
return true;
|
|
|
|
if (!!l != !!r)
|
|
|
|
return false;
|
|
|
|
return (*l == *r);
|
|
|
|
}
|
|
|
|
};// end struct var_decl::ptr_equal
|
|
|
|
|
|
|
|
/// A hashing functor fo instances and pointers of @ref function_decl.
|
|
|
|
struct function_decl::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const function_decl& t) const;
|
|
|
|
|
|
|
|
size_t
|
|
|
|
operator()(const function_decl* t) const;
|
|
|
|
};//end struct function_decl::hash
|
|
|
|
|
|
|
|
/// Equality functor for instances of @ref function_decl
|
|
|
|
struct function_decl::ptr_equal
|
|
|
|
{
|
|
|
|
/// Tests if two pointers to @ref function_decl are equal.
|
|
|
|
///
|
|
|
|
/// @param l the first pointer to @ref function_decl to consider in
|
|
|
|
/// the comparison.
|
|
|
|
///
|
|
|
|
/// @param r the second pointer to @ref function_decl to consider in
|
|
|
|
/// the comparison.
|
|
|
|
///
|
|
|
|
/// @return true if the two functions @p l and @p r are equal, false
|
|
|
|
/// otherwise.
|
|
|
|
bool
|
|
|
|
operator()(const function_decl* l, const function_decl* r) const
|
|
|
|
{
|
|
|
|
if (l == r)
|
|
|
|
return true;
|
|
|
|
if (!!l != !!r)
|
|
|
|
return false;
|
|
|
|
return (*l == *r);
|
|
|
|
}
|
|
|
|
};// function_decl::ptr_equal
|
|
|
|
|
Fix hashing of member types
* 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}::hash::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>
2014-01-17 09:13:49 +00:00
|
|
|
/// The hashing functor for class_decl::base_spec.
|
|
|
|
struct class_decl::base_spec::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const base_spec& t) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// The hashing functor for class_decl::member_base.
|
|
|
|
struct class_decl::member_base::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const member_base& m) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// The hashing functor for class_decl::member_function_template.
|
|
|
|
struct class_decl::member_function_template::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const member_function_template& t) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// The hashing functor for class_decl::member_class_template
|
|
|
|
struct class_decl::member_class_template::hash
|
|
|
|
{
|
|
|
|
size_t
|
|
|
|
operator()(const member_class_template& t) const;
|
|
|
|
};
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
struct function_tdecl::hash
|
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-04-23 09:27:32 +00:00
|
|
|
{
|
2013-08-07 09:07:29 +00:00
|
|
|
size_t
|
2013-08-08 06:54:44 +00:00
|
|
|
operator()(const function_tdecl& t) const;
|
2013-08-02 03:16:22 +00:00
|
|
|
};
|
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-04-23 09:27:32 +00:00
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
struct function_tdecl::shared_ptr_hash
|
2013-08-07 09:07:29 +00:00
|
|
|
{
|
|
|
|
size_t
|
2013-08-08 06:54:44 +00:00
|
|
|
operator()(const shared_ptr<function_tdecl> f) const;
|
2013-08-07 09:07:29 +00:00
|
|
|
};
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
struct class_tdecl::hash
|
2013-08-07 09:07:29 +00:00
|
|
|
{
|
|
|
|
size_t
|
2013-08-08 06:54:44 +00:00
|
|
|
operator()(const class_tdecl& t) const;
|
2013-08-07 09:07:29 +00:00
|
|
|
};
|
|
|
|
|
2013-08-08 06:54:44 +00:00
|
|
|
struct class_tdecl::shared_ptr_hash
|
2013-08-07 09:07:29 +00:00
|
|
|
{
|
|
|
|
size_t
|
2013-08-08 06:54:44 +00:00
|
|
|
operator()(const shared_ptr<class_tdecl> t) const;
|
2013-08-07 09:07:29 +00:00
|
|
|
};
|
|
|
|
|
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-20 10:30:04 +00:00
|
|
|
/// The base class for the visitor type hierarchy used for traversing
|
|
|
|
/// a translation unit.
|
|
|
|
///
|
|
|
|
/// Client code willing to get notified for a certain kind of node
|
|
|
|
/// during the IR traversal might want to define a visitor class that
|
2015-07-23 22:45:03 +00:00
|
|
|
/// inherit ir_node_visitor, overload the ir_node_visitor::visit_begin()
|
|
|
|
/// or ir_node_visitor::visit_end() method of its choice, and provide
|
|
|
|
/// and implementation for it. If either
|
|
|
|
/// ir_node_visitor::visit_begin() or ir_node_visitor::visit_end()
|
|
|
|
/// return false, it means the traversal has to stop immediately after
|
|
|
|
/// the methods' return. If the methods return true, it means the
|
|
|
|
/// traversal keeps going.
|
|
|
|
///
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
/// That new visitor class would then be passed to e.g,
|
2013-08-02 23:30:56 +00:00
|
|
|
/// translation_unit::traverse or to the traverse method of any type
|
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-20 10:30:04 +00:00
|
|
|
/// where the traversal is supposed to start from.
|
2013-09-26 21:33:23 +00:00
|
|
|
struct ir_node_visitor : public node_visitor_base
|
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-20 10:30:04 +00:00
|
|
|
{
|
Canonicalize types either early or late after TU reading
While trying to diff two identical files (abidiff foo.so foo.so) it
appeared that canonicalizing types during e.g, the DWARF reading
process was leading to subtle errors because it's extremely hard to
know when a type is complete. That is, during the building of a class
type C, a pointer to C can be built before C is complete. Worse, even
after reading the DIE (from DWARF) of class C, there can be DIE seen
later in the translation unit that modifies type C. In these late
cases, one needs to wait -- not only until C is fully built, but also
sometimes, after the translation unit is fully built -- to
canonicalize C and then the pointer to C. This kind of things.
So now there are two possible points in time when canonicalization of
a type can happen. It can happen early, when the type is built. This
is the case for basic types and composite types for which all
sub-types are canonicalized already. It can happen late, right after
we've finished reading the debug info for the current translation
unit.
So this patch fixes the IR traversal and uses that to walk the
translation unit (or even types) after it's built. It does away with
the first attempt to perform early canonicalizing only.
The patch also handles type canonicalizing while reading xml-abi
format.
* include/abg-fwd.h (is_class_type)
(type_has_non_canonicalized_subtype): Declare new functions.
(is_member_type): Remove the overload that takes a decl_base_sptr.
It's superfluous. We just need the one that takes a
type_base_sptr.
* include/abg-ir.h (translation_unit::{is_constructed,
set_is_constructed}): Add new methods.
(class_decl::has_virtual_member_functions): Likewise.
(class decl_base): Makes it virtually inherit ir_traversable_base.
(class type_base): Make this virtually inherit traversable_base
too.
(type_base::canonicalize): Renamed enable_canonical_equality
into this.
(type_base::traverse): Declare new virtual method.
(canonicalize): Renamed enable_canonical_equality into this.
(scope_type_decl::traverse): Declare new virtual method.
(namespace_decl::get_pretty_representation): Declare new virtual
method.
(function_type::traverse): Likewise.
(class_decl::base_spec::traverse): Likewise.
(ir_node_visitor::visit): Remove the overloads and replace each of
them with a pair of ...
(ir_node_visitor::{visit_begin, visit_end}): ... of these.
* include/abg-traverse.h (traversable_base::visiting): New
method.
(traversable_base::visiting_): New data member.
(traversable_base::traversable_base): New constructor.
* src/abg-ir.cc ({scope_decl, type_decl, namespace_decl,
qualified_type_def, pointer_type_def, reference_type_def,
array_type_def, enum_type_decl, typedef_decl, var_decl,
function_decl, function_decl::parameter, class_decl,
class_decl::member_function_template,
class_decl::member_class_template, function_tdecl,
class_tdecl}::traverse): Fix this to properly set the
traversable_base::visiting_ flag and to reflect the new signatures
of the ir_node_visitor methods.
({type_base, scope_type_decl, function_type,
class_decl::base_spec}::traverse): New method.
(type_base::get_canonical_type_for): Handle the case of the type
already having a canonical type. Properly hash the type using the
dynamic type hasher. Look through declaration-only classes to
consider the definition of the class instead. Fix logic to have a
single pointer of return, to ease debugging.
(canonicalize): Renamed enable_canonical_equality into this.
(namespace_decl::get_pretty_representation): Define new method.
(ir_node_visitor::visit): Replace each of these overloads with a
pair of visit_begin/visit_end ones.
(translation_unit::priv::is_constructed_): New data member.
(translation_unit::priv::priv): Initialize it.
(translation_unit::{is_constructed, set_is_constructed}): Define
new methods.
(is_member_type(const decl_base_sptr)): Remove.
(is_class_type(decl_base *d)): Define new function.
(class_decl::has_virtual_member_functions): Define new method.
(equals(const class_decl&, const class_decl&, change_kind*)): If
the containing translation unit is not constructed yet, do not
take virtual member functions in account when comparing the
classes. This is because when reading from DWARF, there can be
DIEs that change the number of virtual member functions after the
DIE of the class. So one needs to start taking virtual members
into account only after the translation unit has been constructed.
(class non_canonicalized_subtype_detector): Define new type.
(type_has_non_canonicalized_subtype): Define new function.
* src/abg-corpus.cc (symtab_build_visitor_type::visit): Renamed
this into symtab_build_visitor_type::visit_end.
* src/abg-dwarf-reader.cc (die_type_map_type): New typedef.
(die_class_map_type): This is now a typedef on a map of
Dwarf_Off/class_decl_sptr.
(read_context::{die_type_map_, alternate_die_type_map_,
types_to_canonicalize_, alt_types_to_canonicalize_}): New data
members.
(read_context::{associate_die_to_decl,
associate_die_to_decl_primary}): Make these methods public.
(read_context::{associate_die_to_type,
lookup_type_from_die_offset, is_wip_class_die_offset,
types_to_canonicalize, schedule_type_for_canonicalization}):
Define new methods.
(build_type_decl, build_enum_type)
(build_class_type_and_add_to_ir, build_qualified_type)
(build_pointer_type_def, build_reference_type, build_array_type)
(build_typedef_type, build_function_decl): Do not canonicalize
types here.
(maybe_canonicalize_type): Define new function.
(build_ir_node_from_die): Take a new flag that says if the ir node
is a member type/function or not. Early-canonicalize base types.
Canonicalize composite types that have only canonicalized
sub-types. Schedule the other types for late canonicalizing. For
class types, early canonicalize those that are non-member types,
that are fully constructed and that have only canonicalized
sub-types. Adjust to the new signature of build_ir_node_from_die.
(get_scope_for_die, build_namespace_decl_and_add_to_ir)
(build_qualified_type, build_pointer_type_def)
(build_reference_type, build_array_type, build_typedef_type)
(build_var_decl, build_function_decl): Adjust for the new
signature of build_ir_node_from_die.
(build_translation_unit_and_add_to_ir): Likewise. Perform the
late canonicalizing of the types that have been scheduled for
that.
(build_class_type_and_add_to_ir): Return a class_decl_sptr, not a
decl_base_sptr. Adjust for the new signature of
build_ir_node_from_die. Early canonicalize member types that are
created and added to a given class, or schedule them for late
canonicalizing.
* src/abg-reader.cc (class read_context::{m_wip_classes_map,
m_types_to_canonicalize}): New data members.
(read_context::{clear_types_to_canonicalize,
clear_wip_classes_map, mark_class_as_wip, unmark_class_as_wip,
is_wip_class, maybe_canonicalize_type,
schedule_type_for_late_canonicalizing,
perform_late_type_canonicalizing}): Add new method definitions.
(read_context::clear_per_translation_unit_data): Call
read_context::clear_types_to_canonicalize().
(read_translation_unit_from_input): Call
read_context::perform_late_type_canonicalizing() at the end of the
function.
(build_function_decl): Fix the function type canonicalizing (per
translation) that was already in place. Do the canonicalizing of
these only when the type is fully built. Oops. This was really
brokend. Also, when the function type is constructed, consider it
for type canonicalizing.
(build_type_decl): Early canonicalize basic types.
(build_qualified_type_decl, build_pointer_type_def)
(build_pointer_type_def, build_reference_type_def)
(build_array_type_def, build_enum_type_decl, build_typedef_decl):
Handle the canonicalizing for these composite types: either early
or late.
(build_class_decl): Likewise. Also, mark this class a 'being
built' until it's fully built. This helps the canonicalizing code
to know that it should leave a class alone until it's fully built.
* tests/test-ir-walker.cc (struct name_printing_visitor): Adjust
to the visitor methods naming change.
* configure.ac: Generate the tests/runtestcanonicalizetypes.sh
testing script from tests/runtestcanonicalizetypes.sh.in.
* tests/runtestcanonicalizetypes.sh.in: Add the template for the
new runtestcanonicalizetypes.sh script that test for type
canonicalizing.
* tests/Makefile.am: Add the new runtestcanonicalizetypes.sh
regression testing script to the build system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-02-13 19:20:57 +00:00
|
|
|
virtual bool visit_begin(decl_base*);
|
|
|
|
virtual bool visit_end(decl_base*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(scope_decl*);
|
|
|
|
virtual bool visit_end(scope_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(type_base*);
|
|
|
|
virtual bool visit_end(type_base*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(scope_type_decl*);
|
|
|
|
virtual bool visit_end(scope_type_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(type_decl*);
|
|
|
|
virtual bool visit_end(type_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(namespace_decl*);
|
|
|
|
virtual bool visit_end(namespace_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(qualified_type_def*);
|
|
|
|
virtual bool visit_end(qualified_type_def*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(pointer_type_def*);
|
|
|
|
virtual bool visit_end(pointer_type_def*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(reference_type_def*);
|
|
|
|
virtual bool visit_end(reference_type_def*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(array_type_def*);
|
|
|
|
virtual bool visit_end(array_type_def*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(enum_type_decl*);
|
|
|
|
virtual bool visit_end(enum_type_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(typedef_decl*);
|
|
|
|
virtual bool visit_end(typedef_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(function_type*);
|
|
|
|
virtual bool visit_end(function_type*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(var_decl*);
|
|
|
|
virtual bool visit_end(var_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(function_decl*);
|
|
|
|
virtual bool visit_end(function_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(function_decl::parameter*);
|
|
|
|
virtual bool visit_end(function_decl::parameter*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(function_tdecl*);
|
|
|
|
virtual bool visit_end(function_tdecl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(class_tdecl*);
|
|
|
|
virtual bool visit_end(class_tdecl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(class_decl*);
|
|
|
|
virtual bool visit_end(class_decl*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(class_decl::base_spec*);
|
|
|
|
virtual bool visit_end(class_decl::base_spec*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(class_decl::member_function_template*);
|
|
|
|
virtual bool visit_end(class_decl::member_function_template*);
|
|
|
|
|
|
|
|
virtual bool visit_begin(class_decl::member_class_template*);
|
|
|
|
virtual bool visit_end(class_decl::member_class_template*);
|
|
|
|
}; // end struct ir_node_visitor
|
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-20 10:30:04 +00:00
|
|
|
|
2014-02-07 08:04:46 +00:00
|
|
|
// Debugging facility
|
|
|
|
void
|
|
|
|
fns_to_str(vector<function_decl*>::const_iterator a_begin,
|
|
|
|
vector<function_decl*>::const_iterator a_end,
|
|
|
|
vector<function_decl*>::const_iterator b_begin,
|
|
|
|
vector<function_decl*>::const_iterator b_end,
|
|
|
|
std::ostream& o);
|
|
|
|
|
2014-10-11 09:27:59 +00:00
|
|
|
}// end namespace ir
|
2013-02-28 23:38:28 +00:00
|
|
|
} // end namespace abigail
|
2013-03-29 14:30:34 +00:00
|
|
|
#endif // __ABG_IR_H__
|