aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-11-07 10:37:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-11-07 10:37:53 +0200
commit6e374de9ae2f2978f2fca3390aba4ea3f72bfade (patch)
treea603c240f79494e0139445c20f63f32db04d5277
parentfde4431ec608b467de6ab205e3f73848fe9efbdf (diff)
Switch to C++11, get rid of auto_ptr use
-rw-r--r--odb/Makefile.am5
-rw-r--r--odb/context.cxx4
-rw-r--r--odb/context.hxx4
-rw-r--r--odb/generator.cxx18
-rw-r--r--odb/makefile8
-rw-r--r--odb/options.cli4
-rw-r--r--odb/parser.cxx14
-rw-r--r--odb/parser.hxx7
-rw-r--r--odb/plugin.cxx10
-rw-r--r--odb/processor.cxx6
-rw-r--r--odb/validator.cxx2
11 files changed, 50 insertions, 32 deletions
diff --git a/odb/Makefile.am b/odb/Makefile.am
index a8d3ba3..c0d4ce1 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 = __path__(headers) __path__(extra_dist)
# Plugin.
diff --git a/odb/context.cxx b/odb/context.cxx
index 0ca39a8..7801072 100644
--- a/odb/context.cxx
+++ b/odb/context.cxx
@@ -796,14 +796,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 7c983fc..103646d 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>
@@ -1899,7 +1899,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 74de7d1..bb8e12f 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>
@@ -166,7 +166,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)
{
@@ -496,7 +496,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);
@@ -606,7 +606,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);
@@ -666,7 +666,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);
@@ -759,7 +759,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);
@@ -824,7 +824,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)
@@ -890,7 +890,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)
{
@@ -933,7 +933,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/makefile b/odb/makefile
index 5a67fec..cd952f6 100644
--- a/odb/makefile
+++ b/odb/makefile
@@ -294,7 +294,13 @@ $(call include,$(bld_root)/cxx/o-e.make)
#
ifdef cxx_gnu
-$(cxx_pobj) $(cxx_cobj): cxx_pic_options := -fPIC
+$(odb) $(odb_so) \
+$(cxx_pobj) $(cxx_pod) \
+$(cxx_cobj) $(cxx_cod) \
+$(cxx_dobj) $(cxx_dod): cxx_extra_options += -std=c++0x
+
+$(cxx_pobj) $(cxx_pod) \
+$(cxx_cobj) $(cxx_cod): cxx_pic_options := -fPIC
$(cxx_cobj) $(cxx_cod): cpp_options := -I$(src_root)
$(cxx_dobj) $(cxx_dod): cpp_options := -I$(src_root) '-DODB_GXX_NAME="$(cxx_gnu)"'
diff --git a/odb/options.cli b/odb/options.cli
index e9ed272..1209177 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 00483cd..79a5bc2 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:
@@ -750,10 +750,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);
@@ -2265,6 +2265,12 @@ fq_scope (tree decl)
//
parser::
+~parser ()
+{
+ // Needs parser::impl definition.
+}
+
+parser::
parser (options const& ops,
loc_pragmas& lp,
ns_loc_pragmas& nslp,
@@ -2273,7 +2279,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 97b138c..d8fd60f 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 6c78d11..c046c2f 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;
@@ -381,14 +381,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 1e6557f..7c396e7 100644
--- a/odb/processor.cxx
+++ b/odb/processor.cxx
@@ -140,8 +140,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_member (m) && !(id (m) || version (m) || m.count ("inverse")))
{
@@ -3148,7 +3148,7 @@ process1 (semantics::unit& u)
static void
process2 (options const& ops, features& f, semantics::unit& u)
{
- auto_ptr<context> ctx (create_context (cerr, u, ops, f, 0));
+ unique_ptr<context> ctx (create_context (cerr, u, ops, f, 0));
// Common processing.
//
diff --git a/odb/validator.cxx b/odb/validator.cxx
index 6ba5efb..0c95d0f 100644
--- a/odb/validator.cxx
+++ b/odb/validator.cxx
@@ -1816,7 +1816,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)
{