Remove <memory> usages from abg_compat

std::shared_ptr, std::weak_ptr, std::dynamic_pointer_cast,
std::static_pointer_cast are now provided through the language standard,
hence remove the compatibility code for <memory> and adjust all users
accordingly.

	* include/abg-cxx-compat.h: Drop compatibility layer for <memory>.
	* include/abg-diff-utils.h: migrate abg_compat use to std.
	* include/abg-fwd.h: Likewise.
	* include/abg-ini.h: Likewise.
	* include/abg-interned-str.h: Likewise.
	* include/abg-libxml-utils.h: Likewise.
	* include/abg-libzip-utils.h: Likewise.
	* include/abg-regex.h: Likewise.
	* include/abg-reporter.h: Likewise.
	* include/abg-sptr-utils.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-dwarf-reader.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-diff-suppr.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>
This commit is contained in:
Matthias Maennich 2020-12-14 23:08:53 +00:00 committed by Dodji Seketeli
parent ee3309472a
commit de344c0122
32 changed files with 133 additions and 110 deletions

View File

@ -8,18 +8,11 @@
#ifndef __ABG_CXX_COMPAT_H
#define __ABG_CXX_COMPAT_H
#include <memory>
#include <unordered_map>
#include <unordered_set>
namespace abg_compat {
// <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;

View File

@ -21,13 +21,14 @@
#ifndef __ABG_DIFF_UTILS_H__
#define __ABG_DIFF_UTILS_H__
#include <stdexcept>
#include <cassert>
#include <cstdlib>
#include <memory>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include <sstream>
#include "abg-cxx-compat.h"
#include "abg-fwd.h"
@ -42,7 +43,7 @@ namespace abigail
namespace diff_utils
{
using abg_compat::shared_ptr;
using std::shared_ptr;
// Inject the names from std:: below into this namespace
using std::string;

View File

@ -9,14 +9,15 @@
#define __ABG_IRFWD_H__
#include <stdint.h>
#include <cstdlib>
#include <cstddef>
#include <cstdlib>
#include <list>
#include <vector>
#include <memory>
#include <ostream>
#include <string>
#include <typeinfo>
#include <utility> // for std::rel_ops, at least.
#include <ostream>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-interned-str.h"
#include "abg-hash.h"
@ -48,8 +49,8 @@ namespace abigail
*/
// Inject some types.
using abg_compat::shared_ptr;
using abg_compat::weak_ptr;
using std::shared_ptr;
using std::weak_ptr;
using abg_compat::unordered_map;
using std::string;
using std::vector;

View File

@ -13,10 +13,11 @@
#ifndef __ABG_INI_H__
#define __ABG_INI_H__
#include <istream>
#include <memory>
#include <ostream>
#include <string>
#include <vector>
#include <istream>
#include <ostream>
#include "abg-cxx-compat.h"
namespace abigail
@ -25,8 +26,8 @@ namespace abigail
namespace ini
{
// Inject some standard types in this namespace.
using abg_compat::shared_ptr;
using abg_compat::dynamic_pointer_cast;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using std::string;
using std::vector;
using std:: pair;

View File

@ -17,6 +17,7 @@
#define __ABG_INTERNED_STR_H__
#include <functional>
#include <memory>
#include <ostream>
#include <string>
#include "abg-cxx-compat.h"
@ -26,7 +27,7 @@ namespace abigail
{
// Inject some std types into this namespace.
using abg_compat::unordered_set;
using abg_compat::shared_ptr;
using std::shared_ptr;
using std::string;
using std::ostream;

View File

@ -11,6 +11,7 @@
#include <libxml/xmlreader.h>
#include <istream>
#include <memory>
#include "abg-sptr-utils.h"
#include "abg-cxx-compat.h"
@ -23,7 +24,7 @@ namespace xml
{
using sptr_utils::build_sptr;
using abg_compat::shared_ptr;
using std::shared_ptr;
/// A convenience typedef for a shared pointer of xmlTextReader.
typedef shared_ptr<xmlTextReader> reader_sptr;

View File

@ -9,6 +9,7 @@
#define __ABG_LIBZIP_UTILS_H__
#include <zip.h>
#include <memory>
#include "abg-cxx-compat.h"
namespace abigail
@ -17,7 +18,7 @@ namespace abigail
namespace zip_utils
{
using abg_compat::shared_ptr;
using std::shared_ptr;
using std::string;
/// @brief Functor passed to shared_ptr constructor during

View File

@ -12,6 +12,7 @@
#include <regex.h>
#include <memory>
#include <string>
#include <vector>
@ -26,7 +27,7 @@ namespace regex
{
/// A convenience typedef for a shared pointer of regex_t.
typedef abg_compat::shared_ptr<regex_t> regex_t_sptr;
typedef std::shared_ptr<regex_t> regex_t_sptr;
/// A delete functor for a shared_ptr of regex_t.
struct regex_t_deleter

View File

@ -13,6 +13,7 @@
#ifndef __ABG_REPORTER_H__
#define __ABG_REPORTER_H__
#include <memory>
#include <ostream>
#include <string>
#include "abg-cxx-compat.h"
@ -20,7 +21,7 @@
namespace abigail
{
using abg_compat::shared_ptr;
using std::shared_ptr;
namespace comparison
{

View File

@ -11,6 +11,7 @@
#define __ABG_SPTR_UTILS_H__
#include <regex.h>
#include <memory>
#include "abg-cxx-compat.h"
@ -21,7 +22,7 @@ namespace abigail
namespace sptr_utils
{
using abg_compat::shared_ptr;
using std::shared_ptr;
/// This is to be specialized for the diverse C types that needs
/// wrapping in shared_ptr.

View File

@ -8,11 +8,12 @@
#ifndef __ABG_TOOLS_UTILS_H
#define __ABG_TOOLS_UTILS_H
#include <string>
#include <set>
#include <ostream>
#include <istream>
#include <iostream>
#include <istream>
#include <memory>
#include <ostream>
#include <set>
#include <string>
#include "abg-cxx-compat.h"
#include "abg-suppression.h"
@ -27,7 +28,7 @@ using std::istream;
using std::ifstream;
using std::string;
using std::set;
using abg_compat::shared_ptr;
using std::shared_ptr;
const char* get_system_libdir();
const char* get_anonymous_struct_internal_name_prefix();
@ -303,7 +304,7 @@ bool
file_is_kernel_debuginfo_package(const string& file_path,
file_type file_type);
abg_compat::shared_ptr<char>
std::shared_ptr<char>
make_path_absolute(const char*p);
char*

View File

@ -16,10 +16,11 @@
#ifndef __ABG_WORKERS_H__
#define __ABG_WORKERS_H__
#include <memory>
#include <vector>
#include "abg-cxx-compat.h"
using abg_compat::shared_ptr;
using std::shared_ptr;
namespace abigail
{

View File

@ -12,6 +12,7 @@
#include "abg-cxx-compat.h"
#include "abg-internal.h"
#include <memory>
// <headers defining libabigail's API go under here>
ABG_BEGIN_EXPORT_DECLARATIONS
@ -28,7 +29,7 @@ namespace comparison
namespace filtering
{
using abg_compat::dynamic_pointer_cast;
using std::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

View File

@ -19,6 +19,7 @@
#include "abg-cxx-compat.h"
#include "abg-internal.h"
// <headers defining libabigail's API go under here>
#include <memory>
ABG_BEGIN_EXPORT_DECLARATIONS
#include "abg-hash.h"
@ -42,8 +43,8 @@ using namespace abigail::suppr;
// Inject types from outside in here.
using std::vector;
using abg_compat::dynamic_pointer_cast;
using abg_compat::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;
using abigail::sptr_utils::noop_deleter;
/// Convenience typedef for a pair of decls or types.

View File

@ -19,16 +19,17 @@
#include <libgen.h>
#include <assert.h>
#include <limits.h>
#include <cstring>
#include <cmath>
#include <elfutils/libdwfl.h>
#include <dwarf.h>
#include <algorithm>
#include <stack>
#include <cmath>
#include <cstring>
#include <deque>
#include <list>
#include <memory>
#include <ostream>
#include <sstream>
#include <stack>
#include "abg-cxx-compat.h"
#include "abg-ir-priv.h"
@ -62,8 +63,8 @@ using std::cerr;
namespace dwarf_reader
{
using abg_compat::dynamic_pointer_cast;
using abg_compat::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;
using abg_compat::unordered_map;
using abg_compat::unordered_set;
using std::stack;

View File

@ -13,6 +13,7 @@
#include <algorithm>
#include <functional>
#include <iterator>
#include <memory>
#include <sstream>
#include <typeinfo>
#include <utility>
@ -117,8 +118,8 @@ using std::string;
using std::list;
using std::vector;
using abg_compat::unordered_map;
using abg_compat::dynamic_pointer_cast;
using abg_compat::static_pointer_cast;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;
/// Convenience typedef for a map of string -> string*.
typedef unordered_map<string, string*> pool_map_type;

View File

@ -11,14 +11,15 @@
/// native XML format is named "abixml".
#include "config.h"
#include <cstring>
#include <cstdlib>
#include <cerrno>
#include <deque>
#include <assert.h>
#include <sstream>
#include <libxml/xmlstring.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlstring.h>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <memory>
#include <sstream>
#include "abg-cxx-compat.h"
#include "abg-suppression-priv.h"
@ -50,9 +51,9 @@ namespace xml_reader
{
using std::string;
using std::deque;
using abg_compat::shared_ptr;
using std::shared_ptr;
using abg_compat::unordered_map;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using std::vector;
using std::istream;
#ifdef WITH_ZIP_ARCHIVE

View File

@ -14,6 +14,7 @@
#include "abg-cxx-compat.h"
#include "abg-internal.h"
#include <memory>
// <headers defining libabigail's API go under here>
ABG_BEGIN_EXPORT_DECLARATIONS
@ -34,7 +35,7 @@ namespace abigail
namespace suppr
{
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using regex::regex_t_sptr;
// <parsing stuff>

View File

@ -30,19 +30,19 @@
#include <sys/time.h>
#include <dirent.h>
#include <time.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iterator>
#include <ctype.h>
#include <errno.h>
#include <libgen.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <memory>
#include <sstream>
#include "abg-dwarf-reader.h"
#include "abg-internal.h"
#include "abg-cxx-compat.h"
@ -1709,10 +1709,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.
abg_compat::shared_ptr<char>
std::shared_ptr<char>
make_path_absolute(const char*p)
{
using abg_compat::shared_ptr;
using std::shared_ptr;
shared_ptr<char> result;

View File

@ -12,13 +12,14 @@
#include "config.h"
#include <assert.h>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <memory>
#include <sstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-tools-utils.h"
@ -46,9 +47,9 @@ ABG_END_EXPORT_DECLARATIONS
namespace abigail
{
using std::cerr;
using abg_compat::shared_ptr;
using abg_compat::dynamic_pointer_cast;
using abg_compat::static_pointer_cast;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using std::static_pointer_cast;
using std::ofstream;
using std::ostream;
using std::ostringstream;

View File

@ -18,10 +18,11 @@
#include <sys/wait.h>
#include <cassert>
#include <string>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <memory>
#include <string>
#include "abg-workers.h"
#include "abg-tools-utils.h"
#include "test-utils.h"
@ -869,7 +870,7 @@ int
main()
{
using std::vector;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using abigail::workers::queue;
using abigail::workers::task;
using abigail::workers::task_sptr;

View File

@ -20,10 +20,11 @@
#include "config.h"
#include <sys/wait.h>
#include <cassert>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "abg-workers.h"
#include "test-utils.h"
@ -813,7 +814,7 @@ int
main()
{
using std::vector;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using abigail::workers::queue;
using abigail::workers::task;
using abigail::workers::task_sptr;

View File

@ -16,11 +16,12 @@
/// one.
#include <sys/wait.h>
#include <cstdlib>
#include <cstring>
#include <string>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <memory>
#include <string>
#include "abg-cxx-compat.h"
#include "abg-tools-utils.h"
#include "abg-workers.h"
@ -2169,7 +2170,7 @@ main(int argc, char *argv[])
for (InOutSpec* s = in_out_specs; s->in_elfv0_path; ++s)
{
abg_compat::shared_ptr<test_task> t(
std::shared_ptr<test_task> t(
new test_task(*s, in_base_path, out_base_path));
ABG_ASSERT(task_queue.schedule_task(t));
}
@ -2189,8 +2190,8 @@ main(int argc, char *argv[])
ti != completed_tasks.end();
++ti)
{
abg_compat::shared_ptr<test_task> t =
abg_compat::dynamic_pointer_cast<test_task>(*ti);
std::shared_ptr<test_task> t =
std::dynamic_pointer_cast<test_task>(*ti);
if (!t->is_ok)
{
is_ok = false;

View File

@ -9,11 +9,12 @@
/// files and diff the corpus files against reference XML corpus
/// files.
#include <string>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <cstdlib>
#include "abg-ir.h"
#include "abg-dwarf-reader.h"
#include "abg-workers.h"
@ -25,7 +26,7 @@ using std::vector;
using std::string;
using std::ofstream;
using std::cerr;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using abigail::tests::get_build_dir;
using abigail::dwarf_reader::read_corpus_from_elf;
using abigail::dwarf_reader::read_context;

View File

@ -7,11 +7,12 @@
/// save it back and diff the resulting XML file against the input
/// file. They should be identical.
#include <string>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-ir.h"
@ -26,7 +27,7 @@ using std::vector;
using std::ofstream;
using std::cerr;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using abigail::tools_utils::file_type;
using abigail::tools_utils::check_file;

View File

@ -21,10 +21,11 @@
///
/// The comparison is expected to yield the empty set.
#include <string>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <memory>
#include <string>
#include "abg-tools-utils.h"
#include "test-utils.h"
#include "abg-dwarf-reader.h"
@ -103,7 +104,7 @@ int
main()
{
using std::vector;
using abg_compat::dynamic_pointer_cast;
using std::dynamic_pointer_cast;
using abigail::workers::queue;
using abigail::workers::task;
using abigail::workers::task_sptr;

View File

@ -4,8 +4,9 @@
// Copyright (C) 2013-2020 Red Hat, Inc.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iostream>
#include <memory>
#include "test-utils.h"
#include "abg-ir.h"
#include "abg-corpus.h"
@ -63,7 +64,7 @@ const InOutSpec archive_spec =
using std::string;
using std::cerr;
using std::ofstream;
using abg_compat::shared_ptr;
using std::shared_ptr;
using abigail::corpus;
using abigail::corpus_sptr;
using abigail::translation_unit;

View File

@ -27,12 +27,13 @@
#include <unistd.h>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include "abg-cxx-compat.h"
#include "abg-config.h"
#include "abg-tools-utils.h"
@ -47,7 +48,7 @@ using std::cout;
using std::ostream;
using std::ofstream;
using std::vector;
using abg_compat::shared_ptr;
using std::shared_ptr;
using abigail::tools_utils::emit_prefix;

View File

@ -8,9 +8,10 @@
/// @file
#include <cstring>
#include <vector>
#include <string>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "abg-config.h"
#include "abg-comp-filter.h"
#include "abg-suppression.h"
@ -23,7 +24,7 @@ using std::string;
using std::ostream;
using std::cout;
using std::cerr;
using abg_compat::shared_ptr;
using std::shared_ptr;
using abigail::ir::environment;
using abigail::ir::environment_sptr;
using abigail::translation_unit;

View File

@ -13,12 +13,13 @@
#include <unistd.h>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-config.h"
@ -35,7 +36,7 @@ using std::cout;
using std::ostream;
using std::ofstream;
using std::vector;
using abg_compat::shared_ptr;
using std::shared_ptr;
using abigail::tools_utils::emit_prefix;
using abigail::tools_utils::temp_file;
using abigail::tools_utils::temp_file_sptr;

View File

@ -13,12 +13,13 @@
/// runs a diff on the two files and expects the result of the diff to
/// be empty.
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <cstring>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-config.h"
@ -68,7 +69,7 @@ struct options
bool read_tu;
bool diff;
bool noout;
abg_compat::shared_ptr<char> di_root_path;
std::shared_ptr<char> di_root_path;
vector<string> suppression_paths;
string headers_dir;
vector<string> header_files;

View File

@ -71,14 +71,15 @@
#include <fts.h>
#endif
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "abg-cxx-compat.h"
#include "abg-workers.h"
@ -100,8 +101,8 @@ using std::map;
using abg_compat::unordered_set;
using std::set;
using std::ostringstream;
using abg_compat::shared_ptr;
using abg_compat::dynamic_pointer_cast;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using abigail::workers::task;
using abigail::workers::task_sptr;
using abigail::workers::queue;