Add compatibility layer for C++11 mode
authorMatthias Maennich <maennich@google.com>
Fri, 5 Jul 2019 11:00:23 +0000 (12:00 +0100)
committerDodji Seketeli <dodji@redhat.com>
Tue, 9 Jul 2019 16:05:28 +0000 (18:05 +0200)
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 <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
36 files changed:
include/Makefile.am
include/abg-comparison.h
include/abg-cxx-compat.h [new file with mode: 0644]
include/abg-diff-utils.h
include/abg-fwd.h
include/abg-ini.h
include/abg-interned-str.h
include/abg-ir.h
include/abg-libxml-utils.h
include/abg-libzip-utils.h
include/abg-reporter.h
include/abg-sptr-utils.h
include/abg-suppression.h
include/abg-tools-utils.h
include/abg-workers.h
src/abg-comp-filter.cc
src/abg-comparison-priv.h
src/abg-corpus.cc
src/abg-dwarf-reader.cc
src/abg-hash.cc
src/abg-ir.cc
src/abg-reader.cc
src/abg-suppression.cc
src/abg-tools-utils.cc
src/abg-writer.cc
tests/test-diff-filter.cc
tests/test-diff-pkg.cc
tests/test-read-dwarf.cc
tests/test-read-write.cc
tests/test-types-stability.cc
tests/test-write-read-archive.cc
tools/abicompat.cc
tools/abidiff.cc
tools/abidw.cc
tools/abilint.cc
tools/abipkgdiff.cc

index cd239c7..ae97f67 100644 (file)
@@ -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          \
index 378ce03..66392b9 100644 (file)
@@ -25,9 +25,8 @@
 
 /// @file
 
-#include <tr1/unordered_map>
-#include <tr1/unordered_set>
 #include <ostream>
+#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<filter_base_sptr> 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 (file)
index 0000000..df4191f
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+/// @file
+
+#ifndef __ABG_CXX_COMPAT_H
+#define __ABG_CXX_COMPAT_H
+
+#if __cplusplus >= 201103L
+
+#include <functional>
+#include <memory>
+#include <unordered_map>
+#include <unordered_set>
+
+#else
+
+#include <tr1/functional>
+#include <tr1/memory>
+#include <tr1/unordered_map>
+#include <tr1/unordered_set>
+
+#endif
+
+namespace abg_compat {
+
+#if __cplusplus >= 201103L
+
+// <functional>
+using std::hash;
+
+// <memory>
+using std::shared_ptr;
+using std::weak_ptr;
+using std::dynamic_pointer_cast;
+using std::static_pointer_cast;
+
+// <unordered_map>
+using std::unordered_map;
+
+// <unordered_set>
+using std::unordered_set;
+
+#else
+
+// <functional>
+using std::tr1::hash;
+
+// <memory>
+using std::tr1::shared_ptr;
+using std::tr1::weak_ptr;
+using std::tr1::dynamic_pointer_cast;
+using std::tr1::static_pointer_cast;
+
+// <unordered_map>
+using std::tr1::unordered_map;
+
+// <unordered_set>
+using std::tr1::unordered_set;
+
+#endif
+
+}
+
+#endif  // __ABG_CXX_COMPAT_H
index 1c71185..219cab6 100644 (file)
@@ -43,7 +43,7 @@
 #include <string>
 #include <vector>
 #include <sstream>
-#include <tr1/memory>
+#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;
index 0ea8b2b..3a71743 100644 (file)
 #include <stdint.h>
 #include <cstdlib>
 #include <cstddef>
-#include <tr1/memory>
 #include <list>
 #include <vector>
 #include <string>
-#include <tr1/functional>
-#include <tr1/unordered_map>
 #include <typeinfo>
 #include <utility> // for std::rel_ops, at least.
 #include <ostream>
+#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
index fe39441..3b5195b 100644 (file)
 #ifndef __ABG_INI_H__
 #define __ABG_INI_H__
 
