abidw: fix --stats output for resolved classes and enums
authorGiuliano Procida <gprocida@google.com>
Thu, 25 Aug 2022 11:48:54 +0000 (12:48 +0100)
committerDodji Seketeli <dodji@redhat.com>
Mon, 29 Aug 2022 11:04:43 +0000 (13:04 +0200)
The code to print out the remaining declaration-only types
unintentionally omitted the first such type. This change fixes the
logic and uses a single test to decide whether or not to print the
stats header line.

* src/abg-dwarf-reader.cc
(read_context::resolve_declaration_only_classes): Fix
conditional logic so that showing stats includes the first
unresolved type.
(read_context::resolve_declaration_only_enums): Likewise.

Signed-off-by: Giuliano Procida <gprocida@google.com>
src/abg-dwarf-reader.cc

index 32eaacba4eda2e6705c0c830b7cb832b760abf6f..71c8df1c9f84db8cb666465f5d4fc3f6e9e24f04 100644 (file)
@@ -4325,19 +4325,15 @@ public:
         ++i)
       declaration_only_classes().erase(*i);
 
-    for (string_classes_map::iterator i = declaration_only_classes().begin();
-        i != declaration_only_classes().end();
-        ++i)
+    if (show_stats() && !declaration_only_classes().empty())
       {
-       if (show_stats())
-         {
-           if (i == declaration_only_classes().begin())
-             cerr << "Here are the "
-                  << num_decl_only_classes - num_resolved
-                  << " unresolved class declarations:\n";
-           else
-             cerr << "    " << i->first << "\n";
-         }
+       cerr << "Here are the "
+            << num_decl_only_classes - num_resolved
+            << " unresolved class declarations:\n";
+       for (string_classes_map::iterator i = declaration_only_classes().begin();
+            i != declaration_only_classes().end();
+            ++i)
+         cerr << "    " << i->first << "\n";
       }
   }
 
@@ -4527,19 +4523,15 @@ public:
         ++i)
       declaration_only_enums().erase(*i);
 
-    for (string_enums_map::iterator i = declaration_only_enums().begin();
-        i != declaration_only_enums().end();
-        ++i)
+    if (show_stats() && !declaration_only_enums().empty())
       {
-       if (show_stats())
-         {
-           if (i == declaration_only_enums().begin())
-             cerr << "Here are the "
-                  << num_decl_only_enums - num_resolved
-                  << " unresolved enum declarations:\n";
-           else
-             cerr << "    " << i->first << "\n";
-         }
+       cerr << "Here are the "
+            << num_decl_only_enums - num_resolved
+            << " unresolved enum declarations:\n";
+       for (string_enums_map::iterator i = declaration_only_enums().begin();
+            i != declaration_only_enums().end();
+            ++i)
+         cerr << "    " << i->first << "\n";
       }
   }