From patchwork Wed Jan 1 00:00:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksei Vetrov via Libabigail X-Patchwork-Id: 38998 X-Patchwork-Original-From: libabigail@sourceware.org (Matthias Maennich via libabigail) From: Aleksei Vetrov via Libabigail Date: Wed, 01 Jan 2020 00:00:00 -0000 Subject: [PATCH 1/2] corpus: is_empty: consider actual translation unit contents In-Reply-To: <20200113144451.46359-1-maennich@google.com> References: <20200113144451.46359-1-maennich@google.com> Message-ID: <20200113144451.46359-2-maennich@google.com> A corpus with completely filtered out symbols (exhaustive whitelist), still contains compilation units, but they are empty. A list of empty translation units shall be considered empty as no entries need to be considered. That is useful to skip empty corpora when writing out the xml for them. Hence, teach is_empty() to have a look at the actual translation units. * src/abg-corpus.cc (corpus::is_empty): consider a list of empty members to be empty. Signed-off-by: Matthias Maennich --- src/abg-corpus.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index e37c35f5fbbb..bee87ddbb307 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -859,7 +859,18 @@ corpus::set_architecture_name(const string& arch) bool corpus::is_empty() const { - return (priv_->members.empty() + bool members_empty = true; + for (translation_units::const_iterator i = priv_->members.begin(), + e = priv_->members.end(); + i != e; ++i) + { + if (!(*i)->is_empty()) + { + members_empty = false; + break; + } + } + return (members_empty && priv_->fun_symbol_map && priv_->fun_symbol_map->empty() && priv_->var_symbol_map