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(-)
@@ -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
@@ -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
@@ -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
@@ -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>
@@ -256,6 +256,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.
@@ -309,8 +377,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;
@@ -4334,7 +4402,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
@@ -4354,7 +4422,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