[abixml writer] Fix comparison of pointer to types
authorDodji Seketeli <dodji@redhat.com>
Thu, 5 Jan 2017 08:55:13 +0000 (09:55 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 5 Jan 2017 11:26:20 +0000 (12:26 +0100)
When two type pointers designate two types with the same pretty
printed representatin don't already have an associated type id, the
comparison code was mistakenly associating them with empty type id.

This patch fixes that.

Note that the necessary adjustment to reference outputs of abidw in
the regression test suite is not provided with this patch to ease
backporting.  Those adjustments are in a patch that comes at the end
of this patch series.

* src/abg-writer.cc (type_ptr_comp::operator()): Do not add an
empty type id string to the type -> type id map when the entry for
a given type is empty.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-writer.cc

index 50fcb0258a2de94ca3b6c093b75cd35e5f02a690..a19da3e3d818b7dfd61858dce9be0b621f92bf7a 100644 (file)
@@ -35,6 +35,8 @@
 #include <algorithm>
 #include <tr1/unordered_map>
 
+#include "abg-tools-utils.h"
+
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 ABG_BEGIN_EXPORT_DECLARATIONS
@@ -359,8 +361,13 @@ public:
 
       if (r1 == r2)
        {
-         r1 = (*map)[const_cast<type_base*>(l)];
-         r2 = (*map)[const_cast<type_base*>(r)];
+         type_ptr_map::const_iterator i =
+           map->find(const_cast<type_base*>(l));
+         if (i != map->end())
+           r1 = i->second;
+         i = map->find(const_cast<type_base*>(r));
+         if (i != map->end())
+           r2 = i->second;
        }
 
       return r1 < r2;