-#include <tr1/memory>
 #include <string>
 #include <vector>
 #include <istream>
 #include <ostream>
+#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;
index c102c08..44d3786 100644 (file)
 #ifndef __ABG_INTERNED_STR_H__
 #define __ABG_INTERNED_STR_H__
 
-#include <tr1/memory>
-#include <tr1/functional>
-#include <tr1/unordered_set>
 #include <ostream>
 #include <string>
+#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<size_t> hash_size_t;
+    abg_compat::hash<size_t> hash_size_t;
     return hash_size_t(reinterpret_cast<size_t>(s.raw()));
   }
 }; // end struct hash_interned_string
index 195d145..8f2209b 100644 (file)
@@ -33,7 +33,7 @@
 #include <assert.h>
 #include <stdint.h>
 #include <cstdlib>
-#include <tr1/unordered_map>
+#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<size_t> 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<string,
-                                 std::vector<type_base_sptr> > canonical_types_map_type;
+  typedef abg_compat::unordered_map<string, std::vector<type_base_sptr> >
+      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<string> do_hash;
+    abg_compat::hash<string> do_hash;
     return do_hash(repr);
   }
 
@@ -723,7 +723,7 @@ typedef weak_ptr<elf_symbol> 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<string, elf_symbol_sptr>
+typedef abg_compat::unordered_map<string, elf_symbol_sptr>
 string_elf_symbol_sptr_map_type;
 
 /// Convenience typedef for a shared pointer to an
@@ -736,7 +736,7 @@ typedef std::vector<elf_symbol_sptr> 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<string, elf_symbols>
+typedef abg_compat::unordered_map<string, elf_symbols>
 string_elf_symbols_map_type;
 
 /// Convenience typedef for a shared pointer to
index 5f7bc23..e90ed76 100644 (file)
@@ -20,9 +20,9 @@
 
 /// @file
 
-#include <tr1/memory>
 #include <istream>
-#include <abg-sptr-utils.h>
+#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;
 
index 68d5d45..98a326f 100644 (file)
@@ -20,8 +20,8 @@
 
 /// @file
 
-#include <tr1/memory>
 #include <zip.h>
+#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
index f11e84d..aa52f84 100644 (file)
 
 #include <ostream>
 #include <string>
