diff mbox series

[2/2] writer: completely skip over empty corpora

Message ID 20200113144451.46359-3-maennich@google.com
State Committed
Headers show
Series [1/2] KMI Whitelists: Add functionality to make whitelists additive | expand

Commit Message

Matthias Maennich via libabigail Jan. 1, 2020, midnight UTC
A corpus that has no symbols contributing to the ABI surface (e.g.
because of an exhaustive suppression), will not contribute in a later
comparison via abidiff and friends. Hence, there is no need for such
entries to appear in the ABI xml representation. This patch completely
suppresses empty corpora.

	* src/abg-writer.cc (write_corpus): completely skip empty
	corpora rather than creating an empty entry for them.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 src/abg-writer.cc | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Dodji Seketeli Jan. 1, 2020, midnight UTC | #1
Hello Matthias,

Matthias Maennich <maennich@google.com> a ?crit:

[...]

> diff --git a/src/abg-writer.cc b/src/abg-writer.cc
> index 994a21e28066..ca10af8d5e7e 100644
> --- a/src/abg-writer.cc
> +++ b/src/abg-writer.cc
> @@ -4378,6 +4378,9 @@ write_corpus(write_context&	ctxt,
>    if (!corpus)
>      return false;
>  
> +  if (corpus->is_empty())
> +    return true;
> +
>    do_indent_to_level(ctxt, indent, 0);
>  
>    std::ostream& out = ctxt.get_ostream();
> @@ -4411,12 +4414,6 @@ write_corpus(write_context&	ctxt,
>  
>    write_tracking_non_reachable_types(corpus, out);
>  
> -  if (corpus->is_empty())
> -    {
> -      out << "/>\n";
> -      return true;
> -    }
> -
>    out << ">\n";

This change is OK.  It'd be useful to add a note to the comment of the
write_corpus function to say that nothing is emitted for an empty
corpus.

[...]

> A corpus that has no symbols contributing to the ABI surface (e.g.
> because of an exhaustive suppression), will not contribute in a later
> comparison via abidiff and friends. Hence, there is no need for such
> entries to appear in the ABI xml representation. This patch completely
> suppresses empty corpora.
>
> 	* src/abg-writer.cc (write_corpus): completely skip empty
> 	corpora rather than creating an empty entry for them.

OK to commit to master with the comment udpate above.

Thank you for working on this!

Cheers,
diff mbox series

Patch

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 994a21e28066..ca10af8d5e7e 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -4378,6 +4378,9 @@  write_corpus(write_context&	ctxt,
   if (!corpus)
     return false;
 
+  if (corpus->is_empty())
+    return true;
+
   do_indent_to_level(ctxt, indent, 0);
 
   std::ostream& out = ctxt.get_ostream();
@@ -4411,12 +4414,6 @@  write_corpus(write_context&	ctxt,
 
   write_tracking_non_reachable_types(corpus, out);
 
-  if (corpus->is_empty())
-    {
-      out << "/>\n";
-      return true;
-    }
-
   out << ">\n";
 
   // Write the list of needed corpora.