[1/3] abidw: fix --stats output for resolved classes and enums

Message ID 20220825114856.3137373-2-gprocida@google.com
State New
Headers
Series Improve resolution of declaration-only enums |

Commit Message

Giuliano Procida Aug. 25, 2022, 11:48 a.m. UTC
  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 | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)
  

Comments

Dodji Seketeli Aug. 29, 2022, 11:19 a.m. UTC | #1
Giuliano Procida <gprocida@google.com> a écrit:

> 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>

Applied to master, thanks!

Cheers,

[...]
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index e5159c89..a954de6d 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -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";
       }
   }