From: Matthias Maennich Date: Mon, 13 Jan 2020 14:44:50 +0000 (+0000) Subject: corpus: is_empty: consider actual translation unit contents X-Git-Tag: upstream/1.7~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=750b652b695d38efd83f8fbc1576d31d6e327b9d;p=platform%2Fupstream%2Flibabigail.git corpus: is_empty: consider actual translation unit contents 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. Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich --- diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index baed8e53..567f1b5e 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -849,13 +849,30 @@ void corpus::set_architecture_name(const string& arch) {priv_->architecture_name = arch;} -/// Tests if the corpus contains no translation unit. +/// Tests if the corpus is empty from an ABI surface perspective. I.e. if all +/// of these criteria are true: +/// - all translation units (members) are empty +/// - the maps function and variable symbols are not having entries +/// - for shared libraries: +/// - the soname is empty +/// - there are no DT_NEEDED entries /// /// @return true if the corpus contains no translation unit. 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