From beededda299efd707d0e4481d8371eeda50cd9b3 Mon Sep 17 00:00:00 2001 From: Matthias Maennich Date: Fri, 5 Jul 2019 12:00:23 +0100 Subject: [PATCH] Add compatibility layer for C++11 mode Introduce a compatibility layer for C++11 code by adding include/abg-cxx-compat.h. abg-cxx-compat defines a new namespace abg_compat and defines abg_compat::hash abg_compat::shared_ptr abg_compat::weak_ptr abg_compat::dynamic_pointer_cast abg_compat::static_pointer_cast abg_compat::unordered_map abg_compat::unordered_set based on definitions from std::tr1 (std=gnu++98) or std:: (std=gnu++11). I decided for introducing abg_compat:: rather than polluting abigail:: to allow an easier transition to C++11 at a later time and to not subtly break existing code. As the shared_ptr in C++11 defines shared_ptr::operator bool() explicit, some locations where a shared_ptr is assigned to boolean, needed to be adjusted to explicitly cast to bool. * include/abg-cxx-compat.h: new file introducing the abg_compat namespace to provide C++11 functionality from either std::tr1 or std:: * include/Makefile.am: Add the new abg-cxx-compat.h to source distribution. * include/abg-comparison.h: replace std::tr1 usage by abg_compat and adjust includes accordingly: likewise * include/abg-diff-utils.h: likewise * include/abg-fwd.h: likewise * include/abg-ini.h: likewise * include/abg-interned-str.h: likewise * include/abg-ir.h: likewise * include/abg-libxml-utils.h: likewise * include/abg-libzip-utils.h: likewise * include/abg-reporter.h: likewise * include/abg-sptr-utils.h: likewise * include/abg-suppression.h: likewise * include/abg-tools-utils.h: likewise * include/abg-workers.h: likewise * src/abg-comp-filter.cc: likewise * src/abg-comparison-priv.h: likewise * src/abg-corpus.cc: likewise * src/abg-dwarf-reader.cc: likewise * src/abg-hash.cc: likewise * src/abg-ir.cc: likewise * src/abg-reader.cc: likewise * src/abg-suppression.cc: likewise * src/abg-tools-utils.cc: likewise * src/abg-writer.cc: likewise * tests/test-diff-filter.cc: likewise * tests/test-diff-pkg.cc: likewise * tests/test-read-dwarf.cc: likewise * tests/test-read-write.cc: likewise * tests/test-types-stability.cc: likewise * tests/test-write-read-archive.cc: likewise * tools/abicompat.cc: likewise * tools/abidiff.cc: likewise * tools/abidw.cc: likewise * tools/abilint.cc: likewise * tools/abipkgdiff.cc: likewise Signed-off-by: Matthias Maennich Signed-off-by: Dodji Seketeli --- include/Makefile.am | 1 + include/abg-comparison.h | 7 ++-- include/abg-cxx-compat.h | 82 ++++++++++++++++++++++++++++++++++++++ include/abg-diff-utils.h | 4 +- include/abg-fwd.h | 12 +++--- include/abg-ini.h | 6 +-- include/abg-interned-str.h | 10 ++--- include/abg-ir.h | 14 +++---- include/abg-libxml-utils.h | 6 +-- include/abg-libzip-utils.h | 4 +- include/abg-reporter.h | 4 +- include/abg-sptr-utils.h | 4 +- include/abg-suppression.h | 4 +- include/abg-tools-utils.h | 8 ++-- include/abg-workers.h | 4 +- src/abg-comp-filter.cc | 3 +- src/abg-comparison-priv.h | 7 ++-- src/abg-corpus.cc | 4 +- src/abg-dwarf-reader.cc | 13 +++--- src/abg-hash.cc | 85 ++++++++++++++++++++-------------------- src/abg-ir.cc | 27 ++++++------- src/abg-reader.cc | 14 +++---- src/abg-suppression.cc | 5 ++- src/abg-tools-utils.cc | 5 ++- src/abg-writer.cc | 10 ++--- tests/test-diff-filter.cc | 2 +- tests/test-diff-pkg.cc | 2 +- tests/test-read-dwarf.cc | 2 +- tests/test-read-write.cc | 3 +- tests/test-types-stability.cc | 2 +- tests/test-write-read-archive.cc | 2 +- tools/abicompat.cc | 4 +- tools/abidiff.cc | 2 +- tools/abidw.cc | 4 +- tools/abilint.cc | 3 +- tools/abipkgdiff.cc | 10 ++--- 36 files changed, 231 insertions(+), 148 deletions(-) create mode 100644 include/abg-cxx-compat.h diff --git a/include/Makefile.am b/include/Makefile.am index cd239c7..ae97f67 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -20,6 +20,7 @@ abg-config.h \ abg-ini.h \ abg-workers.h \ abg-traverse.h \ +abg-cxx-compat.h \ abg-version.h \ abg-viz-common.h \ abg-viz-dot.h \ diff --git a/include/abg-comparison.h b/include/abg-comparison.h index 378ce03..66392b9 100644 --- a/include/abg-comparison.h +++ b/include/abg-comparison.h @@ -25,9 +25,8 @@ /// @file -#include -#include #include +#include "abg-cxx-compat.h" #include "abg-corpus.h" #include "abg-diff-utils.h" #include "abg-reporter.h" @@ -52,8 +51,8 @@ typedef std::vector filters; // Inject types we need into this namespace. using std::ostream; using std::vector; -using std::tr1::unordered_map; -using std::tr1::unordered_set; +using abg_compat::unordered_map; +using abg_compat::unordered_set; using std::pair; using diff_utils::insertion; diff --git a/include/abg-cxx-compat.h b/include/abg-cxx-compat.h new file mode 100644 index 0000000..df4191f --- /dev/null +++ b/include/abg-cxx-compat.h @@ -0,0 +1,82 @@ +// -*- Mode: C++ -*- +// +// Copyright (C) 2019 Google, 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 2, 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-LGPLV2. If +// not, see . + +/// @file + +#ifndef __ABG_CXX_COMPAT_H +#define __ABG_CXX_COMPAT_H + +#if __cplusplus >= 201103L + +#include +#include +#include +#include + +#else + +#include +#include +#include +#include + +#endif + +namespace abg_compat { + +#if __cplusplus >= 201103L + +// +using std::hash; + +// +using std::shared_ptr; +using std::weak_ptr; +using std::dynamic_pointer_cast; +using std::static_pointer_cast; + +// +using std::unordered_map; + +// +using std::unordered_set; + +#else + +// +using std::tr1::hash; + +// +using std::tr1::shared_ptr; +using std::tr1::weak_ptr; +using std::tr1::dynamic_pointer_cast; +using std::tr1::static_pointer_cast; + +// +using std::tr1::unordered_map; + +// +using std::tr1::unordered_set; + +#endif + +} + +#endif // __ABG_CXX_COMPAT_H diff --git a/include/abg-diff-utils.h b/include/abg-diff-utils.h index 1c71185..219cab6 100644 --- a/include/abg-diff-utils.h +++ b/include/abg-diff-utils.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-fwd.h" namespace abigail @@ -57,7 +57,7 @@ namespace abigail namespace diff_utils { -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; // Inject the names from std:: below into this namespace using std::string; diff --git a/include/abg-fwd.h b/include/abg-fwd.h index 0ea8b2b..3a71743 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -26,15 +26,13 @@ #include #include #include -#include #include #include #include -#include -#include #include #include // for std::rel_ops, at least. #include +#include "abg-cxx-compat.h" #include "abg-interned-str.h" #include "abg-hash.h" @@ -65,9 +63,9 @@ namespace abigail */ // Inject some types. -using std::tr1::shared_ptr; -using std::tr1::weak_ptr; -using std::tr1::unordered_map; +using abg_compat::shared_ptr; +using abg_compat::weak_ptr; +using abg_compat::unordered_map; using std::string; using std::vector; @@ -1342,7 +1340,7 @@ dump_decl_location(const decl_base_sptr&); /// This is a wrapper around the 'assert' glibc call. It allows for /// its argument to have side effects, so that it keeps working when /// the code of libabigail is compiled with the NDEBUG macro defined. -#define ABG_ASSERT(cond) do {({bool __abg_cond__ = (cond); assert(__abg_cond__); !!__abg_cond__;});} while (false) +#define ABG_ASSERT(cond) do {({bool __abg_cond__ = bool(cond); assert(__abg_cond__); !!__abg_cond__;});} while (false) #endif } // end namespace abigail diff --git a/include/abg-ini.h b/include/abg-ini.h index fe39441..3b5195b 100644 --- a/include/abg-ini.h +++ b/include/abg-ini.h @@ -28,11 +28,11 @@ #ifndef __ABG_INI_H__ #define __ABG_INI_H__ -#include #include #include #include #include +#include "abg-cxx-compat.h" namespace abigail { @@ -40,8 +40,8 @@ namespace abigail namespace ini { // Inject some standard types in this namespace. -using std::tr1::shared_ptr; -using std::tr1::dynamic_pointer_cast; +using abg_compat::shared_ptr; +using abg_compat::dynamic_pointer_cast; using std::string; using std::vector; using std:: pair; diff --git a/include/abg-interned-str.h b/include/abg-interned-str.h index c102c08..44d3786 100644 --- a/include/abg-interned-str.h +++ b/include/abg-interned-str.h @@ -31,18 +31,16 @@ #ifndef __ABG_INTERNED_STR_H__ #define __ABG_INTERNED_STR_H__ -#include -#include -#include #include #include +#include "abg-cxx-compat.h" namespace abigail { // Inject some std types into this namespace. -using std::tr1::unordered_set; -using std::tr1::shared_ptr; +using abg_compat::unordered_set; +using abg_compat::shared_ptr; using std::string; using std::ostream; @@ -228,7 +226,7 @@ struct hash_interned_string size_t operator()(const interned_string& s) const { - std::tr1::hash hash_size_t; + abg_compat::hash hash_size_t; return hash_size_t(reinterpret_cast(s.raw())); } }; // end struct hash_interned_string diff --git a/include/abg-ir.h b/include/abg-ir.h index 195d145..8f2209b 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-fwd.h" #include "abg-hash.h" #include "abg-traverse.h" @@ -105,7 +105,7 @@ namespace ir { // Inject some std::tr1 types in here. -using std::tr1::unordered_map; +using abg_compat::unordered_map; /// A convenience typedef fo r an ordered set of size_t. typedef unordered_set pointer_set; @@ -132,8 +132,8 @@ public: /// the pretty representation string of a particular type and the /// value is the vector of canonical types that have the same pretty /// representation string. - typedef std::tr1::unordered_map > canonical_types_map_type; + typedef abg_compat::unordered_map > + canonical_types_map_type; private: struct priv; @@ -354,7 +354,7 @@ struct type_or_decl_hash operator()(const type_or_decl_base *artifact) const { string repr = get_pretty_representation(artifact); - std::tr1::hash do_hash; + abg_compat::hash do_hash; return do_hash(repr); } @@ -723,7 +723,7 @@ typedef weak_ptr elf_symbol_wptr; /// Convenience typedef for a map which key is a string and which /// value if the elf symbol of the same name. -typedef std::tr1::unordered_map +typedef abg_compat::unordered_map string_elf_symbol_sptr_map_type; /// Convenience typedef for a shared pointer to an @@ -736,7 +736,7 @@ typedef std::vector elf_symbols; /// Convenience typedef for a map which key is a string and which /// value is a vector of elf_symbol. -typedef std::tr1::unordered_map +typedef abg_compat::unordered_map string_elf_symbols_map_type; /// Convenience typedef for a shared pointer to diff --git a/include/abg-libxml-utils.h b/include/abg-libxml-utils.h index 5f7bc23..e90ed76 100644 --- a/include/abg-libxml-utils.h +++ b/include/abg-libxml-utils.h @@ -20,9 +20,9 @@ /// @file -#include #include -#include +#include "abg-sptr-utils.h" +#include "abg-cxx-compat.h" namespace abigail { @@ -32,7 +32,7 @@ namespace xml { using sptr_utils::build_sptr; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using sptr_utils::reader_sptr; using sptr_utils::xml_char_sptr; diff --git a/include/abg-libzip-utils.h b/include/abg-libzip-utils.h index 68d5d45..98a326f 100644 --- a/include/abg-libzip-utils.h +++ b/include/abg-libzip-utils.h @@ -20,8 +20,8 @@ /// @file -#include #include +#include "abg-cxx-compat.h" namespace abigail { @@ -29,7 +29,7 @@ namespace abigail namespace zip_utils { -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using std::string; /// @brief Functor passed to shared_ptr constructor during diff --git a/include/abg-reporter.h b/include/abg-reporter.h index f11e84d..aa52f84 100644 --- a/include/abg-reporter.h +++ b/include/abg-reporter.h @@ -30,13 +30,13 @@ #include #include -#include +#include "abg-cxx-compat.h" namespace abigail { using std::ostream; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; namespace comparison { diff --git a/include/abg-sptr-utils.h b/include/abg-sptr-utils.h index 2167211..d017455 100644 --- a/include/abg-sptr-utils.h +++ b/include/abg-sptr-utils.h @@ -25,9 +25,9 @@ #ifndef __ABG_SPTR_UTILS_H__ #define __ABG_SPTR_UTILS_H__ -#include #include #include +#include "abg-cxx-compat.h" namespace abigail { @@ -36,7 +36,7 @@ namespace abigail namespace sptr_utils { -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; /// This is to be specialized for the diverse C types that needs /// wrapping in shared_ptr. diff --git a/include/abg-suppression.h b/include/abg-suppression.h index 867970c..415e74f 100644 --- a/include/abg-suppression.h +++ b/include/abg-suppression.h @@ -23,7 +23,7 @@ #ifndef __ABG_SUPPRESSION_H__ #define __ABG_SUPPRESSION_H__ -#include +#include "abg-cxx-compat.h" #include "abg-ini.h" #include "abg-comparison.h" @@ -43,7 +43,7 @@ namespace suppr { using namespace abigail::comparison; -using std::tr1::unordered_set; +using abg_compat::unordered_set; /// Base type of the suppression specifications types. /// diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index a014e85..a63f4db 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -20,13 +20,13 @@ ///@file -#include #include #include #include #include #include -#include +#include "abg-cxx-compat.h" +#include "abg-suppression.h" namespace abigail { @@ -39,7 +39,7 @@ using std::istream; using std::ifstream; using std::string; using std::set; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; const char* get_system_libdir(); const char* get_anonymous_struct_internal_name_prefix(); @@ -275,7 +275,7 @@ bool file_is_kernel_debuginfo_package(const string& file_path, file_type file_type); -std::tr1::shared_ptr +abg_compat::shared_ptr make_path_absolute(const char*p); char* diff --git a/include/abg-workers.h b/include/abg-workers.h index 173e2c2..2892837 100644 --- a/include/abg-workers.h +++ b/include/abg-workers.h @@ -31,10 +31,10 @@ #ifndef __ABG_WORKERS_H__ #define __ABG_WORKERS_H__ -#include #include +#include "abg-cxx-compat.h" -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; namespace abigail { diff --git a/src/abg-comp-filter.cc b/src/abg-comp-filter.cc index 3134f5d..5362b53 100644 --- a/src/abg-comp-filter.cc +++ b/src/abg-comp-filter.cc @@ -25,6 +25,7 @@ /// This file contains definitions of diff objects filtering /// facilities. +#include "abg-cxx-compat.h" #include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -42,7 +43,7 @@ namespace comparison namespace filtering { -using std::tr1::dynamic_pointer_cast; +using abg_compat::dynamic_pointer_cast; /// Walk the diff sub-trees of a a @ref corpus_diff and apply a filter /// to the nodes visted. The filter categorizes each node, assigning diff --git a/src/abg-comparison-priv.h b/src/abg-comparison-priv.h index 1d51207..325f012 100644 --- a/src/abg-comparison-priv.h +++ b/src/abg-comparison-priv.h @@ -32,6 +32,7 @@ #ifndef __ABG_COMPARISON_PRIV_H__ #define __ABG_COMPARISON_PRIV_H__ +#include "abg-cxx-compat.h" #include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -52,13 +53,13 @@ namespace abigail namespace comparison { -using std::tr1::unordered_set; +using abg_compat::unordered_set; using namespace abigail::suppr; // Inject types from outside in here. using std::vector; -using std::tr1::dynamic_pointer_cast; -using std::tr1::static_pointer_cast; +using abg_compat::dynamic_pointer_cast; +using abg_compat::static_pointer_cast; using abigail::sptr_utils::noop_deleter; /// Convenience typedef for a pair of decls or types. diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 0b1ebf6..329c03e 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -26,8 +26,8 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -56,7 +56,7 @@ namespace ir { using std::ostringstream; -using std::tr1::unordered_map; +using abg_compat::unordered_map; using std::list; using std::vector; diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 182279d..a46d25d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -39,14 +39,13 @@ #include #include #include -#include -#include #include #include #include #include #include +#include "abg-cxx-compat.h" #include "abg-ir-priv.h" #include "abg-suppression-priv.h" #include "abg-corpus-priv.h" @@ -77,10 +76,10 @@ using std::cerr; namespace dwarf_reader { -using std::tr1::dynamic_pointer_cast; -using std::tr1::static_pointer_cast; -using std::tr1::unordered_map; -using std::tr1::unordered_set; +using abg_compat::dynamic_pointer_cast; +using abg_compat::static_pointer_cast; +using abg_compat::unordered_map; +using abg_compat::unordered_set; using std::stack; using std::deque; using std::list; @@ -5837,7 +5836,7 @@ public: /// @return if there is a corpus group being built, false otherwise. bool has_corpus_group() const - {return cur_corpus_group_;} + {return bool(cur_corpus_group_);} /// Return the main corpus from the current corpus group, if any. /// diff --git a/src/abg-hash.cc b/src/abg-hash.cc index 6588c67..4dd9ae0 100644 --- a/src/abg-hash.cc +++ b/src/abg-hash.cc @@ -20,6 +20,7 @@ /// @file +#include "abg-cxx-compat.h" #include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -78,8 +79,8 @@ using namespace abigail::ir; size_t type_base::hash::operator()(const type_base& t) const { - std::tr1::hash size_t_hash; - std::tr1::hash str_hash; + abg_compat::hash size_t_hash; + abg_compat::hash str_hash; size_t v = str_hash(typeid(t).name()); v = hashing::combine_hashes(v, size_t_hash(t.get_size_in_bits())); @@ -111,7 +112,7 @@ struct decl_base::hash size_t operator()(const decl_base& d) const { - std::tr1::hash str_hash; + abg_compat::hash str_hash; size_t v = str_hash(typeid(d).name()); if (!d.get_linkage_name().empty()) @@ -134,7 +135,7 @@ struct type_decl::hash { decl_base::hash decl_hash; type_base::hash type_hash; - std::tr1::hash str_hash; + abg_compat::hash str_hash; size_t v = str_hash(typeid(t).name()); v = hashing::combine_hashes(v, decl_hash(t)); @@ -152,7 +153,7 @@ struct type_decl::hash size_t scope_decl::hash::operator()(const scope_decl& d) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; size_t v = hash_string(typeid(d).name()); for (scope_decl::declarations::const_iterator i = d.get_member_decls().begin(); @@ -179,7 +180,7 @@ struct scope_type_decl::hash { decl_base::hash decl_hash; type_base::hash type_hash; - std::tr1::hash str_hash; + abg_compat::hash str_hash; size_t v = str_hash(typeid(t).name()); v = hashing::combine_hashes(v, decl_hash(t)); @@ -196,7 +197,7 @@ struct qualified_type_def::hash { type_base::hash type_hash; decl_base::hash decl_hash; - std::tr1::hash str_hash; + abg_compat::hash str_hash; size_t v = str_hash(typeid(t).name()); v = hashing::combine_hashes(v, type_hash(t)); @@ -211,7 +212,7 @@ struct pointer_type_def::hash size_t operator()(const pointer_type_def& t) const { - std::tr1::hash str_hash; + abg_compat::hash str_hash; type_base::hash type_base_hash; decl_base::hash decl_hash; type_base::shared_ptr_hash hash_type_ptr; @@ -229,7 +230,7 @@ struct reference_type_def::hash size_t operator()(const reference_type_def& t) { - std::tr1::hash hash_str; + abg_compat::hash hash_str; type_base::hash hash_type_base; decl_base::hash hash_decl; type_base::shared_ptr_hash hash_type_ptr; @@ -250,7 +251,7 @@ struct array_type_def::subrange_type::hash size_t operator()(const array_type_def::subrange_type& s) const { - std::tr1::hash hash_size_t; + abg_compat::hash hash_size_t; size_t v = hash_size_t(hash_size_t(s.get_lower_bound())); v = hashing::combine_hashes(v, hash_size_t(s.get_upper_bound())); return v; @@ -262,7 +263,7 @@ struct array_type_def::hash size_t operator()(const array_type_def& t) { - std::tr1::hash hash_str; + abg_compat::hash hash_str; type_base::hash hash_type_base; decl_base::hash hash_decl; type_base::shared_ptr_hash hash_type_ptr; @@ -289,10 +290,10 @@ struct enum_type_decl::hash size_t operator()(const enum_type_decl& t) const { - std::tr1::hash str_hash; + abg_compat::hash str_hash; decl_base::hash decl_hash; type_base::shared_ptr_hash type_ptr_hash; - std::tr1::hash size_t_hash; + abg_compat::hash size_t_hash; size_t v = str_hash(typeid(t).name()); v = hashing::combine_hashes(v, decl_hash(t)); @@ -314,7 +315,7 @@ struct typedef_decl::hash size_t operator()(const typedef_decl& t) const { - std::tr1::hash str_hash; + abg_compat::hash str_hash; type_base::hash hash_type; decl_base::hash decl_hash; type_base::shared_ptr_hash type_ptr_hash; @@ -340,10 +341,10 @@ struct typedef_decl::hash size_t var_decl::hash::operator()(const var_decl& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; decl_base::hash hash_decl; type_base::shared_ptr_hash hash_type_ptr; - std::tr1::hash hash_size_t; + abg_compat::hash hash_size_t; size_t v = hash_string(typeid(t).name()); v = hashing::combine_hashes(v, hash_decl(t)); @@ -379,10 +380,10 @@ var_decl::hash::operator()(const var_decl* t) const size_t function_decl::hash::operator()(const function_decl& t) const { - std::tr1::hash hash_int; - std::tr1::hash hash_size_t; - std::tr1::hash hash_bool; - std::tr1::hash hash_string; + abg_compat::hash hash_int; + abg_compat::hash hash_size_t; + abg_compat::hash hash_bool; + abg_compat::hash hash_string; decl_base::hash hash_decl_base; type_base::shared_ptr_hash hash_type_ptr; @@ -424,8 +425,8 @@ function_decl::parameter::hash::operator() (const function_decl::parameter& p) const { type_base::shared_ptr_hash hash_type_ptr; - std::tr1::hash hash_bool; - std::tr1::hash hash_unsigned; + abg_compat::hash hash_bool; + abg_compat::hash hash_unsigned; size_t v = hash_type_ptr(p.get_type()); v = hashing::combine_hashes(v, hash_unsigned(p.get_index())); v = hashing::combine_hashes(v, hash_bool(p.get_variadic_marker())); @@ -448,7 +449,7 @@ struct method_type::hash size_t operator()(const method_type& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; type_base::shared_ptr_hash hash_type_ptr; function_decl::parameter::hash hash_parameter; @@ -484,7 +485,7 @@ struct method_type::hash size_t function_type::hash::operator()(const function_type& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; type_base::shared_ptr_hash hash_type_ptr; function_decl::parameter::hash hash_parameter; @@ -528,7 +529,7 @@ function_type::hash::operator()(const function_type_sptr t) const size_t member_base::hash::operator()(const member_base& m) const { - std::tr1::hash hash_int; + abg_compat::hash hash_int; return hash_int(m.get_access_specifier()); } @@ -537,9 +538,9 @@ class_decl::base_spec::hash::operator()(const base_spec& t) const { member_base::hash hash_member; type_base::shared_ptr_hash hash_type_ptr; - std::tr1::hash hash_size; - std::tr1::hash hash_bool; - std::tr1::hash hash_string; + abg_compat::hash hash_size; + abg_compat::hash hash_bool; + abg_compat::hash hash_string; size_t v = hash_string(typeid(t).name()); v = hashing::combine_hashes(v, hash_member(t)); @@ -553,10 +554,10 @@ size_t member_function_template::hash::operator() (const member_function_template& t) const { - std::tr1::hash hash_bool; + abg_compat::hash hash_bool; function_tdecl::hash hash_function_tdecl; member_base::hash hash_member; - std::tr1::hash hash_string; + abg_compat::hash hash_string; size_t v = hash_member(t); string n = t.get_qualified_name(); @@ -573,7 +574,7 @@ member_class_template::hash::operator() { member_base::hash hash_member; class_tdecl::hash hash_class_tdecl; - std::tr1::hash hash_string; + abg_compat::hash hash_string; size_t v = hash_member(t); string n = t.get_qualified_name(); @@ -610,7 +611,7 @@ class_or_union::hash::operator()(const class_or_union& t) const ABG_ASSERT(!t.get_is_declaration_only()); - std::tr1::hash hash_string; + abg_compat::hash hash_string; scope_type_decl::hash hash_scope_type; var_decl::hash hash_data_member; member_function_template::hash hash_member_fn_tmpl; @@ -689,7 +690,7 @@ class_decl::hash::operator()(const class_decl& t) const ABG_ASSERT(!t.get_is_declaration_only()); - std::tr1::hash hash_string; + abg_compat::hash hash_string; class_decl::base_spec::hash hash_base; class_or_union::hash hash_class_or_union; @@ -738,8 +739,8 @@ struct template_parameter::hash t.set_hashing_has_started(true); - std::tr1::hash hash_unsigned; - std::tr1::hash hash_string; + abg_compat::hash hash_unsigned; + abg_compat::hash hash_string; template_decl::hash hash_template_decl; size_t v = hash_string(typeid(t).name()); @@ -769,7 +770,7 @@ struct template_parameter::shared_ptr_hash size_t template_decl::hash::operator()(const template_decl& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; template_parameter::shared_ptr_hash hash_template_parameter; size_t v = hash_string(typeid(t).name()); @@ -790,7 +791,7 @@ struct type_tparameter::hash size_t operator()(const type_tparameter& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; template_parameter::hash hash_template_parameter; type_decl::hash hash_type; @@ -811,7 +812,7 @@ size_t non_type_tparameter::hash::operator()(const non_type_tparameter& t) const { template_parameter::hash hash_template_parameter; - std::tr1::hash hash_string; + abg_compat::hash hash_string; type_base::shared_ptr_hash hash_type; size_t v = hash_string(typeid(t).name()); @@ -836,7 +837,7 @@ struct template_tparameter::hash size_t operator()(const template_tparameter& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; type_tparameter::hash hash_template_type_parm; template_decl::hash hash_template_decl; @@ -874,7 +875,7 @@ operator()(const template_parameter* t) const size_t type_composition::hash::operator()(const type_composition& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; type_base::dynamic_hash hash_type; size_t v = hash_string(typeid(t).name()); @@ -895,7 +896,7 @@ size_t function_tdecl::hash:: operator()(const function_tdecl& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; decl_base::hash hash_decl_base; template_decl::hash hash_template_decl; function_decl::hash hash_function_decl; @@ -924,7 +925,7 @@ size_t class_tdecl::hash:: operator()(const class_tdecl& t) const { - std::tr1::hash hash_string; + abg_compat::hash hash_string; decl_base::hash hash_decl_base; template_decl::hash hash_template_decl; class_decl::hash hash_class_decl; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 27fa770..94e4ac8 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -31,9 +31,8 @@ #include #include #include -#include -#include +#include "abg-cxx-compat.h" #include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -130,9 +129,9 @@ namespace abigail using std::string; using std::list; using std::vector; -using std::tr1::unordered_map; -using std::tr1::dynamic_pointer_cast; -using std::tr1::static_pointer_cast; +using abg_compat::unordered_map; +using abg_compat::dynamic_pointer_cast; +using abg_compat::static_pointer_cast; /// Convenience typedef for a map of string -> string*. typedef unordered_map pool_map_type; @@ -1620,7 +1619,7 @@ elf_symbol::get_next_alias() const ///@return true iff the current elf_symbol has an alias. bool elf_symbol::has_aliases() const -{return get_next_alias();} +{return bool(get_next_alias());} /// Get the number of aliases to this elf symbol /// @@ -1698,7 +1697,7 @@ bool elf_symbol::has_other_common_instances() const { ABG_ASSERT(is_common_symbol()); - return get_next_common_instance(); + return bool(get_next_common_instance()); } /// Get the next common instance of the current common symbol. @@ -1955,7 +1954,7 @@ elf_symbol::operator==(const elf_symbol& other) const { bool are_equal = textually_equals(*this, other); if (!are_equal) - are_equal = get_alias_which_equals(other); + are_equal = bool(get_alias_which_equals(other)); return are_equal; } @@ -21649,7 +21648,7 @@ hash_type_or_decl(const type_or_decl_base *tod) ABG_ASSERT(v->get_type()); size_t h = hash_type_or_decl(v->get_type()); string repr = v->get_pretty_representation(); - std::tr1::hash hash_string; + abg_compat::hash hash_string; h = hashing::combine_hashes(h, hash_string(repr)); result = h; } @@ -21658,7 +21657,7 @@ hash_type_or_decl(const type_or_decl_base *tod) ABG_ASSERT(f->get_type()); size_t h = hash_type_or_decl(f->get_type()); string repr = f->get_pretty_representation(); - std::tr1::hash hash_string; + abg_compat::hash hash_string; h = hashing::combine_hashes(h, hash_string(repr)); result = h; } @@ -21666,8 +21665,8 @@ hash_type_or_decl(const type_or_decl_base *tod) { type_base_sptr parm_type = p->get_type(); ABG_ASSERT(parm_type); - std::tr1::hash hash_bool; - std::tr1::hash hash_unsigned; + abg_compat::hash hash_bool; + abg_compat::hash hash_unsigned; size_t h = hash_type_or_decl(parm_type); h = hashing::combine_hashes(h, hash_unsigned(p->get_index())); h = hashing::combine_hashes(h, hash_bool(p->get_variadic_marker())); @@ -21676,8 +21675,8 @@ hash_type_or_decl(const type_or_decl_base *tod) else if (class_decl::base_spec *bs = is_class_base_spec(d)) { member_base::hash hash_member; - std::tr1::hash hash_size; - std::tr1::hash hash_bool; + abg_compat::hash hash_size; + abg_compat::hash hash_bool; type_base_sptr type = bs->get_base_class(); size_t h = hash_type_or_decl(type); h = hashing::combine_hashes(h, hash_member(*bs)); diff --git a/src/abg-reader.cc b/src/abg-reader.cc index a7e0d55..1567518 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -29,13 +29,13 @@ #include #include #include -#include #include #include #include #include #include +#include "abg-cxx-compat.h" #include "abg-suppression-priv.h" #include "abg-internal.h" @@ -63,9 +63,9 @@ namespace xml_reader { using std::string; using std::deque; -using std::tr1::shared_ptr; -using std::tr1::unordered_map; -using std::tr1::dynamic_pointer_cast; +using abg_compat::shared_ptr; +using abg_compat::unordered_map; +using abg_compat::dynamic_pointer_cast; using std::vector; using std::istream; #ifdef WITH_ZIP_ARCHIVE @@ -404,7 +404,7 @@ public: if (d) return (ir::get_translation_unit(d) == get_translation_unit()); else if (function_type_sptr fn_type = is_function_type(type)) - return lookup_function_type(fn_type, *get_translation_unit()); + return bool(lookup_function_type(fn_type, *get_translation_unit())); else return false; } @@ -1901,7 +1901,7 @@ read_corpus_from_input(read_context& ctxt) do { translation_unit_sptr tu = read_translation_unit_from_input(ctxt); - is_ok = tu; + is_ok = bool(tu); } while (is_ok); @@ -2750,7 +2750,7 @@ build_elf_symbol_db(read_context& ctxt, ctxt.set_corpus_node(node); - typedef std::tr1::unordered_map + typedef abg_compat::unordered_map xml_node_ptr_elf_symbol_sptr_map_type; xml_node_ptr_elf_symbol_sptr_map_type xml_node_ptr_elf_symbol_map; diff --git a/src/abg-suppression.cc b/src/abg-suppression.cc index 8544826..e410d36 100644 --- a/src/abg-suppression.cc +++ b/src/abg-suppression.cc @@ -25,8 +25,9 @@ /// This contains the implementation of the suppression engine of /// libabigail. -#include "abg-internal.h" #include +#include "abg-cxx-compat.h" +#include "abg-internal.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -47,7 +48,7 @@ namespace abigail namespace suppr { -using std::tr1::dynamic_pointer_cast; +using abg_compat::dynamic_pointer_cast; // diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 87a79c0..9300beb 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -62,6 +62,7 @@ #include "abg-dwarf-reader.h" #include "abg-internal.h" +#include "abg-cxx-compat.h" // ABG_BEGIN_EXPORT_DECLARATIONS @@ -1591,10 +1592,10 @@ struct malloced_char_star_deleter /// @param p the path to turn into an absolute path. /// /// @return a shared pointer to the resulting absolute path. -std::tr1::shared_ptr +abg_compat::shared_ptr make_path_absolute(const char*p) { - using std::tr1::shared_ptr; + using abg_compat::shared_ptr; shared_ptr result; diff --git a/src/abg-writer.cc b/src/abg-writer.cc index b38bdec..0d3b853 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -33,8 +33,8 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-tools-utils.h" #include "abg-internal.h" @@ -59,16 +59,16 @@ ABG_END_EXPORT_DECLARATIONS namespace abigail { using std::cerr; -using std::tr1::shared_ptr; -using std::tr1::dynamic_pointer_cast; -using std::tr1::static_pointer_cast; +using abg_compat::shared_ptr; +using abg_compat::dynamic_pointer_cast; +using abg_compat::static_pointer_cast; using std::ofstream; using std::ostream; using std::ostringstream; using std::list; using std::vector; using std::stack; -using std::tr1::unordered_map; +using abg_compat::unordered_map; using abigail::sptr_utils::noop_deleter; #if WITH_ZIP_ARCHIVE diff --git a/tests/test-diff-filter.cc b/tests/test-diff-filter.cc index a0e0c77..04a1f67 100644 --- a/tests/test-diff-filter.cc +++ b/tests/test-diff-filter.cc @@ -660,7 +660,7 @@ int main() { using std::vector; - using std::tr1::dynamic_pointer_cast; + using abg_compat::dynamic_pointer_cast; using abigail::workers::queue; using abigail::workers::task; using abigail::workers::task_sptr; diff --git a/tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc index 59ef7d6..95338be 100644 --- a/tests/test-diff-pkg.cc +++ b/tests/test-diff-pkg.cc @@ -786,7 +786,7 @@ int main() { using std::vector; - using std::tr1::dynamic_pointer_cast; + using abg_compat::dynamic_pointer_cast; using abigail::workers::queue; using abigail::workers::task; using abigail::workers::task_sptr; diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index b3be07f..f089f6c 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -40,7 +40,7 @@ using std::vector; using std::string; using std::ofstream; using std::cerr; -using std::tr1::dynamic_pointer_cast; +using abg_compat::dynamic_pointer_cast; using abigail::tests::get_build_dir; using abigail::dwarf_reader::read_corpus_from_elf; using abigail::dwarf_reader::read_context; diff --git a/tests/test-read-write.cc b/tests/test-read-write.cc index 3624b99..6fa43ba 100644 --- a/tests/test-read-write.cc +++ b/tests/test-read-write.cc @@ -28,6 +28,7 @@ #include #include #include +#include "abg-cxx-compat.h" #include "abg-ir.h" #include "abg-reader.h" #include "abg-writer.h" @@ -40,7 +41,7 @@ using std::vector; using std::ofstream; using std::cerr; -using std::tr1::dynamic_pointer_cast; +using abg_compat::dynamic_pointer_cast; using abigail::tools_utils::file_type; using abigail::tools_utils::check_file; diff --git a/tests/test-types-stability.cc b/tests/test-types-stability.cc index 28b19f9..b075efe 100644 --- a/tests/test-types-stability.cc +++ b/tests/test-types-stability.cc @@ -112,7 +112,7 @@ int main() { using std::vector; - using std::tr1::dynamic_pointer_cast; + using abg_compat::dynamic_pointer_cast; using abigail::workers::queue; using abigail::workers::task; using abigail::workers::task_sptr; diff --git a/tests/test-write-read-archive.cc b/tests/test-write-read-archive.cc index aa83dc7..85fbeb1 100644 --- a/tests/test-write-read-archive.cc +++ b/tests/test-write-read-archive.cc @@ -78,7 +78,7 @@ const InOutSpec archive_spec = using std::string; using std::cerr; using std::ofstream; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using abigail::corpus; using abigail::corpus_sptr; using abigail::translation_unit; diff --git a/tools/abicompat.cc b/tools/abicompat.cc index deee21e..fb5b44c 100644 --- a/tools/abicompat.cc +++ b/tools/abicompat.cc @@ -48,7 +48,7 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-config.h" #include "abg-tools-utils.h" #include "abg-corpus.h" @@ -62,7 +62,7 @@ using std::cout; using std::ostream; using std::ofstream; using std::vector; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using abigail::tools_utils::emit_prefix; diff --git a/tools/abidiff.cc b/tools/abidiff.cc index 1e29888..a8b7828 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -38,7 +38,7 @@ using std::string; using std::ostream; using std::cout; using std::cerr; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using abigail::ir::environment; using abigail::ir::environment_sptr; using abigail::translation_unit; diff --git a/tools/abidw.cc b/tools/abidw.cc index e5ca872..111ceb2 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -35,7 +35,7 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-config.h" #include "abg-tools-utils.h" #include "abg-corpus.h" @@ -50,7 +50,7 @@ using std::cout; using std::ostream; using std::ofstream; using std::vector; -using std::tr1::shared_ptr; +using abg_compat::shared_ptr; using abigail::tools_utils::emit_prefix; using abigail::tools_utils::temp_file; using abigail::tools_utils::temp_file_sptr; diff --git a/tools/abilint.cc b/tools/abilint.cc index 0bdc496..4b5b1e1 100644 --- a/tools/abilint.cc +++ b/tools/abilint.cc @@ -35,6 +35,7 @@ #include #include #include +#include "abg-cxx-compat.h" #include "abg-config.h" #include "abg-tools-utils.h" #include "abg-ir.h" @@ -81,7 +82,7 @@ struct options bool read_tu; bool diff; bool noout; - std::tr1::shared_ptr di_root_path; + abg_compat::shared_ptr di_root_path; vector suppression_paths; string headers_dir; diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index bc3fce7..f3065fd 100644 --- a/tools/abipkgdiff.cc +++ b/tools/abipkgdiff.cc @@ -95,8 +95,8 @@ #include #include #include -#include +#include "abg-cxx-compat.h" #include "abg-workers.h" #include "abg-config.h" #include "abg-tools-utils.h" @@ -110,11 +110,11 @@ using std::string; using std::ostream; using std::vector; using std::map; -using std::tr1::unordered_set; +using abg_compat::unordered_set; using std::set; using std::ostringstream; -using std::tr1::shared_ptr; -using std::tr1::dynamic_pointer_cast; +using abg_compat::shared_ptr; +using abg_compat::dynamic_pointer_cast; using abigail::workers::task; using abigail::workers::task_sptr; using abigail::workers::queue; @@ -1532,7 +1532,7 @@ maybe_create_private_types_suppressions(package& pkg, const options &opts) pkg.private_types_suppressions().push_back(suppr); } - return suppr; + return bool(suppr); } /// If the user wants to avoid comparing DSOs that are private to this -- 2.7.4