struct libcc1 : public gcc_c_context
{
libcc1 (const gcc_base_vtable *, const gcc_c_fe_vtable *);
- ~libcc1 ();
// A convenience function to print something.
void print (const char *str)
this->print_function (this->print_datum, str);
}
- libcc1_connection *connection;
+ std::unique_ptr<libcc1_connection> connection;
gcc_c_oracle_function *binding_oracle;
gcc_c_symbol_address_function *address_oracle;
virtual ~compiler ()
{
}
- } *compilerp;
+ };
+
+ std::unique_ptr<compiler> compilerp;
/* Compiler to set by set_triplet_regexp. */
class compiler_triplet_regexp : public compiler
libcc1::libcc1 (const gcc_base_vtable *v,
const gcc_c_fe_vtable *cv)
- : connection (NULL),
- binding_oracle (NULL),
+ : binding_oracle (NULL),
address_oracle (NULL),
oracle_datum (NULL),
print_function (NULL),
c_ops = cv;
}
-libcc1::~libcc1 ()
-{
- delete connection;
- delete compilerp;
-}
-
\f
// Enclose these functions in an anonymous namespace because they
libcc1 *self = (libcc1 *) s;
R result;
- if (!cc1_plugin::call (self->connection, NAME, &result, rest...))
+ if (!cc1_plugin::call (self->connection.get (), NAME, &result, rest...))
return 0;
return result;
}
{
libcc1 *self = (libcc1 *) s;
- delete self->compilerp;
- self->compilerp = new libcc1::compiler_triplet_regexp (self, triplet_regexp);
+ self->compilerp.reset (new libcc1::compiler_triplet_regexp (self,
+ triplet_regexp));
return NULL;
}
{
libcc1 *self = (libcc1 *) s;
- delete self->compilerp;
- self->compilerp = new libcc1::compiler_driver_filename (self,
- driver_filename);
+ self->compilerp.reset (new libcc1::compiler_driver_filename (self,
+ driver_filename));
return NULL;
}
cc1_plugin::status result = cc1_plugin::FAIL;
if (self->connection->send ('H')
- && ::cc1_plugin::marshall (self->connection, GCC_C_FE_VERSION_1))
+ && ::cc1_plugin::marshall (self->connection.get (),
+ GCC_C_FE_VERSION_1))
result = self->connection->wait_for_query ();
close (spair_fds[0]);
if (self->verbose)
self->args.push_back ("-v");
- self->connection = new libcc1_connection (fds[0], stderr_fds[0], self);
+ self->connection.reset (new libcc1_connection (fds[0], stderr_fds[0], self));
cc1_plugin::callback_ftype *fun
= cc1_plugin::callback<int,
struct libcp1 : public gcc_cp_context
{
libcp1 (const gcc_base_vtable *, const gcc_cp_fe_vtable *);
- ~libcp1 ();
// A convenience function to print something.
void print (const char *str)
this->print_function (this->print_datum, str);
}
- libcp1_connection *connection;
+ std::unique_ptr<libcp1_connection> connection;
gcc_cp_oracle_function *binding_oracle;
gcc_cp_symbol_address_function *address_oracle;
virtual ~compiler ()
{
}
- } *compilerp;
+ };
+
+ std::unique_ptr<compiler> compilerp;
/* Compiler to set by set_triplet_regexp. */
class compiler_triplet_regexp : public compiler
libcp1::libcp1 (const gcc_base_vtable *v,
const gcc_cp_fe_vtable *cv)
- : connection (NULL),
- binding_oracle (NULL),
+ : binding_oracle (NULL),
address_oracle (NULL),
oracle_datum (NULL),
print_function (NULL),
cp_ops = cv;
}
-libcp1::~libcp1 ()
-{
- delete connection;
- delete compilerp;
-}
-
\f
// Enclose these functions in an anonymous namespace because they
libcp1 *self = (libcp1 *) s;
R result;
- if (!cc1_plugin::call (self->connection, NAME, &result, rest...))
+ if (!cc1_plugin::call (self->connection.get (), NAME, &result, rest...))
return 0;
return result;
}
{
libcp1 *self = (libcp1 *) s;
- delete self->compilerp;
- self->compilerp = new libcp1::compiler_triplet_regexp (self, triplet_regexp);
+ self->compilerp.reset (new libcp1::compiler_triplet_regexp (self,
+ triplet_regexp));
return NULL;
}
{
libcp1 *self = (libcp1 *) s;
- delete self->compilerp;
- self->compilerp = new libcp1::compiler_driver_filename (self,
- driver_filename);
+ self->compilerp.reset (new libcp1::compiler_driver_filename (self,
+ driver_filename));
return NULL;
}
cc1_plugin::status result = cc1_plugin::FAIL;
if (self->connection->send ('H')
- && ::cc1_plugin::marshall (self->connection, GCC_CP_FE_VERSION_0))
+ && ::cc1_plugin::marshall (self->connection.get (),
+ GCC_CP_FE_VERSION_0))
result = self->connection->wait_for_query ();
close (spair_fds[0]);
if (self->verbose)
self->args.push_back ("-v");
- self->connection = new libcp1_connection (fds[0], stderr_fds[0], self);
+ self->connection.reset (new libcp1_connection (fds[0], stderr_fds[0], self));
cc1_plugin::callback_ftype *fun
= cc1_plugin::callback<int,