From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
maennich@google.com
Subject: [PATCH v3 13/21] Move match methods from priv to suppression_base.
Date: Fri, 24 Apr 2020 10:21:24 +0100 [thread overview]
Message-ID: <20200424092132.150547-14-gprocida@google.com> (raw)
In-Reply-To: <20200424092132.150547-1-gprocida@google.com>
The suppression_base::priv methods matches_soname and
matches_binary_name do not require special access to the priv class
and can be moved to the main suppression_base class and use its
getters.
This is a step towards simplifying the suppression type priv classes
to the point they are simple data containers.
There are no behavioural changes.
* include/abg-suppression.h
(suppression_base::matches_soname): Add declaration.
(suppression_base::matches_binary_name): Add declaration.
(suppression_base): Remove friend declarations of
suppression_matches_soname and
suppression_matches_soname_or_filename.
* src/abg-dwarf-reader.cc (suppression_can_match): Call
matches_soname and matches_binary_name on suppression values
directly.
* src/abg-reader.cc (suppression_can_match): Call
matches_soname and matches_binary_name on suppression values
directly.
* src/abg-suppression-priv.h
(suppression_base::priv::matches_soname): Remove method.
(suppression_base::priv::matches_binary_name): Remove method.
* src/abg-suppression.cc
(suppression_base::matches_soname): Add definition.
(suppression_base::matches_binary_name): Add definition.
(names_of_binaries_match): Call matches_binary_name on
suppression values directly. (suppression_matches_soname):
Call matches_soname on suppression values directly.
(suppression_matches_soname_or_filename): Call
matches_binary_name on suppression values directly.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
include/abg-suppression.h | 15 +++-----
src/abg-dwarf-reader.cc | 4 +-
src/abg-reader.cc | 4 +-
src/abg-suppression-priv.h | 71 +----------------------------------
src/abg-suppression.cc | 76 ++++++++++++++++++++++++++++++++++++--
5 files changed, 83 insertions(+), 87 deletions(-)
diff --git a/include/abg-suppression.h b/include/abg-suppression.h
index 1869cbe5..02e77ea9 100644
--- a/include/abg-suppression.h
+++ b/include/abg-suppression.h
@@ -116,19 +116,16 @@ public:
bool
has_soname_related_property() const;
+ bool
+ matches_soname(const string& soname) const;
+
+ bool
+ matches_binary_name(const string& binary_name) const;
+
virtual bool
suppresses_diff(const diff*) const = 0;
virtual ~suppression_base();
-
- friend bool
- suppression_matches_soname(const string& soname,
- const suppression_base& suppr);
-
- friend bool
- suppression_matches_soname_or_filename(const string& soname,
- const string& filename,
- const suppression_base& suppr);
}; // end class suppression_base
void
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 850281ad..c9e6f918 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7723,14 +7723,14 @@ public:
bool
suppression_can_match(const suppr::suppression_base& s) const
{
- if (!s.priv_->matches_soname(dt_soname()))
+ if (!s.matches_soname(dt_soname()))
if (s.has_soname_related_property())
// The suppression has some SONAME related properties, but
// none of them match the SONAME of the current binary. So
// the suppression cannot match the current binary.
return false;
- if (!s.priv_->matches_binary_name(elf_path()))
+ if (!s.matches_binary_name(elf_path()))
if (s.has_file_name_related_property())
// The suppression has some file_name related properties, but
// none of them match the file name of the current binary. So
diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index dcaa27e1..5e0b97e0 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -999,14 +999,14 @@ public:
{
corpus_sptr corp = get_corpus();
- if (!s.priv_->matches_soname(corp->get_soname()))
+ if (!s.matches_soname(corp->get_soname()))
if (s.has_soname_related_property())
// The suppression has some SONAME related properties, but
// none of them match the SONAME of the current binary. So
// the suppression cannot match the current binary.
return false;
- if (!s.priv_->matches_binary_name(corp->get_path()))
+ if (!s.matches_binary_name(corp->get_path()))
if (s.has_file_name_related_property())
// The suppression has some file_name related properties, but
// none of them match the file name of the current binary. So
diff --git a/src/abg-suppression-priv.h b/src/abg-suppression-priv.h
index 263052d4..5c06d5d0 100644
--- a/src/abg-suppression-priv.h
+++ b/src/abg-suppression-priv.h
@@ -107,76 +107,7 @@ public:
{
return soname_not_regex_;
}
-
- /// Test if the current suppression matches a given SONAME.
- ///
- /// @param soname the SONAME to consider.
- ///
- /// @return true iff the suppression matches the SONAME denoted by
- /// @p soname.
- ///
- /// Note that if the suppression contains no property that is
- /// related to SONAMEs, the function returns false.
- bool
- matches_soname(const string& soname) const
- {
- bool has_regexp = false;
- if (regex::regex_t_sptr regexp = get_soname_regex())
- {
- has_regexp = true;
- if (!regex::match(regexp, soname))
- return false;
- }
-
- if (regex::regex_t_sptr regexp = get_soname_not_regex())
- {
- has_regexp = true;
- if (regex::match(regexp, soname))
- return false;
- }
-
- if (!has_regexp)
- return false;
-
- return true;
- }
-
- /// Test if the current suppression matches the full file path to a
- /// given binary.
- ///
- /// @param binary_name the full path to the binary.
- ///
- /// @return true iff the suppression matches the path denoted by @p
- /// binary_name.
- ///
- /// Note that if the suppression contains no property that is
- /// related to file name, the function returns false.
- bool
- matches_binary_name(const string& binary_name) const
- {
- bool has_regexp = false;
-
- if (regex::regex_t_sptr regexp = get_file_name_regex())
- {
- has_regexp = true;
- if (!regex::match(regexp, binary_name))
- return false;
- }
-
- if (regex::regex_t_sptr regexp = get_file_name_not_regex())
- {
- has_regexp = true;
- if (regex::match(regexp, binary_name))
- return false;
- }
-
- if (!has_regexp)
- return false;
-
- return true;
- }
-
-}; // end clas suppression_base::priv
+}; // end class suppression_base::priv
// </suppression_base stuff>
diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc
index 7e501c45..191c65c6 100644
--- a/src/abg-suppression.cc
+++ b/src/abg-suppression.cc
@@ -252,6 +252,74 @@ suppression_base::has_soname_related_property() const
return get_soname_regex() || get_soname_not_regex();
}
+/// Test if the current suppression matches a given SONAME.
+///
+/// @param soname the SONAME to consider.
+///
+/// @return true iff the suppression matches the SONAME denoted by
+/// @p soname.
+///
+/// Note that if the suppression contains no property that is
+/// related to SONAMEs, the function returns false.
+bool
+suppression_base::matches_soname(const string& soname) const
+{
+ bool has_regexp = false;
+ if (regex::regex_t_sptr regexp = get_soname_regex())
+ {
+ has_regexp = true;
+ if (!regex::match(regexp, soname))
+ return false;
+ }
+
+ if (regex::regex_t_sptr regexp = get_soname_not_regex())
+ {
+ has_regexp = true;
+ if (regex::match(regexp, soname))
+ return false;
+ }
+
+ if (!has_regexp)
+ return false;
+
+ return true;
+}
+
+/// Test if the current suppression matches the full file path to a
+/// given binary.
+///
+/// @param binary_name the full path to the binary.
+///
+/// @return true iff the suppression matches the path denoted by @p
+/// binary_name.
+///
+/// Note that if the suppression contains no property that is
+/// related to file name, the function returns false.
+bool
+suppression_base::matches_binary_name(const string& binary_name) const
+{
+ bool has_regexp = false;
+
+ if (regex::regex_t_sptr regexp = get_file_name_regex())
+ {
+ has_regexp = true;
+ if (!regex::match(regexp, binary_name))
+ return false;
+ }
+
+ if (regex::regex_t_sptr regexp = get_file_name_not_regex())
+ {
+ has_regexp = true;
+ if (regex::match(regexp, binary_name))
+ return false;
+ }
+
+ if (!has_regexp)
+ return false;
+
+ return true;
+}
+
/// Check if the SONAMEs of the two binaries being compared match the
/// content of the properties "soname_regexp" and "soname_not_regexp"
/// of the current suppression specification.
@@ -305,8 +373,8 @@ names_of_binaries_match(const suppression_base& suppr,
if (!suppr.has_file_name_related_property())
return false;
- if (!suppr.priv_->matches_binary_name(first_binary_path)
- && !suppr.priv_->matches_binary_name(second_binary_path))
+ if (!suppr.matches_binary_name(first_binary_path)
+ && !suppr.matches_binary_name(second_binary_path))
return false;
return true;
@@ -4330,7 +4398,7 @@ bool
suppression_matches_soname(const string& soname,
const suppression_base& suppr)
{
- return suppr.priv_->matches_soname(soname);
+ return suppr.matches_soname(soname);
}
/// Test if a given SONAME or file name is matched by a given
@@ -4350,7 +4418,7 @@ suppression_matches_soname_or_filename(const string& soname,
const suppression_base& suppr)
{
return (suppression_matches_soname(soname, suppr)
- || suppr.priv_->matches_binary_name(filename));
+ || suppr.matches_binary_name(filename));
}
/// @return the name of the artificial private type suppression
--
2.26.2.303.gf8c07b1a785-goog
next prev parent reply other threads:[~2020-04-24 9:22 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 15:44 [PATCH 00/21] Simplify regex and suppression parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 01/21] Move regex definitions to own files Giuliano Procida
2020-04-23 15:44 ` [PATCH 02/21] Move libxml bits out of abg-sptr-utils.h Giuliano Procida
2020-04-23 15:44 ` [PATCH 03/21] Simplify generation of symbol whitelist regex Giuliano Procida
2020-04-23 15:44 ` [PATCH 04/21] Escape names used in symbol whitelisting regex Giuliano Procida
2020-04-23 15:44 ` [PATCH 05/21] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-04-23 15:44 ` [PATCH 06/21] diff suppression: Fix handling of change kinds Giuliano Procida
2020-04-23 15:44 ` [PATCH 07/21] Add POSIX regex wrapper functions Giuliano Procida
2020-04-23 18:07 ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 08/21] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-04-23 15:44 ` [PATCH 09/21] Use regex::match wrapper instead of regexec Giuliano Procida
2020-04-23 18:02 ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 10/21] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-04-23 15:44 ` [PATCH 11/21] Compile suppression regexes earlier Giuliano Procida
2020-04-23 15:44 ` [PATCH 12/21] Reduce direct access to suppression priv_ members Giuliano Procida
2020-04-23 15:44 ` [PATCH 13/21] Move match methods from priv to suppression_base Giuliano Procida
2020-04-23 15:44 ` [PATCH 14/21] Remove suppression types' priv class methods Giuliano Procida
2020-04-23 15:44 ` [PATCH 15/21] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-04-23 15:44 ` [PATCH 16/21] abg-tools-utils.cc: Assert generated regexes OK Giuliano Procida
2020-04-23 15:44 ` [PATCH 17/21] Refactor suppression property string parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 18/21] Refactor suppression property regex parsing Giuliano Procida
2020-04-23 15:44 ` [PATCH 19/21] Warn if user-supplied regexes fail to compile Giuliano Procida
2020-04-23 18:04 ` [PATCH v2 " Giuliano Procida
2020-04-23 15:44 ` [PATCH 20/21] Default construct suppression types Giuliano Procida
2020-04-23 15:44 ` [PATCH 21/21] Remove unused suppression type priv constructors Giuliano Procida
2020-04-23 18:11 ` [PATCH 00/21] Simplify regex and suppression parsing Giuliano Procida
2020-04-24 8:54 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 00/21]Simplify " Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 01/21] Move regex definitions to own files Giuliano Procida
2020-04-27 10:52 ` Matthias Maennich
2020-04-29 14:19 ` Dodji Seketeli
2020-04-29 14:35 ` Giuliano Procida
2020-05-04 9:19 ` Dodji Seketeli
2020-04-24 9:21 ` [PATCH v3 02/21] Move libxml bits out of abg-sptr-utils.h Giuliano Procida
2020-04-27 10:53 ` Matthias Maennich
2020-04-29 14:30 ` Dodji Seketeli
2020-05-04 9:20 ` Dodji Seketeli
2020-04-24 9:21 ` [PATCH v3 03/21] Simplify generation of symbol whitelist regex Giuliano Procida
2020-04-27 11:01 ` Matthias Maennich
2020-04-27 15:31 ` Giuliano Procida
2020-05-04 9:20 ` Dodji Seketeli
2020-04-24 9:21 ` [PATCH v3 04/21] Escape names used in symbol whitelisting regex Giuliano Procida
2020-04-27 11:14 ` Matthias Maennich
2020-04-27 15:37 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 05/21] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-04-27 11:17 ` Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 06/21] diff suppression: Fix handling of change kinds Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 07/21] Add POSIX regex wrapper functions Giuliano Procida
2020-04-27 11:23 ` Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 08/21] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-04-27 11:34 ` Matthias Maennich
2020-04-27 16:01 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 09/21] Use regex::match wrapper instead of regexec Giuliano Procida
2020-04-27 11:38 ` Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 10/21] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 11/21] Compile suppression regexes earlier Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 12/21] Reduce direct access to suppression priv_ members Giuliano Procida
2020-04-27 11:54 ` Matthias Maennich
2020-04-24 9:21 ` Giuliano Procida [this message]
2020-04-27 11:55 ` [PATCH v3 13/21] Move match methods from priv to suppression_base Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 14/21] Remove suppression types' priv class methods Giuliano Procida
2020-04-27 11:57 ` Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 15/21] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-04-27 12:07 ` Matthias Maennich
2020-04-27 16:18 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 16/21] abg-tools-utils.cc: Assert generated regexes OK Giuliano Procida
2020-04-27 12:08 ` Matthias Maennich
2020-04-27 16:21 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 17/21] Refactor suppression property string parsing Giuliano Procida
2020-04-27 12:17 ` Matthias Maennich
2020-04-27 16:42 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 18/21] Refactor suppression property regex parsing Giuliano Procida
2020-04-27 14:55 ` Matthias Maennich
2020-04-27 16:59 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 19/21] Warn if user-supplied regexes fail to compile Giuliano Procida
2020-04-27 15:36 ` Matthias Maennich
2020-05-01 8:49 ` Giuliano Procida
2020-04-24 9:21 ` [PATCH v3 20/21] Default construct suppression types Giuliano Procida
2020-04-27 15:40 ` Matthias Maennich
2020-04-24 9:21 ` [PATCH v3 21/21] Remove unused suppression type priv constructors Giuliano Procida
2020-04-27 15:41 ` Matthias Maennich
2020-05-04 12:34 ` [PATCH v4 00/15] Simplify regex and suppression parsing Giuliano Procida
2020-05-04 12:34 ` [PATCH v4 01/15] Tidy #includes in a few files Giuliano Procida
2020-05-04 12:49 ` Matthias Maennich
2020-05-11 13:24 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 02/15] Document ^_^ regex in generate_from_strings Giuliano Procida
2020-05-04 12:49 ` Matthias Maennich
2020-05-11 13:32 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 03/15] Escape names used in symbol whitelisting regex Giuliano Procida
2020-05-04 12:57 ` Matthias Maennich
2020-05-04 16:45 ` [PATCH v5 " Giuliano Procida
2020-05-11 13:59 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 04/15] abg-suppression.cc: More uniform variable naming Giuliano Procida
2020-05-11 14:04 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 05/15] diff suppression: Fix handling of change kinds Giuliano Procida
2020-05-04 13:04 ` Matthias Maennich
2020-05-11 14:15 ` Dodji Seketeli
2020-05-11 15:47 ` Giuliano Procida
2020-05-11 17:53 ` Dodji Seketeli
2020-05-12 9:54 ` Giuliano Procida
2020-05-12 10:14 ` [PATCH v5 05/15] Tidy checks for sufficient suppression properties Giuliano Procida
2020-05-12 16:11 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 06/15] Add POSIX regex wrapper functions Giuliano Procida
2020-05-11 16:37 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 07/15] Use regex::compile wrapper instead of regcomp Giuliano Procida
2020-05-11 16:38 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 08/15] Use regex::match wrapper instead of regexec Giuliano Procida
2020-05-12 16:35 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 09/15] Refactor read_parameter_spec_from_string logic Giuliano Procida
2020-05-13 7:51 ` Dodji Seketeli
2020-05-04 12:34 ` [PATCH v4 10/15] Compile suppression regexes earlier Giuliano Procida
2020-05-04 13:14 ` Matthias Maennich
2020-05-13 8:07 ` Dodji Seketeli
2020-05-13 15:36 ` Giuliano Procida
2020-05-04 12:34 ` [PATCH v4 11/15] Reduce direct access to suppression priv_ members Giuliano Procida
2020-05-04 12:34 ` [PATCH v4 12/15] Move match methods from priv to suppression_base Giuliano Procida
2020-05-04 12:34 ` [PATCH v4 13/15] Remove suppression type priv class methods Giuliano Procida
2020-05-04 12:34 ` [PATCH v4 14/15] abg-suppression.cc: More consistent regex matching Giuliano Procida
2020-05-04 13:17 ` Matthias Maennich
2020-05-04 12:34 ` [PATCH v4 15/15] abg-tools-utils.cc: Assert generated regexes OK Giuliano Procida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424092132.150547-14-gprocida@google.com \
--to=gprocida@google.com \
--cc=dodji@seketeli.org \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).