Sometimes, two different variables A and B can have the same underlying
symbol, when for instance A is a reference that is initialized with
the address of B.
Until now, that was not supported by libabigail's ABI corpus. Only
one (either A or B) variable is kept. This is because the ID of the
variable, as returned by abigail::var_decl::get_id() is made of the
symbol name of the variable only.
This patch fixes the issue by including the name of the variable in
the ID.
* src/abg-ir.cc (var_decl::get_id()): Include the name of the
variable in the ID.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
{
if (priv_->id_.empty())
{
+ string repr = get_name();
+ string sym_str;
if (elf_symbol_sptr s = get_symbol())
- priv_->id_ = s->get_id_string();
+ sym_str = s->get_id_string();
else if (!get_linkage_name().empty())
- priv_->id_ = get_linkage_name();
- else
- priv_->id_ = get_pretty_representation();
+ sym_str = get_linkage_name();
+ priv_->id_ = repr;
+ if (!sym_str.empty())
+ priv_->id_ += "{" + sym_str + "}";
}
return priv_->id_;
}