From: Matthias Maennich Date: Mon, 13 Jan 2020 14:44:51 +0000 (+0000) Subject: writer: completely skip over empty corpora X-Git-Tag: upstream/1.7~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68910c530148591d55a5834933fe95b4136e75c5;p=platform%2Fupstream%2Flibabigail.git writer: completely skip over empty corpora 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. Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich --- diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 78844cf4..c8c0ee6d 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -4362,6 +4362,10 @@ write_corpus_to_archive(const corpus_sptr corp, const bool annotate) /// Serialize an ABI corpus to a single native xml document. The root /// note of the resulting XML document is 'abi-corpus'. /// +/// Note: If either corpus is null or corpus does not contain serializable +/// content (i.e. corpus.is_empty()), nothing is emitted to the ctxt's +/// output stream. +/// /// @param ctxt the write context to use. /// /// @param corpus the corpus to serialize. @@ -4378,6 +4382,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 +4418,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.