Merge remote-tracking branch 'origin/develop' into develop_060

This commit is contained in:
chriseth
2019-11-27 19:14:08 +01:00
33 changed files with 298 additions and 158 deletions
+1 -1
View File
@@ -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();
+4 -4
View File
@@ -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;
@@ -720,7 +720,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;
+23 -28
View File
@@ -55,11 +55,6 @@ ASTNode::ASTNode(SourceLocation const& _location):
{
}
ASTNode::~ASTNode()
{
delete m_annotation;
}
void ASTNode::resetID()
{
IDDispenser::reset();
@@ -68,14 +63,14 @@ void ASTNode::resetID()
ASTAnnotation& ASTNode::annotation() const
{
if (!m_annotation)
m_annotation = new ASTAnnotation();
m_annotation = make_unique<ASTAnnotation>();
return *m_annotation;
}
SourceUnitAnnotation& SourceUnit::annotation() const
{
if (!m_annotation)
m_annotation = new SourceUnitAnnotation();
m_annotation = make_unique<SourceUnitAnnotation>();
return dynamic_cast<SourceUnitAnnotation&>(*m_annotation);
}
@@ -99,7 +94,7 @@ set<SourceUnit const*> SourceUnit::referencedSourceUnits(bool _recurse, set<Sour
ImportAnnotation& ImportDirective::annotation() const
{
if (!m_annotation)
m_annotation = new ImportAnnotation();
m_annotation = make_unique<ImportAnnotation>();
return dynamic_cast<ImportAnnotation&>(*m_annotation);
}
@@ -177,7 +172,7 @@ vector<EventDefinition const*> const& ContractDefinition::interfaceEvents() cons
if (!m_interfaceEvents)
{
set<string> eventsSeen;
m_interfaceEvents.reset(new vector<EventDefinition const*>());
m_interfaceEvents = make_unique<vector<EventDefinition const*>>();
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
for (EventDefinition const* e: contract->events())
{
@@ -202,7 +197,7 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::inter
if (!m_interfaceFunctionList)
{
set<string> signaturesSeen;
m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, FunctionTypePointer>>());
m_interfaceFunctionList = make_unique<vector<pair<FixedHash<4>, FunctionTypePointer>>>();
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
{
vector<FunctionTypePointer> functions;
@@ -234,7 +229,7 @@ vector<Declaration const*> const& ContractDefinition::inheritableMembers() const
{
if (!m_inheritableMembers)
{
m_inheritableMembers.reset(new vector<Declaration const*>());
m_inheritableMembers = make_unique<vector<Declaration const*>>();
auto addInheritableMember = [&](Declaration const* _decl)
{
solAssert(_decl, "addInheritableMember got a nullpointer.");
@@ -268,14 +263,14 @@ TypePointer ContractDefinition::type() const
ContractDefinitionAnnotation& ContractDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new ContractDefinitionAnnotation();
m_annotation = make_unique<ContractDefinitionAnnotation>();
return dynamic_cast<ContractDefinitionAnnotation&>(*m_annotation);
}
TypeNameAnnotation& TypeName::annotation() const
{
if (!m_annotation)
m_annotation = new TypeNameAnnotation();
m_annotation = make_unique<TypeNameAnnotation>();
return dynamic_cast<TypeNameAnnotation&>(*m_annotation);
}
@@ -287,7 +282,7 @@ TypePointer StructDefinition::type() const
TypeDeclarationAnnotation& StructDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new TypeDeclarationAnnotation();
m_annotation = make_unique<TypeDeclarationAnnotation>();
return dynamic_cast<TypeDeclarationAnnotation&>(*m_annotation);
}
@@ -306,7 +301,7 @@ TypePointer EnumDefinition::type() const
TypeDeclarationAnnotation& EnumDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new TypeDeclarationAnnotation();
m_annotation = make_unique<TypeDeclarationAnnotation>();
return dynamic_cast<TypeDeclarationAnnotation&>(*m_annotation);
}
@@ -366,7 +361,7 @@ string FunctionDefinition::externalSignature() const
FunctionDefinitionAnnotation& FunctionDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new FunctionDefinitionAnnotation();
m_annotation = make_unique<FunctionDefinitionAnnotation>();
return dynamic_cast<FunctionDefinitionAnnotation&>(*m_annotation);
}
@@ -378,7 +373,7 @@ TypePointer ModifierDefinition::type() const
ModifierDefinitionAnnotation& ModifierDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new ModifierDefinitionAnnotation();
m_annotation = make_unique<ModifierDefinitionAnnotation>();
return dynamic_cast<ModifierDefinitionAnnotation&>(*m_annotation);
}
@@ -398,14 +393,14 @@ FunctionTypePointer EventDefinition::functionType(bool _internal) const
EventDefinitionAnnotation& EventDefinition::annotation() const
{
if (!m_annotation)
m_annotation = new EventDefinitionAnnotation();
m_annotation = make_unique<EventDefinitionAnnotation>();
return dynamic_cast<EventDefinitionAnnotation&>(*m_annotation);
}
UserDefinedTypeNameAnnotation& UserDefinedTypeName::annotation() const
{
if (!m_annotation)
m_annotation = new UserDefinedTypeNameAnnotation();
m_annotation = make_unique<UserDefinedTypeNameAnnotation>();
return dynamic_cast<UserDefinedTypeNameAnnotation&>(*m_annotation);
}
@@ -619,63 +614,63 @@ FunctionTypePointer VariableDeclaration::functionType(bool _internal) const
VariableDeclarationAnnotation& VariableDeclaration::annotation() const
{
if (!m_annotation)
m_annotation = new VariableDeclarationAnnotation();
m_annotation = make_unique<VariableDeclarationAnnotation>();
return dynamic_cast<VariableDeclarationAnnotation&>(*m_annotation);
}
StatementAnnotation& Statement::annotation() const
{
if (!m_annotation)
m_annotation = new StatementAnnotation();
m_annotation = make_unique<StatementAnnotation>();
return dynamic_cast<StatementAnnotation&>(*m_annotation);
}
InlineAssemblyAnnotation& InlineAssembly::annotation() const
{
if (!m_annotation)
m_annotation = new InlineAssemblyAnnotation();
m_annotation = make_unique<InlineAssemblyAnnotation>();
return dynamic_cast<InlineAssemblyAnnotation&>(*m_annotation);
}
ReturnAnnotation& Return::annotation() const
{
if (!m_annotation)
m_annotation = new ReturnAnnotation();
m_annotation = make_unique<ReturnAnnotation>();
return dynamic_cast<ReturnAnnotation&>(*m_annotation);
}
ExpressionAnnotation& Expression::annotation() const
{
if (!m_annotation)
m_annotation = new ExpressionAnnotation();
m_annotation = make_unique<ExpressionAnnotation>();
return dynamic_cast<ExpressionAnnotation&>(*m_annotation);
}
MemberAccessAnnotation& MemberAccess::annotation() const
{
if (!m_annotation)
m_annotation = new MemberAccessAnnotation();
m_annotation = make_unique<MemberAccessAnnotation>();
return dynamic_cast<MemberAccessAnnotation&>(*m_annotation);
}
BinaryOperationAnnotation& BinaryOperation::annotation() const
{
if (!m_annotation)
m_annotation = new BinaryOperationAnnotation();
m_annotation = make_unique<BinaryOperationAnnotation>();
return dynamic_cast<BinaryOperationAnnotation&>(*m_annotation);
}
FunctionCallAnnotation& FunctionCall::annotation() const
{
if (!m_annotation)
m_annotation = new FunctionCallAnnotation();
m_annotation = make_unique<FunctionCallAnnotation>();
return dynamic_cast<FunctionCallAnnotation&>(*m_annotation);
}
IdentifierAnnotation& Identifier::annotation() const
{
if (!m_annotation)
m_annotation = new IdentifierAnnotation();
m_annotation = make_unique<IdentifierAnnotation>();
return dynamic_cast<IdentifierAnnotation&>(*m_annotation);
}
+2 -2
View File
@@ -67,7 +67,7 @@ public:
using SourceLocation = langutil::SourceLocation;
explicit ASTNode(SourceLocation const& _location);
virtual ~ASTNode();
virtual ~ASTNode() {}
/// @returns an identifier of this AST node that is unique for a single compilation run.
size_t id() const { return m_id; }
@@ -111,7 +111,7 @@ public:
protected:
size_t const m_id = 0;
/// Annotation - is specialised in derived classes, is created upon request (because of polymorphism).
mutable ASTAnnotation* m_annotation = nullptr;
mutable std::unique_ptr<ASTAnnotation> m_annotation;
private:
SourceLocation m_location;
+1 -1
View File
@@ -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];
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -149,7 +149,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
+7 -7
View File
@@ -529,7 +529,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();
}
@@ -543,7 +543,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();
}
@@ -680,7 +680,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;
}
@@ -702,7 +702,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;
}
@@ -724,7 +724,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;
}
@@ -746,7 +746,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;
}
@@ -779,7 +779,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;
}
+2 -2
View File
@@ -368,7 +368,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);
}
@@ -892,7 +892,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);
}