mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restrict usage of plain "new".
This commit is contained in:
parent
87943bf444
commit
0bb88dabb7
@ -40,7 +40,7 @@ GasMeter::GasConsumption PathGasMeter::estimateMax(
|
||||
shared_ptr<KnownState> const& _state
|
||||
)
|
||||
{
|
||||
auto path = unique_ptr<GasPath>(new GasPath());
|
||||
auto path = make_unique<GasPath>();
|
||||
path->index = _startIndex;
|
||||
path->state = _state->copy();
|
||||
queue(move(path));
|
||||
@ -120,7 +120,7 @@ GasMeter::GasConsumption PathGasMeter::handleQueueItem()
|
||||
|
||||
for (u256 const& tag: jumpTags)
|
||||
{
|
||||
auto newPath = unique_ptr<GasPath>(new GasPath());
|
||||
auto newPath = make_unique<GasPath>();
|
||||
newPath->index = m_items.size();
|
||||
if (m_tagPositions.count(tag))
|
||||
newPath->index = m_tagPositions.at(tag);
|
||||
|
@ -35,7 +35,7 @@ unique_ptr<FunctionFlow> ControlFlowBuilder::createFunctionFlow(
|
||||
FunctionDefinition const& _function
|
||||
)
|
||||
{
|
||||
auto functionFlow = unique_ptr<FunctionFlow>(new FunctionFlow());
|
||||
auto functionFlow = make_unique<FunctionFlow>();
|
||||
functionFlow->entry = _nodeContainer.newNode();
|
||||
functionFlow->exit = _nodeContainer.newNode();
|
||||
functionFlow->revert = _nodeContainer.newNode();
|
||||
|
@ -48,7 +48,7 @@ NameAndTypeResolver::NameAndTypeResolver(
|
||||
m_globalContext(_globalContext)
|
||||
{
|
||||
if (!m_scopes[nullptr])
|
||||
m_scopes[nullptr].reset(new DeclarationContainer());
|
||||
m_scopes[nullptr] = make_shared<DeclarationContainer>();
|
||||
for (Declaration const* declaration: _globalContext.declarations())
|
||||
{
|
||||
solAssert(m_scopes[nullptr]->registerDeclaration(*declaration), "Unable to register global declaration.");
|
||||
@ -545,7 +545,7 @@ bool DeclarationRegistrationHelper::visit(SourceUnit& _sourceUnit)
|
||||
{
|
||||
if (!m_scopes[&_sourceUnit])
|
||||
// By importing, it is possible that the container already exists.
|
||||
m_scopes[&_sourceUnit].reset(new DeclarationContainer(m_currentScope, m_scopes[m_currentScope].get()));
|
||||
m_scopes[&_sourceUnit] = make_shared<DeclarationContainer>(m_currentScope, m_scopes[m_currentScope].get());
|
||||
m_currentScope = &_sourceUnit;
|
||||
return true;
|
||||
}
|
||||
@ -561,7 +561,7 @@ bool DeclarationRegistrationHelper::visit(ImportDirective& _import)
|
||||
SourceUnit const* importee = _import.annotation().sourceUnit;
|
||||
solAssert(!!importee, "");
|
||||
if (!m_scopes[importee])
|
||||
m_scopes[importee].reset(new DeclarationContainer(nullptr, m_scopes[nullptr].get()));
|
||||
m_scopes[importee] = make_shared<DeclarationContainer>(nullptr, m_scopes[nullptr].get());
|
||||
m_scopes[&_import] = m_scopes[importee];
|
||||
registerDeclaration(_import, false);
|
||||
return true;
|
||||
@ -705,7 +705,7 @@ void DeclarationRegistrationHelper::enterNewSubScope(ASTNode& _subScope)
|
||||
{
|
||||
map<ASTNode const*, shared_ptr<DeclarationContainer>>::iterator iter;
|
||||
bool newlyAdded;
|
||||
shared_ptr<DeclarationContainer> container(new DeclarationContainer(m_currentScope, m_scopes[m_currentScope].get()));
|
||||
shared_ptr<DeclarationContainer> container{make_shared<DeclarationContainer>(m_currentScope, m_scopes[m_currentScope].get())};
|
||||
tie(iter, newlyAdded) = m_scopes.emplace(&_subScope, move(container));
|
||||
solAssert(newlyAdded, "Unable to add new scope.");
|
||||
m_currentScope = &_subScope;
|
||||
|
@ -329,7 +329,7 @@ MemberList const& Type::members(ContractDefinition const* _currentScope) const
|
||||
MemberList::MemberMap members = nativeMembers(_currentScope);
|
||||
if (_currentScope)
|
||||
members += boundFunctions(*this, *_currentScope);
|
||||
m_members[_currentScope] = unique_ptr<MemberList>(new MemberList(move(members)));
|
||||
m_members[_currentScope] = make_unique<MemberList>(move(members));
|
||||
}
|
||||
return *m_members[_currentScope];
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple)
|
||||
if (_tuple.components().size() == 1)
|
||||
m_currentLValue = move(lvalues[0]);
|
||||
else
|
||||
m_currentLValue.reset(new TupleObject(m_context, move(lvalues)));
|
||||
m_currentLValue = make_unique<TupleObject>(m_context, move(lvalues));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -136,7 +136,7 @@ template <class _LValueType, class... _Arguments>
|
||||
void ExpressionCompiler::setLValue(Expression const& _expression, _Arguments const&... _arguments)
|
||||
{
|
||||
solAssert(!m_currentLValue, "Current LValue not reset before trying to set new one.");
|
||||
std::unique_ptr<_LValueType> lvalue(new _LValueType(m_context, _arguments...));
|
||||
std::unique_ptr<_LValueType> lvalue = std::make_unique<_LValueType>(m_context, _arguments...);
|
||||
if (_expression.annotation().lValueRequested)
|
||||
m_currentLValue = move(lvalue);
|
||||
else
|
||||
|
@ -512,7 +512,7 @@ string const* CompilerStack::sourceMapping(string const& _contractName) const
|
||||
if (!c.sourceMapping)
|
||||
{
|
||||
if (auto items = assemblyItems(_contractName))
|
||||
c.sourceMapping.reset(new string(computeSourceMapping(*items)));
|
||||
c.sourceMapping = make_unique<string>(computeSourceMapping(*items));
|
||||
}
|
||||
return c.sourceMapping.get();
|
||||
}
|
||||
@ -526,7 +526,7 @@ string const* CompilerStack::runtimeSourceMapping(string const& _contractName) c
|
||||
if (!c.runtimeSourceMapping)
|
||||
{
|
||||
if (auto items = runtimeAssemblyItems(_contractName))
|
||||
c.runtimeSourceMapping.reset(new string(computeSourceMapping(*items)));
|
||||
c.runtimeSourceMapping = make_unique<string>(computeSourceMapping(*items));
|
||||
}
|
||||
return c.runtimeSourceMapping.get();
|
||||
}
|
||||
@ -663,7 +663,7 @@ Json::Value const& CompilerStack::contractABI(Contract const& _contract) const
|
||||
|
||||
// caches the result
|
||||
if (!_contract.abi)
|
||||
_contract.abi.reset(new Json::Value(ABI::generate(*_contract.contract)));
|
||||
_contract.abi = make_unique<Json::Value>(ABI::generate(*_contract.contract));
|
||||
|
||||
return *_contract.abi;
|
||||
}
|
||||
@ -685,7 +685,7 @@ Json::Value const& CompilerStack::storageLayout(Contract const& _contract) const
|
||||
|
||||
// caches the result
|
||||
if (!_contract.storageLayout)
|
||||
_contract.storageLayout.reset(new Json::Value(StorageLayout().generate(*_contract.contract)));
|
||||
_contract.storageLayout = make_unique<Json::Value>(StorageLayout().generate(*_contract.contract));
|
||||
|
||||
return *_contract.storageLayout;
|
||||
}
|
||||
@ -707,7 +707,7 @@ Json::Value const& CompilerStack::natspecUser(Contract const& _contract) const
|
||||
|
||||
// caches the result
|
||||
if (!_contract.userDocumentation)
|
||||
_contract.userDocumentation.reset(new Json::Value(Natspec::userDocumentation(*_contract.contract)));
|
||||
_contract.userDocumentation = make_unique<Json::Value>(Natspec::userDocumentation(*_contract.contract));
|
||||
|
||||
return *_contract.userDocumentation;
|
||||
}
|
||||
@ -729,7 +729,7 @@ Json::Value const& CompilerStack::natspecDev(Contract const& _contract) const
|
||||
|
||||
// caches the result
|
||||
if (!_contract.devDocumentation)
|
||||
_contract.devDocumentation.reset(new Json::Value(Natspec::devDocumentation(*_contract.contract)));
|
||||
_contract.devDocumentation = make_unique<Json::Value>(Natspec::devDocumentation(*_contract.contract));
|
||||
|
||||
return *_contract.devDocumentation;
|
||||
}
|
||||
@ -762,7 +762,7 @@ string const& CompilerStack::metadata(Contract const& _contract) const
|
||||
|
||||
// cache the result
|
||||
if (!_contract.metadata)
|
||||
_contract.metadata.reset(new string(createMetadata(_contract)));
|
||||
_contract.metadata = make_unique<string>(createMetadata(_contract));
|
||||
|
||||
return *_contract.metadata;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier()
|
||||
if (m_scanner->currentToken() == Token::LParen)
|
||||
{
|
||||
m_scanner->next();
|
||||
arguments.reset(new vector<ASTPointer<Expression>>(parseFunctionCallListArguments()));
|
||||
arguments = make_unique<vector<ASTPointer<Expression>>>(parseFunctionCallListArguments());
|
||||
nodeFactory.markEndPosition();
|
||||
expectToken(Token::RParen);
|
||||
}
|
||||
@ -811,7 +811,7 @@ ASTPointer<ModifierInvocation> Parser::parseModifierInvocation()
|
||||
if (m_scanner->currentToken() == Token::LParen)
|
||||
{
|
||||
m_scanner->next();
|
||||
arguments.reset(new vector<ASTPointer<Expression>>(parseFunctionCallListArguments()));
|
||||
arguments = make_unique<vector<ASTPointer<Expression>>>(parseFunctionCallListArguments());
|
||||
nodeFactory.markEndPosition();
|
||||
expectToken(Token::RParen);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ Statement Parser::parseStatement()
|
||||
|
||||
expectToken(Token::AssemblyAssign);
|
||||
|
||||
assignment.value.reset(new Expression(parseExpression()));
|
||||
assignment.value = make_unique<Expression>(parseExpression());
|
||||
assignment.location.end = locationOf(*assignment.value).end;
|
||||
|
||||
return Statement{std::move(assignment)};
|
||||
|
@ -933,7 +933,7 @@ bool CommandLineInterface::processInput()
|
||||
return link();
|
||||
}
|
||||
|
||||
m_compiler.reset(new CompilerStack(fileReader));
|
||||
m_compiler = make_unique<CompilerStack>(fileReader);
|
||||
|
||||
unique_ptr<SourceReferenceFormatter> formatter;
|
||||
if (m_args.count(g_argNewReporter))
|
||||
|
@ -96,7 +96,7 @@ int registerTests(
|
||||
{
|
||||
static vector<unique_ptr<string>> filenames;
|
||||
|
||||
filenames.emplace_back(new string(_path.string()));
|
||||
filenames.emplace_back(make_unique<string>(_path.string()));
|
||||
_suite.add(make_test_case(
|
||||
[config, _testCaseCreator]
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ protected:
|
||||
void deployRegistrar()
|
||||
{
|
||||
if (!s_compiledRegistrar)
|
||||
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "GlobalRegistrar")));
|
||||
s_compiledRegistrar = make_unique<bytes>(compileContract(registrarCode, "GlobalRegistrar"));
|
||||
|
||||
sendMessage(*s_compiledRegistrar, true);
|
||||
BOOST_REQUIRE(m_transactionSuccessful);
|
||||
|
@ -132,7 +132,7 @@ protected:
|
||||
void deployRegistrar()
|
||||
{
|
||||
if (!s_compiledRegistrar)
|
||||
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "FixedFeeRegistrar")));
|
||||
s_compiledRegistrar = make_unique<bytes>(compileContract(registrarCode, "FixedFeeRegistrar"));
|
||||
|
||||
sendMessage(*s_compiledRegistrar, true);
|
||||
BOOST_REQUIRE(m_transactionSuccessful);
|
||||
|
@ -448,7 +448,7 @@ protected:
|
||||
)
|
||||
{
|
||||
if (!s_compiledWallet)
|
||||
s_compiledWallet.reset(new bytes(compileContract(walletCode, "Wallet")));
|
||||
s_compiledWallet = make_unique<bytes>(compileContract(walletCode, "Wallet"));
|
||||
|
||||
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
|
||||
sendMessage(*s_compiledWallet + args, true, _value);
|
||||
|
@ -36,7 +36,7 @@ class ABIJsonTest: public TestCase
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{ return std::unique_ptr<TestCase>(new ABIJsonTest(_config.filename)); }
|
||||
{ return std::make_unique<ABIJsonTest>(_config.filename); }
|
||||
ABIJsonTest(std::string const& _filename);
|
||||
|
||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
@ -36,7 +36,7 @@ class ASTJSONTest: public TestCase
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{ return std::unique_ptr<TestCase>(new ASTJSONTest(_config.filename)); }
|
||||
{ return std::make_unique<ASTJSONTest>(_config.filename); }
|
||||
ASTJSONTest(std::string const& _filename);
|
||||
|
||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
@ -37,7 +37,7 @@ class EWasmTranslationTest: public dev::solidity::test::EVMVersionRestrictedTest
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{
|
||||
return std::unique_ptr<TestCase>(new EWasmTranslationTest(_config.filename));
|
||||
return std::make_unique<EWasmTranslationTest>(_config.filename);
|
||||
}
|
||||
|
||||
explicit EWasmTranslationTest(std::string const& _filename);
|
||||
|
@ -34,7 +34,7 @@ class FunctionSideEffects: public dev::solidity::test::TestCase
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{ return std::unique_ptr<TestCase>(new FunctionSideEffects(_config.filename)); }
|
||||
{ return std::make_unique<FunctionSideEffects>(_config.filename); }
|
||||
explicit FunctionSideEffects(std::string const& _filename);
|
||||
|
||||
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
|
||||
|
@ -42,7 +42,7 @@ class ObjectCompilerTest: public dev::solidity::test::TestCase
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{
|
||||
return std::unique_ptr<TestCase>(new ObjectCompilerTest(_config.filename));
|
||||
return std::make_unique<ObjectCompilerTest>(_config.filename);
|
||||
}
|
||||
|
||||
explicit ObjectCompilerTest(std::string const& _filename);
|
||||
|
@ -42,7 +42,7 @@ class YulInterpreterTest: public dev::solidity::test::EVMVersionRestrictedTestCa
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{
|
||||
return std::unique_ptr<TestCase>(new YulInterpreterTest(_config.filename));
|
||||
return std::make_unique<YulInterpreterTest>(_config.filename);
|
||||
}
|
||||
|
||||
explicit YulInterpreterTest(std::string const& _filename);
|
||||
|
@ -424,7 +424,11 @@ void YulOptimizerTest::disambiguate()
|
||||
void YulOptimizerTest::updateContext()
|
||||
{
|
||||
m_nameDispenser = make_unique<NameDispenser>(*m_dialect, *m_ast, m_reservedIdentifiers);
|
||||
m_context = unique_ptr<OptimiserStepContext>(new OptimiserStepContext{*m_dialect, *m_nameDispenser, m_reservedIdentifiers});
|
||||
m_context = make_unique<OptimiserStepContext>(OptimiserStepContext{
|
||||
*m_dialect,
|
||||
*m_nameDispenser,
|
||||
m_reservedIdentifiers
|
||||
});
|
||||
}
|
||||
|
||||
void YulOptimizerTest::printErrors(ostream& _stream, ErrorList const& _errors)
|
||||
|
@ -51,7 +51,7 @@ class YulOptimizerTest: public dev::solidity::test::EVMVersionRestrictedTestCase
|
||||
public:
|
||||
static std::unique_ptr<TestCase> create(Config const& _config)
|
||||
{
|
||||
return std::unique_ptr<TestCase>(new YulOptimizerTest(_config.filename));
|
||||
return std::make_unique<YulOptimizerTest>(_config.filename);
|
||||
}
|
||||
|
||||
explicit YulOptimizerTest(std::string const& _filename);
|
||||
|
Loading…
Reference in New Issue
Block a user