-#include <tr1/memory>
+#include "abg-cxx-compat.h"
 
 namespace abigail
 {
 
 using std::ostream;
-using std::tr1::shared_ptr;
+using abg_compat::shared_ptr;
 
 namespace comparison
 {
index 2167211..d017455 100644 (file)
@@ -25,9 +25,9 @@
 #ifndef __ABG_SPTR_UTILS_H__
 #define __ABG_SPTR_UTILS_H__
 
-#include <tr1/memory>
 #include <regex.h>
 #include <libxml/xmlreader.h>
+#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.
index 867970c..415e74f 100644 (file)
@@ -23,7 +23,7 @@
 #ifndef __ABG_SUPPRESSION_H__
 #define __ABG_SUPPRESSION_H__
 
-#include <tr1/unordered_set>
+#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.
 ///
index a014e85..a63f4db 100644 (file)
 
 ///@file
 
-#include <tr1/memory>
 #include <string>
 #include <set>
 #include <ostream>
 #include <istream>
 #include <iostream>
-#include <abg-suppression.h>
+#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<char>
+abg_compat::shared_ptr<char>
 make_path_absolute(const char*p);
 
 char*
index 173e2c2..2892837 100644 (file)
 #ifndef __ABG_WORKERS_H__
 #define __ABG_WORKERS_H__
 
-#include <tr1/memory>
 #include <vector>
+#include "abg-cxx-compat.h"
 
-using std::tr1::shared_ptr;
+using abg_compat::shared_ptr;
 
 namespace abigail
 {
index 3134f5d..5362b53 100644 (file)
@@ -25,6 +25,7 @@
 /// This file contains definitions of diff objects filtering
 /// facilities.
 
+#include "abg-cxx-compat.h"
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 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
index 1d51207..325f012 100644 (file)
@@ -32,6 +32,7 @@
 #ifndef __ABG_COMPARISON_PRIV_H__
 #define __ABG_COMPARISON_PRIV_H__
 
+#include "abg-cxx-compat.h"
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 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.
index 0b1ebf6..329c03e 100644 (file)
@@ -26,8 +26,8 @@
 #include <cassert>
 #include <stdexcept>
 #include <algorithm>
-#include <tr1/unordered_map>
 
+#include "abg-cxx-compat.h"
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 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;
 
index 182279d..a46d25d 100644 (file)
 #include <elfutils/libdwfl.h>
 #include <dwarf.h>
 #include <algorithm>
-#include <tr1/unordered_map>
-#include <tr1/unordered_set>
 #include <stack>
 #include <deque>
 #include <list>
 #include <ostream>
 #include <sstream>
 
+#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.
   ///
index 6588c67..4dd9ae0 100644 (file)
@@ -20,6 +20,7 @@
 
 /// @file
 
+#include "abg-cxx-compat.h"
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 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> size_t_hash;
-  std::tr1::hash<string> str_hash;
+  abg_compat::hash<size_t> size_t_hash;
+  abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> hash_str;
+    abg_compat::hash<string> 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<int> hash_size_t;
+    abg_compat::hash<int> 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<string> hash_str;
+    abg_compat::hash<string> 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<string> str_hash;
+    abg_compat::hash<string> str_hash;
     decl_base::hash decl_hash;
     type_base::shared_ptr_hash type_ptr_hash;
-    std::tr1::hash<size_t> size_t_hash;
+    abg_compat::hash<size_t> 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<string> str_hash;
+    abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> hash_string;
   decl_base::hash hash_decl;
   type_base::shared_ptr_hash hash_type_ptr;
-  std::tr1::hash<size_t> hash_size_t;
+  abg_compat::hash<size_t> 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<int> hash_int;
-  std::tr1::hash<size_t> hash_size_t;
-  std::tr1::hash<bool> hash_bool;
-  std::tr1::hash<string> hash_string;
+  abg_compat::hash<int> hash_int;
+  abg_compat::hash<size_t> hash_size_t;
+  abg_compat::hash<bool> hash_bool;
+  abg_compat::hash<string> 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<bool> hash_bool;
-  std::tr1::hash<unsigned> hash_unsigned;
+  abg_compat::hash<bool> hash_bool;
+  abg_compat::hash<unsigned> 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<string> hash_string;
+    abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<int> hash_int;
+  abg_compat::hash<int> 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<size_t> hash_size;
-  std::tr1::hash<bool> hash_bool;
-  std::tr1::hash<string> hash_string;
+  abg_compat::hash<size_t> hash_size;
+  abg_compat::hash<bool> hash_bool;
+  abg_compat::hash<string> 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<bool> hash_bool;
+  abg_compat::hash<bool> hash_bool;
   function_tdecl::hash hash_function_tdecl;
   member_base::hash hash_member;
-  std::tr1::hash<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<unsigned> hash_unsigned;
-    std::tr1::hash<std::string> hash_string;
+    abg_compat::hash<unsigned> hash_unsigned;
+    abg_compat::hash<std::string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+    abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+    abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> 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<string> hash_string;
+  abg_compat::hash<string> hash_string;
   decl_base::hash hash_decl_base;
   template_decl::hash hash_template_decl;
   class_decl::hash hash_class_decl;
index 27fa770..94e4ac8 100644 (file)
@@ -31,9 +31,8 @@
 #include <iterator>
 #include <typeinfo>
 #include <sstream>
-#include <tr1/memory>
-#include <tr1/unordered_map>
 
+#include "abg-cxx-compat.h"
 #include "abg-internal.h"
 // <headers defining libabigail's API go under here>
 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<string, string*> 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<string> hash_string;
+         abg_compat::hash<string> 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<string> hash_string;
+         abg_compat::hash<string> 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<bool> hash_bool;
-         std::tr1::hash<unsigned> hash_unsigned;
+         abg_compat::hash<bool> hash_bool;
+         abg_compat::hash<unsigned> 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<size_t> hash_size;
-         std::tr1::hash<bool> hash_bool;
+         abg_compat::hash<size_t> hash_size;
+         abg_compat::hash<bool> 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));
index a7e0d55..1567518 100644 (file)
 #include <cstring>
 #include <cstdlib>
 #include <cerrno>
-#include <tr1/unordered_map>
 #include <deque>
 #include <assert.h>
 #include <sstream>
 #include <libxml/xmlstring.h>
 #include <libxml/xmlreader.h>
 
+#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<xmlNodePtr, elf_symbol_sptr>
+  typedef abg_compat::unordered_map<xmlNodePtr, elf_symbol_sptr>
     xml_node_ptr_elf_symbol_sptr_map_type;
   xml_node_ptr_elf_symbol_sptr_map_type xml_node_ptr_elf_symbol_map;
 
index 8544826..e410d36 100644 (file)
@@ -25,8 +25,9 @@
 /// This contains the implementation of the suppression engine of
 /// libabigail.
 
-#include "abg-internal.h"
 #include <algorithm>
+#include "abg-cxx-compat.h"
+#include "abg-internal.h"
 
 // <headers defining libabigail's API go under here>
 ABG_BEGIN_EXPORT_DECLARATIONS
@@ -47,7 +48,7 @@ namespace abigail
 namespace suppr
 {
 
-using std::tr1::dynamic_pointer_cast;
+using abg_compat::dynamic_pointer_cast;
 
 // <suppression_base stuff>
 
index 87a79c0..9300beb 100644 (file)
@@ -62,6 +62,7 @@
 
 #include "abg-dwarf-reader.h"
 #include "abg-internal.h"
+#include "abg-cxx-compat.h"
 // <headers defining libabigail's API go under here>
 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<char>
+abg_compat::shared_ptr<char>
 make_path_absolute(const char*p)
 {
-  using std::tr1::shared_ptr;
+  using abg_compat::shared_ptr;
 
   shared_ptr<char> result;
 
index b38bdec..0d3b853 100644 (file)
@@ -33,8 +33,8 @@
 #include <vector>
 #include <stack>
 #include <algorithm>
-#include <tr1/unordered_map>
 
+#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
index a0e0c77..04a1f67 100644 (file)
@@ -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;
index 59ef7d6..95338be 100644 (file)
@@ -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;
index b3be07f..f089f6c 100644 (file)
@@ -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;
index 3624b99..6fa43ba 100644 (file)
@@ -28,6 +28,7 @@
 #include <cstdlib>
 #include <cstring>
 #include <vector>
+#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;
index 28b19f9..b075efe 100644 (file)
@@ -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;
index aa83dc7..85fbeb1 100644 (file)
@@ -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;
index deee21e..fb5b44c 100644 (file)
@@ -48,7 +48,7 @@
 #include <string>
 #include <iostream>
 #include <fstream>
-#include <tr1/memory>
+#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;
 
index 1e29888..a8b7828 100644 (file)
@@ -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;
index e5ca872..111ceb2 100644 (file)
@@ -35,7 +35,7 @@
 #include <iostream>
 #include <fstream>
 #include <vector>
-#include <tr1/memory>
+#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;
index 0bdc496..4b5b1e1 100644 (file)
@@ -35,6 +35,7 @@
 #include <iostream>
 #include <fstream>
 #include <vector>
+#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<char>   di_root_path;
+  abg_compat::shared_ptr<char> di_root_path;
   vector<string>               suppression_paths;
   string                       headers_dir;
 
index bc3fce7..f3065fd 100644 (file)
@@ -95,8 +95,8 @@
 #include <vector>
 #include <algorithm>
 #include <map>
-#include <tr1/unordered_set>
 
+#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