mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-21 00:06:58 +00:00
During comparison use symbol name + version as decl ID
* include/abg-ir.h ({var,function}_decl::get_id): New member function declarations. * src/abg-ir.cc ({var,function}_decl::get_id): New member function definitions. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Use the ::get_id() function to get an identifier for the function or variable. * src/abg-corpus.cc (symtab_build_visitor_type::build_id): Use the get_id of the function/variable. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
73ffa4f562
commit
30b7fb8e5a
@ -1493,6 +1493,9 @@ public:
|
||||
var_decl_sptr
|
||||
clone() const;
|
||||
|
||||
string
|
||||
get_id() const;
|
||||
|
||||
virtual size_t
|
||||
get_hash() const;
|
||||
|
||||
@ -1770,6 +1773,9 @@ public:
|
||||
virtual size_t
|
||||
get_hash() const;
|
||||
|
||||
string
|
||||
get_id() const;
|
||||
|
||||
virtual bool
|
||||
traverse(ir_node_visitor&);
|
||||
|
||||
|
@ -6200,9 +6200,7 @@ corpus_diff::priv::ensure_lookup_tables_populated()
|
||||
assert(i < first_->get_functions().size());
|
||||
|
||||
function_decl* deleted_fn = first_->get_functions()[i];
|
||||
string n = deleted_fn->get_linkage_name();
|
||||
if (n.empty())
|
||||
n = deleted_fn->get_pretty_representation();
|
||||
string n = deleted_fn->get_id();
|
||||
assert(!n.empty());
|
||||
assert(deleted_fns_.find(n) == deleted_fns_.end());
|
||||
deleted_fns_[n] = deleted_fn;
|
||||
@ -6219,25 +6217,11 @@ corpus_diff::priv::ensure_lookup_tables_populated()
|
||||
{
|
||||
unsigned i = *iit;
|
||||
function_decl* added_fn = second_->get_functions()[i];
|
||||
string n = added_fn->get_linkage_name();
|
||||
if (n.empty())
|
||||
n = added_fn->get_pretty_representation();
|
||||
string n = added_fn->get_id();
|
||||
assert(!n.empty());
|
||||
assert(added_fns_.find(n) == added_fns_.end());
|
||||
string_function_ptr_map::const_iterator j =
|
||||
deleted_fns_.find(n);
|
||||
if (j == deleted_fns_.end())
|
||||
{
|
||||
// It can happen that an old dwarf producer might not
|
||||
// have emitted the mangled name of the first diff
|
||||
// subject. Int hat case, we need to try to use the
|
||||
// function synthetic signature here.
|
||||
// TODO: also query the underlying elf file's .dynsym
|
||||
// symbol table to see if the symbol is present in the
|
||||
// first diff subject before for real.
|
||||
if (!added_fn->get_linkage_name().empty())
|
||||
j = deleted_fns_.find(added_fn->get_pretty_representation());
|
||||
}
|
||||
if (j != deleted_fns_.end())
|
||||
{
|
||||
if (*j->second != *added_fn)
|
||||
@ -6294,9 +6278,7 @@ corpus_diff::priv::ensure_lookup_tables_populated()
|
||||
assert(i < first_->get_variables().size());
|
||||
|
||||
var_decl* deleted_var = first_->get_variables()[i];
|
||||
string n = deleted_var->get_linkage_name();
|
||||
if (n.empty())
|
||||
n = deleted_var->get_pretty_representation();
|
||||
string n = deleted_var->get_id();
|
||||
assert(!n.empty());
|
||||
assert(deleted_vars_.find(n) == deleted_vars_.end());
|
||||
deleted_vars_[n] = deleted_var;
|
||||
@ -6313,9 +6295,7 @@ corpus_diff::priv::ensure_lookup_tables_populated()
|
||||
{
|
||||
unsigned i = *iit;
|
||||
var_decl* added_var = second_->get_variables()[i];
|
||||
string n = added_var->get_linkage_name();
|
||||
if (n.empty())
|
||||
n = added_var->get_name();
|
||||
string n = added_var->get_id();
|
||||
assert(!n.empty());
|
||||
{
|
||||
string_var_ptr_map::const_iterator k = added_vars_.find(n);
|
||||
|
@ -201,13 +201,7 @@ public:
|
||||
/// @return the unique ID.
|
||||
string
|
||||
build_id(const function_decl& fn)
|
||||
{
|
||||
if (elf_symbol_sptr s = fn.get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!fn.get_linkage_name().empty())
|
||||
return fn.get_linkage_name();
|
||||
return fn.get_pretty_representation();
|
||||
}
|
||||
{return fn.get_id();}
|
||||
|
||||
/// Build a string that uniquely identifies a var_decl inside
|
||||
/// one corpus.
|
||||
@ -222,13 +216,7 @@ public:
|
||||
/// @return the unique ID.
|
||||
string
|
||||
build_id(const var_decl& var)
|
||||
{
|
||||
if (elf_symbol_sptr s = var.get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!var.get_linkage_name().empty())
|
||||
return var.get_linkage_name();
|
||||
return var.get_pretty_representation();
|
||||
}
|
||||
{return var.get_id();}
|
||||
|
||||
/// Build a string that uniquely identifies a function_decl inside
|
||||
/// one corpus.
|
||||
|
@ -4272,6 +4272,25 @@ var_decl::operator==(const decl_base& o) const
|
||||
return *c0 == *c1;
|
||||
}
|
||||
|
||||
/// Return an ID that tries to uniquely identify the variable inside a
|
||||
/// program or a library.
|
||||
///
|
||||
/// So if the variable has an underlying elf symbol, the ID is the
|
||||
/// concatenation of the symbol name and its version. Otherwise, the
|
||||
/// ID is the linkage name if its non-null. Otherwise, it's the
|
||||
/// pretty representation of the variable.
|
||||
///
|
||||
/// @return the ID.
|
||||
string
|
||||
var_decl::get_id() const
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
return get_linkage_name();
|
||||
return get_pretty_representation();
|
||||
}
|
||||
|
||||
/// Return the hash value for the current instance.
|
||||
///
|
||||
/// @return the hash value.
|
||||
@ -5014,6 +5033,25 @@ function_decl::get_hash() const
|
||||
return hash_fn(*this);
|
||||
}
|
||||
|
||||
/// Return an ID that tries to uniquely identify the function inside a
|
||||
/// program or a library.
|
||||
///
|
||||
/// So if the function has an underlying elf symbol, the ID is the
|
||||
/// concatenation of the symbol name and its version. Otherwise, the
|
||||
/// ID is the linkage name if its non-null. Otherwise, it's the
|
||||
/// pretty representation of the function.
|
||||
///
|
||||
/// @return the ID.
|
||||
string
|
||||
function_decl::get_id() const
|
||||
{
|
||||
if (elf_symbol_sptr s = get_symbol())
|
||||
return s->get_id_string();
|
||||
else if (!get_linkage_name().empty())
|
||||
return get_linkage_name();
|
||||
return get_pretty_representation();
|
||||
}
|
||||
|
||||
/// This implements the ir_traversable_base::traverse pure virtual
|
||||
/// function.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user