comparison: Fix index error when interpreting scope comparison
authorDodji Seketeli <dodji@redhat.com>
Wed, 19 Apr 2023 14:24:05 +0000 (16:24 +0200)
committerDodji Seketeli <dodji@redhat.com>
Tue, 25 Apr 2023 13:50:26 +0000 (15:50 +0200)
While looking at something else, I noticed a thinko in the
code in scope_diff::ensure_lookup_tables_populated that interprets the
result of the diffing algorithm on the decls of a given scope.  Fixed
thus.

* src/abg-comparison.cc
(scope_diff::ensure_lookup_tables_populated): Use the proper index
to address the deleted decl.  Also, use the range-based for syntax
in the enclosing for-loop for more clarity.

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

index 59530a8abfa57b6bfb677c29db655d6c9f4c28e7..9c580da20cfcf5cf72739904e3ece8068c792190 100644 (file)
@@ -6522,10 +6522,9 @@ scope_diff::ensure_lookup_tables_populated()
   edit_script& e = priv_->member_changes_;
 
   // Populate deleted types & decls lookup tables.
-  for (vector<deletion>::const_iterator i = e.deletions().begin();
-       i != e.deletions().end();
-       ++i)
+  for (const auto& deletion : e.deletions())
     {
+      unsigned i = deletion.index();
       decl_base_sptr decl = deleted_member_at(i);
       string qname = decl->get_qualified_name();
       if (is_type(decl))