352 lines
12 KiB
Diff
352 lines
12 KiB
Diff
From c5bea9562929c6b55ca208a530ae80033eeb1614 Mon Sep 17 00:00:00 2001
|
|
From: Boris Kolpackov <boris@codesynthesis.com>
|
|
Date: Tue, 7 Nov 2017 10:37:53 +0200
|
|
Subject: [PATCH] Switch to C++11, get rid of auto_ptr use
|
|
|
|
[Upstream: 6e374de9ae2f2978f2fca3390aba4ea3f72bfade]
|
|
Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com>
|
|
---
|
|
odb/Makefile.am | 5 +++++
|
|
odb/context.cxx | 4 ++--
|
|
odb/context.hxx | 4 ++--
|
|
odb/generator.cxx | 18 +++++++++---------
|
|
odb/options.cli | 4 ++--
|
|
odb/parser.cxx | 14 ++++++++++----
|
|
odb/parser.hxx | 7 ++++---
|
|
odb/plugin.cxx | 10 +++++-----
|
|
odb/processor.cxx | 6 +++---
|
|
odb/validator.cxx | 2 +-
|
|
10 files changed, 43 insertions(+), 31 deletions(-)
|
|
|
|
diff --git a/odb/Makefile.am b/odb/Makefile.am
|
|
index 2f01398..d9e83d7 100644
|
|
--- a/odb/Makefile.am
|
|
+++ b/odb/Makefile.am
|
|
@@ -9,6 +9,11 @@ plugin_LTLIBRARIES = odb.la
|
|
|
|
AM_CPPFLAGS = -I'$(top_builddir)' -I'$(top_srcdir)'
|
|
|
|
+# Note: not passed by libtool when linking odb.so. Seems to be harmless for
|
|
+# now.
|
|
+#
|
|
+AM_CXXFLAGS = -std=c++0x
|
|
+
|
|
EXTRA_DIST = common-query.hxx common.hxx context.hxx context.ixx cxx-lexer.hxx cxx-token.hxx diagnostics.hxx emitter.hxx features.hxx gcc-fwd.hxx gcc.hxx generate.hxx generator.hxx instance.hxx location.hxx lookup.hxx option-functions.hxx option-parsers.hxx option-types.hxx options.hxx options.ixx parser.hxx pragma.hxx processor.hxx profile.hxx relational/common-query.hxx relational/common.hxx relational/common.txx relational/context.hxx relational/context.ixx relational/generate.hxx relational/header.hxx relational/inline.hxx relational/model.hxx relational/mssql/common.hxx relational/mssql/context.hxx relational/mysql/common.hxx relational/mysql/context.hxx relational/oracle/common.hxx relational/oracle/context.hxx relational/pgsql/common.hxx relational/pgsql/context.hxx relational/processor.hxx relational/schema-source.hxx relational/schema.hxx relational/source.hxx relational/sqlite/common.hxx relational/sqlite/context.hxx relational/validator.hxx semantics.hxx semantics/class-template.hxx semantics/class.hxx semantics/derived.hxx semantics/elements.hxx semantics/elements.ixx semantics/enum.hxx semantics/fundamental.hxx semantics/namespace.hxx semantics/relational.hxx semantics/relational/changelog.hxx semantics/relational/changeset.hxx semantics/relational/column.hxx semantics/relational/deferrable.hxx semantics/relational/elements.hxx semantics/relational/elements.txx semantics/relational/foreign-key.hxx semantics/relational/index.hxx semantics/relational/key.hxx semantics/relational/model.hxx semantics/relational/name.hxx semantics/relational/primary-key.hxx semantics/relational/table.hxx semantics/template.hxx semantics/union-template.hxx semantics/union.hxx semantics/unit.hxx sql-lexer.hxx sql-lexer.ixx sql-token.hxx sql-token.ixx traversal.hxx traversal/class-template.hxx traversal/class.hxx traversal/derived.hxx traversal/elements.hxx traversal/enum.hxx traversal/fundamental.hxx traversal/namespace.hxx traversal/relational.hxx traversal/relational/changelog.hxx traversal/relational/changeset.hxx traversal/relational/column.hxx traversal/relational/elements.hxx traversal/relational/foreign-key.hxx traversal/relational/index.hxx traversal/relational/key.hxx traversal/relational/model.hxx traversal/relational/primary-key.hxx traversal/relational/table.hxx traversal/template.hxx traversal/union-template.hxx traversal/union.hxx traversal/unit.hxx validator.hxx version.hxx options.cli
|
|
|
|
# Plugin.
|
|
diff --git a/odb/context.cxx b/odb/context.cxx
|
|
index d62fa88..87f1c32 100644
|
|
--- a/odb/context.cxx
|
|
+++ b/odb/context.cxx
|
|
@@ -564,14 +564,14 @@ namespace
|
|
};
|
|
}
|
|
|
|
-auto_ptr<context>
|
|
+unique_ptr<context>
|
|
create_context (ostream& os,
|
|
semantics::unit& unit,
|
|
options const& ops,
|
|
features& f,
|
|
semantics::relational::model* m)
|
|
{
|
|
- auto_ptr<context> r;
|
|
+ unique_ptr<context> r;
|
|
|
|
switch (ops.database ()[0])
|
|
{
|
|
diff --git a/odb/context.hxx b/odb/context.hxx
|
|
index 351bc61..10de237 100644
|
|
--- a/odb/context.hxx
|
|
+++ b/odb/context.hxx
|
|
@@ -13,7 +13,7 @@
|
|
#include <stack>
|
|
#include <vector>
|
|
#include <string>
|
|
-#include <memory> // std::auto_ptr
|
|
+#include <memory> // std::unique_ptr
|
|
#include <ostream>
|
|
#include <cstddef> // std::size_t
|
|
#include <iostream>
|
|
@@ -1691,7 +1691,7 @@ private:
|
|
|
|
// Create concrete database context.
|
|
//
|
|
-std::auto_ptr<context>
|
|
+std::unique_ptr<context>
|
|
create_context (std::ostream&,
|
|
semantics::unit&,
|
|
options const&,
|
|
diff --git a/odb/generator.cxx b/odb/generator.cxx
|
|
index 6aa5151..266b75f 100644
|
|
--- a/odb/generator.cxx
|
|
+++ b/odb/generator.cxx
|
|
@@ -4,7 +4,7 @@
|
|
|
|
#include <cctype> // std::toupper, std::is{alpha,upper,lower}
|
|
#include <string>
|
|
-#include <memory> // std::auto_ptr
|
|
+#include <memory> // std::unique_ptr
|
|
#include <iomanip>
|
|
#include <fstream>
|
|
#include <sstream>
|
|
@@ -141,7 +141,7 @@ generate (options const& ops,
|
|
|
|
if (gen_schema)
|
|
{
|
|
- auto_ptr<context> ctx (create_context (cerr, unit, ops, fts, 0));
|
|
+ unique_ptr<context> ctx (create_context (cerr, unit, ops, fts, 0));
|
|
|
|
switch (db)
|
|
{
|
|
@@ -471,7 +471,7 @@ generate (options const& ops,
|
|
//
|
|
if (gen_cxx)
|
|
{
|
|
- auto_ptr<context> ctx (
|
|
+ unique_ptr<context> ctx (
|
|
create_context (hxx, unit, ops, fts, model.get ()));
|
|
|
|
sloc_filter sloc (ctx->os);
|
|
@@ -581,7 +581,7 @@ generate (options const& ops,
|
|
//
|
|
if (gen_cxx)
|
|
{
|
|
- auto_ptr<context> ctx (
|
|
+ unique_ptr<context> ctx (
|
|
create_context (ixx, unit, ops, fts, model.get ()));
|
|
|
|
sloc_filter sloc (ctx->os);
|
|
@@ -641,7 +641,7 @@ generate (options const& ops,
|
|
//
|
|
if (gen_cxx && (db != database::common || md == multi_database::dynamic))
|
|
{
|
|
- auto_ptr<context> ctx (
|
|
+ unique_ptr<context> ctx (
|
|
create_context (cxx, unit, ops, fts, model.get ()));
|
|
|
|
sloc_filter sloc (ctx->os);
|
|
@@ -734,7 +734,7 @@ generate (options const& ops,
|
|
//
|
|
if (gen_sep_schema)
|
|
{
|
|
- auto_ptr<context> ctx (
|
|
+ unique_ptr<context> ctx (
|
|
create_context (sch, unit, ops, fts, model.get ()));
|
|
|
|
sloc_filter sloc (ctx->os);
|
|
@@ -799,7 +799,7 @@ generate (options const& ops,
|
|
//
|
|
if (gen_sql_schema)
|
|
{
|
|
- auto_ptr<context> ctx (
|
|
+ unique_ptr<context> ctx (
|
|
create_context (sql, unit, ops, fts, model.get ()));
|
|
|
|
switch (db)
|
|
@@ -865,7 +865,7 @@ generate (options const& ops,
|
|
//
|
|
{
|
|
ofstream& mig (*mig_pre[i]);
|
|
- auto_ptr<context> ctx (create_context (mig, unit, ops, fts, 0));
|
|
+ unique_ptr<context> ctx (create_context (mig, unit, ops, fts, 0));
|
|
|
|
switch (db)
|
|
{
|
|
@@ -908,7 +908,7 @@ generate (options const& ops,
|
|
//
|
|
{
|
|
ofstream& mig (*mig_post[i]);
|
|
- auto_ptr<context> ctx (create_context (mig, unit, ops, fts, 0));
|
|
+ unique_ptr<context> ctx (create_context (mig, unit, ops, fts, 0));
|
|
|
|
switch (db)
|
|
{
|
|
diff --git a/odb/options.cli b/odb/options.cli
|
|
index cf278cb..c994975 100644
|
|
--- a/odb/options.cli
|
|
+++ b/odb/options.cli
|
|
@@ -211,10 +211,10 @@ class options
|
|
\cb{db pointer} pragma will use this pointer by default. The value
|
|
of this option can be \cb{*} which denotes the raw pointer and is
|
|
the default, or qualified name of a smart pointer class template,
|
|
- for example, \cb{std::auto_ptr}. In the latter case, the ODB compiler
|
|
+ for example, \cb{std::shared_ptr}. In the latter case, the ODB compiler
|
|
constructs the object or view pointer by adding a single template
|
|
argument of the object or view type to the qualified name, for example
|
|
- \cb{std::auto_ptr<object>}. The ODB runtime uses object and view
|
|
+ \cb{std::shared_ptr<object>}. The ODB runtime uses object and view
|
|
pointers to return, and, in case of objects, pass and cache
|
|
dynamically allocated instances of object and view types.
|
|
|
|
diff --git a/odb/parser.cxx b/odb/parser.cxx
|
|
index 927063b..30e45af 100644
|
|
--- a/odb/parser.cxx
|
|
+++ b/odb/parser.cxx
|
|
@@ -26,7 +26,7 @@ public:
|
|
|
|
impl (options const&, loc_pragmas&, ns_loc_pragmas&, decl_pragmas&);
|
|
|
|
- auto_ptr<unit>
|
|
+ unique_ptr<unit>
|
|
parse (tree global_scope, path const& main_file);
|
|
|
|
private:
|
|
@@ -728,10 +728,10 @@ impl (options const& ops,
|
|
{
|
|
}
|
|
|
|
-auto_ptr<unit> parser::impl::
|
|
+unique_ptr<unit> parser::impl::
|
|
parse (tree global_scope, path const& main_file)
|
|
{
|
|
- auto_ptr<unit> u (new unit (main_file));
|
|
+ unique_ptr<unit> u (new unit (main_file));
|
|
u->insert (global_namespace, *u);
|
|
process_named_pragmas (global_namespace, *u);
|
|
|
|
@@ -2263,6 +2263,12 @@ fq_scope (tree decl)
|
|
// parser
|
|
//
|
|
|
|
+parser::
|
|
+~parser ()
|
|
+{
|
|
+ // Needs parser::impl definition.
|
|
+}
|
|
+
|
|
parser::
|
|
parser (options const& ops,
|
|
loc_pragmas& lp,
|
|
@@ -2272,7 +2278,7 @@ parser (options const& ops,
|
|
{
|
|
}
|
|
|
|
-auto_ptr<unit> parser::
|
|
+unique_ptr<unit> parser::
|
|
parse (tree global_scope, path const& main_file)
|
|
{
|
|
return impl_->parse (global_scope, main_file);
|
|
diff --git a/odb/parser.hxx b/odb/parser.hxx
|
|
index 80e4aa4..648337f 100644
|
|
--- a/odb/parser.hxx
|
|
+++ b/odb/parser.hxx
|
|
@@ -7,7 +7,7 @@
|
|
|
|
#include <odb/gcc.hxx>
|
|
|
|
-#include <memory> // std::auto_ptr
|
|
+#include <memory> // std::unique_ptr
|
|
|
|
#include <odb/pragma.hxx>
|
|
#include <odb/options.hxx>
|
|
@@ -18,9 +18,10 @@ class parser
|
|
public:
|
|
class failed {};
|
|
|
|
+ ~parser ();
|
|
parser (options const&, loc_pragmas&, ns_loc_pragmas&, decl_pragmas&);
|
|
|
|
- std::auto_ptr<semantics::unit>
|
|
+ std::unique_ptr<semantics::unit>
|
|
parse (tree global_scope, semantics::path const& main_file);
|
|
|
|
private:
|
|
@@ -31,7 +32,7 @@ private:
|
|
|
|
private:
|
|
class impl;
|
|
- std::auto_ptr<impl> impl_;
|
|
+ std::unique_ptr<impl> impl_;
|
|
};
|
|
|
|
#endif // ODB_PARSER_HXX
|
|
diff --git a/odb/plugin.cxx b/odb/plugin.cxx
|
|
index 779faed..0fac632 100644
|
|
--- a/odb/plugin.cxx
|
|
+++ b/odb/plugin.cxx
|
|
@@ -8,7 +8,7 @@
|
|
#include <sys/types.h> // stat
|
|
#include <sys/stat.h> // stat
|
|
|
|
-#include <memory> // std::auto_ptr
|
|
+#include <memory> // std::unique_ptr
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstring> // std::strcpy, std::strstr
|
|
@@ -39,7 +39,7 @@ using cutl::fs::invalid_path;
|
|
typedef vector<path> paths;
|
|
|
|
int plugin_is_GPL_compatible;
|
|
-auto_ptr<options const> options_;
|
|
+unique_ptr<options const> options_;
|
|
paths profile_paths_;
|
|
path file_; // File being compiled.
|
|
paths inputs_; // List of input files in at-once mode or just file_.
|
|
@@ -222,7 +222,7 @@ gate_callback (void*, void*)
|
|
// Parse the GCC tree to semantic graph.
|
|
//
|
|
parser p (*options_, loc_pragmas_, ns_loc_pragmas_, decl_pragmas_);
|
|
- auto_ptr<unit> u (p.parse (global_namespace, file_));
|
|
+ unique_ptr<unit> u (p.parse (global_namespace, file_));
|
|
|
|
features f;
|
|
|
|
@@ -377,14 +377,14 @@ plugin_init (plugin_name_args* plugin_info, plugin_gcc_version*)
|
|
oi[2].arg = &pd;
|
|
|
|
cli::argv_file_scanner scan (argc, &argv[0], oi, 3);
|
|
- auto_ptr<options> ops (
|
|
+ unique_ptr<options> ops (
|
|
new options (scan, cli::unknown_mode::fail, cli::unknown_mode::fail));
|
|
|
|
// Process options.
|
|
//
|
|
process_options (*ops);
|
|
|
|
- options_ = ops;
|
|
+ options_ = move (ops);
|
|
pragma_db_ = db;
|
|
pragma_multi_ = options_->multi_database ();
|
|
}
|
|
diff --git a/odb/processor.cxx b/odb/processor.cxx
|
|
index bea3624..c787e0d 100644
|
|
--- a/odb/processor.cxx
|
|
+++ b/odb/processor.cxx
|
|
@@ -120,8 +120,8 @@ namespace
|
|
// both the wrapper type and the wrapped type must be const.
|
|
// To see why, consider these possibilities:
|
|
//
|
|
- // auto_ptr<const T> - can modify by setting a new pointer
|
|
- // const auto_ptr<T> - can modify by changing the pointed-to value
|
|
+ // unique_ptr<const T> - can modify by setting a new pointer
|
|
+ // const unique_ptr<T> - can modify by changing the pointed-to value
|
|
//
|
|
if (const_type (m.type ()) &&
|
|
!(id (m) || version (m) || m.count ("inverse")))
|
|
@@ -3086,7 +3086,7 @@ process (options const& ops,
|
|
{
|
|
try
|
|
{
|
|
- auto_ptr<context> ctx (create_context (cerr, unit, ops, f, 0));
|
|
+ unique_ptr<context> ctx (create_context (cerr, unit, ops, f, 0));
|
|
|
|
// Common processing.
|
|
//
|
|
diff --git a/odb/validator.cxx b/odb/validator.cxx
|
|
index aac52e4..196386c 100644
|
|
--- a/odb/validator.cxx
|
|
+++ b/odb/validator.cxx
|
|
@@ -1516,7 +1516,7 @@ validate (options const& ops,
|
|
if (!valid)
|
|
throw validator_failed ();
|
|
|
|
- auto_ptr<context> ctx (create_context (cerr, u, ops, f, 0));
|
|
+ unique_ptr<context> ctx (create_context (cerr, u, ops, f, 0));
|
|
|
|
if (pass == 1)
|
|
{
|
|
--
|
|
2.25.0
|
|
|