1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
|
From 6e374de9ae2f2978f2fca3390aba4ea3f72bfade Mon Sep 17 00:00:00 2001
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Tue, 7 Nov 2017 10:37:53 +0200
Subject: Switch to C++11, get rid of auto_ptr use
---
odb/Makefile.am | 5 +++++
odb/context.cxx | 4 ++--
odb/context.hxx | 4 ++--
odb/generator.cxx | 18 +++++++++---------
odb/makefile | 8 +++++++-
odb/options.cli | 4 ++--
odb/parser.cxx | 14 ++++++++++----
odb/parser.hxx | 7 ++++---
odb/plugin.cxx | 10 +++++-----
odb/processor.cxx | 6 +++---
odb/validator.cxx | 2 +-
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 = 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 0ca39a8..7801072 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 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>
@@ -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 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>
@@ -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 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:
@@ -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);
@@ -2264,6 +2264,12 @@ fq_scope (tree decl)
//
parser::
+~parser ()
+{
+ // Needs parser::impl definition.
+}
+
+parser::
parser (options const& ops,
loc_pragmas& lp,
ns_loc_pragmas& nslp,
@@ -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 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;
@@ -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 1e6557f..7c396e7 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 6ba5efb..0c95d0f 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)
{
--
cgit v1.1
|