diff --git a/include/Makefile.am b/include/Makefile.am index ae97f674..b5475252 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,6 +24,7 @@ abg-cxx-compat.h \ abg-version.h \ abg-viz-common.h \ abg-viz-dot.h \ -abg-viz-svg.h +abg-viz-svg.h \ +abg-regex.h EXTRA_DIST = abg-version.h.in diff --git a/include/abg-regex.h b/include/abg-regex.h new file mode 100644 index 00000000..84c386a9 --- /dev/null +++ b/include/abg-regex.h @@ -0,0 +1,83 @@ +// -*- mode: C++ -*- +// +// Copyright (C) 2013-2020 Red Hat, Inc. +// +// This file is part of the GNU Application Binary Interface Generic +// Analysis and Instrumentation Library (libabigail). This library is +// free software; you can redistribute it and/or modify it under the +// terms of the GNU Lesser General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) any +// later version. + +// This library is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. + +// You should have received a copy of the GNU Lesser General Public +// License along with this program; see the file COPYING-LGPLV3. If +// not, see . + +/// @file +/// +/// Wrappers around regex types and functions. + +#ifndef __ABG_REGEX_H__ +#define __ABG_REGEX_H__ + +#include + +#include "abg-cxx-compat.h" +#include "abg-sptr-utils.h" + +namespace abigail +{ + +/// Namespace for regex types and functions. +namespace regex +{ + +/// A convenience typedef for a shared pointer of regex_t. +typedef abg_compat::shared_ptr regex_t_sptr; + +/// A delete functor for a shared_ptr of regex_t. +struct regex_t_deleter +{ + /// The operator called to de-allocate the pointer to regex_t + /// embedded in a shared_ptr + /// + /// @param r the pointer to regex_t to de-allocate. + void + operator()(::regex_t* r) + { + regfree(r); + delete r; + } +};//end struct regex_deleter + +}// end namespace regex + +/// Specialization of sptr_utils::build_sptr for regex_t. +/// +/// This is used to wrap a pointer to regex_t into a +/// shared_ptr. +/// +/// @param p the bare pointer to regex_t to wrap into a shared_ptr. +/// +/// @return the shared_ptr that wraps @p p. +template<> +regex::regex_t_sptr +sptr_utils::build_sptr(regex_t *p); + +/// Specialization of sptr_utils::build_sptr for regex_t. +/// +/// This creates a pointer to regex_t and wraps it into a shared_ptr. +/// +/// @return the shared_ptr wrapping the newly created regex_t* +template<> +regex::regex_t_sptr +sptr_utils::build_sptr(); + +}// end namespace abigail + +#endif //__ABG_REGEX_H__ diff --git a/include/abg-sptr-utils.h b/include/abg-sptr-utils.h index 0adedbb3..9737fe5f 100644 --- a/include/abg-sptr-utils.h +++ b/include/abg-sptr-utils.h @@ -78,19 +78,6 @@ typedef shared_ptr xml_char_sptr; template<> xml_char_sptr build_sptr(xmlChar *p); -/// A convenience typedef for a shared pointer of regex_t. -typedef shared_ptr regex_t_sptr; - -/// Specialization of sptr_utils::build_sptr for regex_t. -template<> -regex_t_sptr -build_sptr(regex_t *p); - -/// Specialization of sptr_utils::build_sptr for regex_t. -template<> -regex_t_sptr -build_sptr(); - /// A deleter for shared pointers that ... doesn't delete the object /// managed by the shared pointer. struct noop_deleter @@ -101,42 +88,6 @@ struct noop_deleter {} }; -/// A delete functor for a shared_ptr of regex_t. -struct regex_t_deleter -{ - /// The operator called to de-allocate the pointer to regex_t - /// embedded in a shared_ptr - /// - /// @param r the pointer to regex_t to de-allocate. - void - operator()(::regex_t* r) - { - regfree(r); - delete r; - } -};//end struct regex_deleter - -/// Specialization of sptr_utils::build_sptr for regex_t. -/// -/// This is used to wrap a pointer to regex_t into a -/// shared_ptr. -/// -/// @param p the bare pointer to regex_t to wrap into a shared_ptr. -/// -/// @return the shared_ptr that wraps @p p. -template<> -regex_t_sptr -build_sptr(regex_t *p); - -/// Specialization of sptr_utils::build_sptr for regex_t. -/// -/// This creates a pointer to regex_t and wraps it into a shared_ptr. -/// -/// @return the shared_ptr wrapping the newly created regex_t* -template<> -regex_t_sptr -build_sptr(); - }// end namespace sptr_utils }// end namespace abigail diff --git a/src/Makefile.am b/src/Makefile.am index fafab853..1153a5f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,6 @@ endif libabigail_la_SOURCES = \ abg-internal.h \ -abg-sptr-utils.cc \ abg-traverse.cc \ abg-ir-priv.h \ abg-ir.cc \ @@ -41,6 +40,7 @@ abg-workers.cc \ abg-tools-utils.cc \ abg-elf-helpers.h \ abg-elf-helpers.cc \ +abg-regex.cc \ $(CXX11_SOURCES) libabigail_la_LIBADD = $(DEPS_LIBS) diff --git a/src/abg-corpus-priv.h b/src/abg-corpus-priv.h index 4cb2e43c..e65f7c8f 100644 --- a/src/abg-corpus-priv.h +++ b/src/abg-corpus-priv.h @@ -30,6 +30,7 @@ #define __ABG_CORPUS_PRIV_H__ #include "abg-sptr-utils.h" +#include "abg-regex.h" #include "abg-internal.h" namespace abigail @@ -42,7 +43,7 @@ namespace sptr_utils namespace ir { -using sptr_utils::regex_t_sptr; +using regex::regex_t_sptr; /// A convenience typedef for std::vector. typedef vector regex_t_sptrs_type; diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 12f44fd1..2e9f304d 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -67,7 +67,7 @@ using zip_utils::open_archive; using zip_utils::open_file_in_archive; #endif // WITH_ZIP_ARCHIVE -using sptr_utils::regex_t_sptr; +using regex::regex_t_sptr; /// Constructor of @ref corpus::exported_decls_builder. /// diff --git a/src/abg-sptr-utils.cc b/src/abg-regex.cc similarity index 84% rename from src/abg-sptr-utils.cc rename to src/abg-regex.cc index 2a6739a8..13f5841d 100644 --- a/src/abg-sptr-utils.cc +++ b/src/abg-regex.cc @@ -24,13 +24,11 @@ /// #include "abg-sptr-utils.h" +#include "abg-regex.h" namespace abigail { -namespace sptr_utils -{ - /// Specialization of sptr_utils::build_sptr for regex_t. /// /// This is used to wrap a pointer to regex_t into a @@ -40,9 +38,9 @@ namespace sptr_utils /// /// @return the shared_ptr that wraps @p p. template<> -regex_t_sptr -build_sptr(regex_t *p) -{return regex_t_sptr(p, regex_t_deleter());} +regex::regex_t_sptr +sptr_utils::build_sptr(regex_t *p) +{return regex::regex_t_sptr(p, regex::regex_t_deleter());} /// Specialization of sptr_utils::build_sptr for regex_t. /// @@ -50,9 +48,8 @@ build_sptr(regex_t *p) /// /// @return the shared_ptr wrapping the newly created regex_t* template<> -regex_t_sptr -build_sptr() -{return build_sptr(new regex_t);} +regex::regex_t_sptr +sptr_utils::build_sptr() +{return sptr_utils::build_sptr(new regex_t);} -} -} +}//end namespace abigail diff --git a/src/abg-suppression-priv.h b/src/abg-suppression-priv.h index 1a9a7207..c37ceff6 100644 --- a/src/abg-suppression-priv.h +++ b/src/abg-suppression-priv.h @@ -31,6 +31,7 @@ #include "abg-fwd.h" #include "abg-suppression.h" #include "abg-sptr-utils.h" +#include "abg-regex.h" namespace abigail { @@ -47,13 +48,13 @@ class suppression_base::priv bool drops_artifact_; string label_; string file_name_regex_str_; - mutable sptr_utils::regex_t_sptr file_name_regex_; + mutable regex::regex_t_sptr file_name_regex_; string file_name_not_regex_str_; - mutable sptr_utils::regex_t_sptr file_name_not_regex_; + mutable regex::regex_t_sptr file_name_not_regex_; string soname_regex_str_; - mutable sptr_utils::regex_t_sptr soname_regex_; + mutable regex::regex_t_sptr soname_regex_; string soname_not_regex_str_; - mutable sptr_utils::regex_t_sptr soname_not_regex_; + mutable regex::regex_t_sptr soname_not_regex_; public: priv() @@ -87,14 +88,14 @@ public: /// /// If the 'file_name_regex' property of @ref suppression_base is /// empty then this method returns nil. - const sptr_utils::regex_t_sptr& + const regex::regex_t_sptr& get_file_name_regex() const { if (!file_name_regex_) { if (!file_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), file_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -112,14 +113,14 @@ public: /// /// If the 'file_name_not_regex' property of @ref suppression_base /// is empty then this method returns nil. - const sptr_utils::regex_t_sptr& + const regex::regex_t_sptr& get_file_name_not_regex() const { if (!file_name_not_regex_) { if (!file_name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), file_name_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -137,14 +138,14 @@ public: /// /// If the 'soname_regex' property of @ref suppression_base is empty /// then this method returns nil. - const sptr_utils::regex_t_sptr& + const regex::regex_t_sptr& get_soname_regex() const { if (!soname_regex_) { if (!soname_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), soname_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -162,14 +163,14 @@ public: /// /// If the 'soname_not_regex' property of @ref suppression_base is /// empty then this method returns nil. - const sptr_utils::regex_t_sptr& + const regex::regex_t_sptr& get_soname_not_regex() const { if (!soname_not_regex_) { if (!soname_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), soname_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -192,14 +193,14 @@ public: matches_soname(const string& soname) const { bool has_regexp = false; - if (sptr_utils::regex_t_sptr regexp = get_soname_regex()) + if (regex::regex_t_sptr regexp = get_soname_regex()) { has_regexp = true; if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) != 0) return false; } - if (sptr_utils::regex_t_sptr regexp = get_soname_not_regex()) + if (regex::regex_t_sptr regexp = get_soname_not_regex()) { has_regexp = true; if (regexec(regexp.get(), soname.c_str(), 0, NULL, 0) == 0) @@ -227,7 +228,7 @@ public: { bool has_regexp = false; - if (sptr_utils::regex_t_sptr regexp = get_file_name_regex()) + if (regex::regex_t_sptr regexp = get_file_name_regex()) { has_regexp = true; if (regexec(regexp.get(), binary_name.c_str(), @@ -235,7 +236,7 @@ public: return false; } - if (sptr_utils::regex_t_sptr regexp = get_file_name_not_regex()) + if (regex::regex_t_sptr regexp = get_file_name_not_regex()) { has_regexp = true; if (regexec(regexp.get(), binary_name.c_str(), @@ -263,7 +264,7 @@ class function_suppression::parameter_spec::priv size_t index_; string type_name_; string type_name_regex_str_; - mutable sptr_utils::regex_t_sptr type_name_regex_; + mutable regex::regex_t_sptr type_name_regex_; priv() : index_() @@ -277,12 +278,12 @@ class function_suppression::parameter_spec::priv : index_(i), type_name_(tn), type_name_regex_str_(tn_regex) {} - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_type_name_regex() const { if (!type_name_regex_ && !type_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), type_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -302,21 +303,21 @@ struct function_suppression::priv change_kind change_kind_; string name_; string name_regex_str_; - mutable sptr_utils::regex_t_sptr name_regex_; + mutable regex::regex_t_sptr name_regex_; string name_not_regex_str_; - mutable sptr_utils::regex_t_sptr name_not_regex_; + mutable regex::regex_t_sptr name_not_regex_; string return_type_name_; string return_type_regex_str_; - mutable sptr_utils::regex_t_sptr return_type_regex_; + mutable regex::regex_t_sptr return_type_regex_; parameter_specs_type parm_specs_; string symbol_name_; string symbol_name_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_name_regex_; + mutable regex::regex_t_sptr symbol_name_regex_; string symbol_name_not_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_name_not_regex_; + mutable regex::regex_t_sptr symbol_name_not_regex_; string symbol_version_; string symbol_version_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_version_regex_; + mutable regex::regex_t_sptr symbol_version_regex_; bool allow_other_aliases_; priv(): @@ -356,12 +357,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::name_regex_str_.. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_name_regex() const { if (!name_regex_ && !name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -379,12 +380,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::name_not_regex_str_.. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_name_not_regex() const { if (!name_not_regex_ && !name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), name_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -402,12 +403,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::return_type_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_return_type_regex() const { if (!return_type_regex_ && !return_type_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), return_type_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -425,12 +426,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::symbol_name_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_name_regex() const { if (!symbol_name_regex_ && !symbol_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -448,12 +449,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::symbol_name_not_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_name_not_regex() const { if (!symbol_name_not_regex_ && !symbol_name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_name_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -471,12 +472,12 @@ struct function_suppression::priv /// /// @return a pointer to the regular expression object of /// function_suppression::priv::symbol_version_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_version_regex() const { if (!symbol_version_regex_ && ! symbol_version_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_version_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -561,20 +562,20 @@ struct variable_suppression::priv change_kind change_kind_; string name_; string name_regex_str_; - mutable sptr_utils::regex_t_sptr name_regex_; + mutable regex::regex_t_sptr name_regex_; string name_not_regex_str_; - mutable sptr_utils::regex_t_sptr name_not_regex_; + mutable regex::regex_t_sptr name_not_regex_; string symbol_name_; string symbol_name_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_name_regex_; + mutable regex::regex_t_sptr symbol_name_regex_; string symbol_name_not_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_name_not_regex_; + mutable regex::regex_t_sptr symbol_name_not_regex_; string symbol_version_; string symbol_version_regex_str_; - mutable sptr_utils::regex_t_sptr symbol_version_regex_; + mutable regex::regex_t_sptr symbol_version_regex_; string type_name_; string type_name_regex_str_; - mutable sptr_utils::regex_t_sptr type_name_regex_; + mutable regex::regex_t_sptr type_name_regex_; priv(const string& name, const string& name_regex_str, @@ -604,12 +605,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::name_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_name_regex() const { if (!name_regex_ && !name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -627,12 +628,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::name_not_regex_str_.. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_name_not_regex() const { if (!name_not_regex_ && !name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), name_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -650,12 +651,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::symbol_name_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_name_regex() const { if (!symbol_name_regex_ && !symbol_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -673,12 +674,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::symbol_name_not_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_name_not_regex() const { if (!symbol_name_not_regex_ && !symbol_name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_name_not_regex_str_.c_str(), REG_EXTENDED) == 0) symbol_name_not_regex_ = r; @@ -695,12 +696,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::symbol_version_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_symbol_version_regex() const { if (!symbol_version_regex_ && !symbol_version_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), symbol_version_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -718,12 +719,12 @@ struct variable_suppression::priv /// /// @return a pointer to the regular expression object of /// variable_suppression::priv::type_name_regex_str_. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_type_name_regex() const { if (!type_name_regex_ && !type_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), type_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -766,18 +767,18 @@ variable_is_suppressed(const ReadContextType& ctxt, class type_suppression::priv { string type_name_regex_str_; - mutable sptr_utils::regex_t_sptr type_name_regex_; + mutable regex::regex_t_sptr type_name_regex_; string type_name_; string type_name_not_regex_str_; - mutable sptr_utils::regex_t_sptr type_name_not_regex_; + mutable regex::regex_t_sptr type_name_not_regex_; bool consider_type_kind_; type_suppression::type_kind type_kind_; bool consider_reach_kind_; type_suppression::reach_kind reach_kind_; type_suppression::insertion_ranges insertion_ranges_; - unordered_set source_locations_to_keep_; + unordered_set source_locations_to_keep_; string source_location_to_keep_regex_str_; - mutable sptr_utils::regex_t_sptr source_location_to_keep_regex_; + mutable regex::regex_t_sptr source_location_to_keep_regex_; mutable vector changed_enumerator_names_; priv(); @@ -805,14 +806,14 @@ public: /// /// If the 'type_name_regex' property of @ref type_suppression is /// empty then this method returns nil. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_type_name_regex() const { if (!type_name_regex_) { if (!type_name_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), type_name_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -826,7 +827,7 @@ public: /// /// @param r the new type_name_regex object. void - set_type_name_regex(sptr_utils::regex_t_sptr r) + set_type_name_regex(regex::regex_t_sptr r) {type_name_regex_ = r;} /// Get the regular expression object associated to the @@ -837,14 +838,14 @@ public: /// /// If the 'type_name_not_regex' property of @ref type_suppression is /// empty then this method returns nil. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_type_name_not_regex() const { if (!type_name_not_regex_) { if (!type_name_not_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), type_name_not_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -858,7 +859,7 @@ public: /// /// @param r the new type_name_not_regex object. void - set_type_name_not_regex(sptr_utils::regex_t_sptr r) + set_type_name_not_regex(regex::regex_t_sptr r) {type_name_not_regex_ = r;} /// Getter for the string that denotes the 'type_name_not_regex' @@ -882,14 +883,14 @@ public: /// Getter for the source_location_to_keep_regex object. /// /// This function builds the regex if it's not yet built. - const sptr_utils::regex_t_sptr + const regex::regex_t_sptr get_source_location_to_keep_regex() const { if (!source_location_to_keep_regex_) { if (!source_location_to_keep_regex_str_.empty()) { - sptr_utils::regex_t_sptr r = sptr_utils::build_sptr(); + regex::regex_t_sptr r = sptr_utils::build_sptr(); if (regcomp(r.get(), source_location_to_keep_regex_str_.c_str(), REG_EXTENDED) == 0) @@ -903,7 +904,7 @@ public: /// /// @param r the new regex object. void - set_source_location_to_keep_regex(sptr_utils::regex_t_sptr r) + set_source_location_to_keep_regex(regex::regex_t_sptr r) {source_location_to_keep_regex_ = r;} friend class type_suppression; diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index d3ccb63c..f26c9208 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -49,6 +49,7 @@ namespace suppr { using abg_compat::dynamic_pointer_cast; +using regex::regex_t_sptr; // @@ -990,7 +991,7 @@ suppression_matches_type_name(const type_suppression& s, // If the qualified name of the considered type doesn't match // the regular expression of the type name, then this // suppression doesn't apply. - if (const sptr_utils::regex_t_sptr& type_name_regex = + if (const regex_t_sptr& type_name_regex = s.priv_->get_type_name_regex()) { if (regexec(type_name_regex.get(), @@ -999,7 +1000,7 @@ suppression_matches_type_name(const type_suppression& s, return false; } - if (const sptr_utils::regex_t_sptr type_name_not_regex = + if (const regex_t_sptr type_name_not_regex = s.priv_->get_type_name_not_regex()) { if (regexec(type_name_not_regex.get(), @@ -1050,8 +1051,7 @@ suppression_matches_type_location(const type_suppression& s, unsigned loc_line = 0, loc_column = 0; loc.expand(loc_path, loc_line, loc_column); - if (sptr_utils::regex_t_sptr regexp = - s.priv_->get_source_location_to_keep_regex()) + if (regex_t_sptr regexp = s.priv_->get_source_location_to_keep_regex()) if (regexec(regexp.get(), loc_path.c_str(), 0, NULL, 0) == 0) return false; @@ -2500,7 +2500,7 @@ function_suppression::suppresses_function(const function_decl* fn, } // check if the "name_regexp" property matches. - const sptr_utils::regex_t_sptr name_regex = priv_->get_name_regex(); + const regex_t_sptr name_regex = priv_->get_name_regex(); if (name_regex) { if (regexec(name_regex.get(), @@ -2535,7 +2535,7 @@ function_suppression::suppresses_function(const function_decl* fn, } // check if the "name_not_regexp" property matches. - const sptr_utils::regex_t_sptr name_not_regex = priv_->get_name_not_regex(); + const regex_t_sptr name_not_regex = priv_->get_name_not_regex(); if (name_not_regex) { if (regexec(name_not_regex.get(), @@ -2585,8 +2585,7 @@ function_suppression::suppresses_function(const function_decl* fn, } else { - const sptr_utils::regex_t_sptr return_type_regex = - priv_->get_return_type_regex(); + const regex_t_sptr return_type_regex = priv_->get_return_type_regex(); if (return_type_regex && (regexec(return_type_regex.get(), fn_return_type_name.c_str(), @@ -2626,15 +2625,14 @@ function_suppression::suppresses_function(const function_decl* fn, } else if (sym) { - const sptr_utils::regex_t_sptr symbol_name_regex = - priv_->get_symbol_name_regex(); + const regex_t_sptr symbol_name_regex = priv_->get_symbol_name_regex(); if (symbol_name_regex && (regexec(symbol_name_regex.get(), fn_sym_name.c_str(), 0, NULL, 0) != 0)) return false; - const sptr_utils::regex_t_sptr symbol_name_not_regex = + const regex_t_sptr symbol_name_not_regex = priv_->get_symbol_name_not_regex(); if (symbol_name_not_regex && (regexec(symbol_name_not_regex.get(), @@ -2678,7 +2676,7 @@ function_suppression::suppresses_function(const function_decl* fn, } else if (sym) { - const sptr_utils::regex_t_sptr symbol_version_regex = + const regex_t_sptr symbol_version_regex = priv_->get_symbol_version_regex(); if (symbol_version_regex && (regexec(symbol_version_regex.get(), @@ -2720,7 +2718,7 @@ function_suppression::suppresses_function(const function_decl* fn, } else { - const sptr_utils::regex_t_sptr parm_type_name_regex = + const regex_t_sptr parm_type_name_regex = (*p)->priv_->get_type_name_regex(); if (parm_type_name_regex) { @@ -2813,8 +2811,7 @@ function_suppression::suppresses_function_symbol(const elf_symbol* sym, } else if (!get_symbol_name_regex_str().empty()) { - const sptr_utils::regex_t_sptr symbol_name_regex = - priv_->get_symbol_name_regex(); + const regex_t_sptr symbol_name_regex = priv_->get_symbol_name_regex(); if (symbol_name_regex && (regexec(symbol_name_regex.get(), sym_name.c_str(), @@ -2832,7 +2829,7 @@ function_suppression::suppresses_function_symbol(const elf_symbol* sym, } else if (!get_symbol_version_regex_str().empty()) { - const sptr_utils::regex_t_sptr symbol_version_regex = + const regex_t_sptr symbol_version_regex = priv_->get_symbol_version_regex(); if (symbol_version_regex && (regexec(symbol_version_regex.get(), @@ -2927,12 +2924,12 @@ bool suppression_matches_function_name(const suppr::function_suppression& s, const string& fn_name) { - if (sptr_utils::regex_t_sptr regexp = s.priv_->get_name_regex()) + if (regex_t_sptr regexp = s.priv_->get_name_regex()) { if (regexec(regexp.get(), fn_name.c_str(), 0, NULL, 0) != 0) return false; } - else if (sptr_utils::regex_t_sptr regexp = s.priv_->get_name_not_regex()) + else if (regex_t_sptr regexp = s.priv_->get_name_not_regex()) { if (regexec(regexp.get(), fn_name.c_str(), 0, NULL, 0) == 0) return false; @@ -2963,12 +2960,12 @@ bool suppression_matches_function_sym_name(const suppr::function_suppression& s, const string& fn_linkage_name) { - if (sptr_utils::regex_t_sptr regexp = s.priv_->get_symbol_name_regex()) + if (regex_t_sptr regexp = s.priv_->get_symbol_name_regex()) { if (regexec(regexp.get(), fn_linkage_name.c_str(), 0, NULL, 0) != 0) return false; } - else if (sptr_utils::regex_t_sptr regexp = s.priv_->get_symbol_name_not_regex()) + else if (regex_t_sptr regexp = s.priv_->get_symbol_name_not_regex()) { if (regexec(regexp.get(), fn_linkage_name.c_str(), 0, NULL, 0) == 0) return false; @@ -2996,12 +2993,12 @@ bool suppression_matches_variable_name(const suppr::variable_suppression& s, const string& var_name) { - if (sptr_utils::regex_t_sptr regexp = s.priv_->get_name_regex()) + if (regex_t_sptr regexp = s.priv_->get_name_regex()) { if (regexec(regexp.get(), var_name.c_str(), 0, NULL, 0) != 0) return false; } - else if (sptr_utils::regex_t_sptr regexp = s.priv_->get_name_not_regex()) + else if (regex_t_sptr regexp = s.priv_->get_name_not_regex()) { if (regexec(regexp.get(), var_name.c_str(), 0, NULL, 0) == 0) return false; @@ -3030,12 +3027,12 @@ bool suppression_matches_variable_sym_name(const suppr::variable_suppression& s, const string& var_linkage_name) { - if (sptr_utils::regex_t_sptr regexp = s.priv_->get_symbol_name_regex()) + if (regex_t_sptr regexp = s.priv_->get_symbol_name_regex()) { if (regexec(regexp.get(), var_linkage_name.c_str(), 0, NULL, 0) != 0) return false; } - else if (sptr_utils::regex_t_sptr regexp = + else if (regex_t_sptr regexp = s.priv_->get_symbol_name_not_regex()) { if (regexec(regexp.get(), var_linkage_name.c_str(), 0, NULL, 0) == 0) @@ -3065,7 +3062,7 @@ bool suppression_matches_type(const suppr::type_suppression& s, const string& type_name) { - if (sptr_utils::regex_t_sptr regexp = s.priv_->get_type_name_regex()) + if (regex_t_sptr regexp = s.priv_->get_type_name_regex()) { if (regexec(regexp.get(), type_name.c_str(), 0, NULL, 0) != 0) return false; @@ -3780,14 +3777,13 @@ variable_suppression::suppresses_variable(const var_decl* var, // "name_regex" and "name_not_regex" properties match if (get_name().empty()) { - const sptr_utils::regex_t_sptr name_regex = priv_->get_name_regex(); + const regex_t_sptr name_regex = priv_->get_name_regex(); if (name_regex && (regexec(name_regex.get(), var_name.c_str(), 0, NULL, 0) != 0)) return false; - const sptr_utils::regex_t_sptr name_not_regex = - priv_->get_name_not_regex(); + const regex_t_sptr name_not_regex = priv_->get_name_not_regex(); if (name_not_regex && (regexec(name_not_regex.get(), var_name.c_str(), 0, NULL, 0) == 0)) @@ -3805,14 +3801,13 @@ variable_suppression::suppresses_variable(const var_decl* var, } else { - const sptr_utils::regex_t_sptr sym_name_regex = - priv_->get_symbol_name_regex(); + const regex_t_sptr sym_name_regex = priv_->get_symbol_name_regex(); if (sym_name_regex && (regexec(sym_name_regex.get(), var_sym_name.c_str(), 0, NULL, 0) != 0)) return false; - const sptr_utils::regex_t_sptr sym_name_not_regex = + const regex_t_sptr sym_name_not_regex = priv_->get_symbol_name_not_regex(); if (sym_name_not_regex && (regexec(sym_name_not_regex.get(), var_sym_name.c_str(), @@ -3830,7 +3825,7 @@ variable_suppression::suppresses_variable(const var_decl* var, } else { - const sptr_utils::regex_t_sptr symbol_version_regex = + const regex_t_sptr symbol_version_regex = priv_->get_symbol_version_regex(); if (symbol_version_regex && (regexec(symbol_version_regex.get(), @@ -3852,8 +3847,7 @@ variable_suppression::suppresses_variable(const var_decl* var, { if (get_type_name().empty()) { - const sptr_utils::regex_t_sptr type_name_regex = - priv_->get_type_name_regex(); + const regex_t_sptr type_name_regex = priv_->get_type_name_regex(); if (type_name_regex && (regexec(type_name_regex.get(), var_type_name.c_str(), 0, NULL, 0) != 0)) @@ -3946,8 +3940,7 @@ variable_suppression::suppresses_variable_symbol(const elf_symbol* sym, } else if (!get_symbol_name_regex_str().empty()) { - const sptr_utils::regex_t_sptr sym_name_regex = - priv_->get_symbol_name_regex(); + const regex_t_sptr sym_name_regex = priv_->get_symbol_name_regex(); if (sym_name_regex && (regexec(sym_name_regex.get(), sym_name.c_str(), 0, NULL, 0) != 0)) @@ -3965,7 +3958,7 @@ variable_suppression::suppresses_variable_symbol(const elf_symbol* sym, } else if (!get_symbol_version_regex_str().empty()) { - const sptr_utils::regex_t_sptr symbol_version_regex = + const regex_t_sptr symbol_version_regex = priv_->get_symbol_version_regex(); if (symbol_version_regex && (regexec(symbol_version_regex.get(), @@ -4275,16 +4268,14 @@ file_suppression::suppresses_file(const string& file_path) bool has_regexp = false; - if (sptr_utils::regex_t_sptr regexp = - suppression_base::priv_->get_file_name_regex()) + if (regex_t_sptr regexp = suppression_base::priv_->get_file_name_regex()) { has_regexp = true; if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) != 0) return false; } - if (sptr_utils::regex_t_sptr regexp = - suppression_base::priv_->get_file_name_not_regex()) + if (regex_t_sptr regexp = suppression_base::priv_->get_file_name_not_regex()) { has_regexp = true; if (regexec(regexp.get(), fname.c_str(), 0, NULL, 0) == 0)