Support two different variables having the same underlying symbol
authorDodji Seketeli <dodji@redhat.com>
Mon, 4 Jan 2016 16:15:05 +0000 (17:15 +0100)
committerDodji Seketeli <dodji@redhat.com>
Mon, 4 Jan 2016 18:58:02 +0000 (19:58 +0100)
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>
src/abg-ir.cc

index 24e8d9ddb87d8a493aef0d2497b456fcb9dd0f3e..2be3c8505d57acb94502f6053dcb4d39a85a4f1e 100644 (file)
@@ -9013,12 +9013,15 @@ var_decl::get_id() const
 {
   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_;
 }