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

This commit is contained in:
chriseth
2019-10-28 15:21:49 +01:00
67 changed files with 182 additions and 165 deletions
+1 -1
View File
@@ -658,7 +658,7 @@ bool AsmAnalyzer::warnOnInstructions(std::string const& _instructionIdentifier,
{
auto const builtin = EVMDialect::strictAssemblyForEVM(EVMVersion{}).builtin(YulString(_instructionIdentifier));
if (builtin)
return warnOnInstructions(builtin->instruction.get(), _location);
return warnOnInstructions(builtin->instruction.value(), _location);
else
return false;
}
+1 -1
View File
@@ -31,11 +31,11 @@
#include <libyul/backends/evm/EVMDialect.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <functional>
#include <list>
#include <memory>
#include <optional>
namespace langutil
{
+1 -1
View File
@@ -27,10 +27,10 @@
#include <libdevcore/Visitor.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <functional>
#include <memory>
#include <optional>
namespace yul
{
+2 -4
View File
@@ -704,9 +704,7 @@ void CodeTransform::visitExpression(Expression const& _expression)
void CodeTransform::visitStatements(vector<Statement> const& _statements)
{
// Workaround boost bug:
// https://www.boost.org/doc/libs/1_63_0/libs/optional/doc/html/boost_optional/tutorial/gotchas/false_positive_with__wmaybe_uninitialized.html
boost::optional<AbstractAssembly::LabelID> jumpTarget = boost::make_optional(false, AbstractAssembly::LabelID());
std::optional<AbstractAssembly::LabelID> jumpTarget = std::nullopt;
for (auto const& statement: _statements)
{
@@ -721,7 +719,7 @@ void CodeTransform::visitStatements(vector<Statement> const& _statements)
else if (!functionDefinition && jumpTarget)
{
m_assembly.appendLabel(*jumpTarget);
jumpTarget = boost::none;
jumpTarget = std::nullopt;
}
boost::apply_visitor(*this, statement);
+1 -1
View File
@@ -28,8 +28,8 @@
#include <libyul/AsmScope.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <optional>
#include <stack>
namespace langutil
+1 -1
View File
@@ -47,7 +47,7 @@ struct BuiltinContext
struct BuiltinFunctionForEVM: BuiltinFunction
{
boost::optional<dev::eth::Instruction> instruction;
std::optional<dev::eth::Instruction> instruction;
/// Function to generate code for the given function call and append it to the abstract
/// assembly. The fourth parameter is called to visit (and generate code for) the arguments
/// from right to left.
+9 -9
View File
@@ -82,7 +82,7 @@ void WordSizeTransform::operator()(Block& _block)
{
iterateReplacing(
_block.statements,
[&](Statement& _s) -> boost::optional<vector<Statement>>
[&](Statement& _s) -> std::optional<vector<Statement>>
{
if (_s.type() == typeid(VariableDeclaration))
{
@@ -95,7 +95,7 @@ void WordSizeTransform::operator()(Block& _block)
{
if (varDecl.value) visit(*varDecl.value);
rewriteVarDeclList(varDecl.variables);
return boost::none;
return std::nullopt;
}
else if (
varDecl.value->type() == typeid(Identifier) ||
@@ -114,7 +114,7 @@ void WordSizeTransform::operator()(Block& _block)
std::move(newRhs[i])
}
);
return ret;
return {std::move(ret)};
}
else
yulAssert(false, "");
@@ -130,7 +130,7 @@ void WordSizeTransform::operator()(Block& _block)
{
if (assignment.value) visit(*assignment.value);
rewriteIdentifierList(assignment.variableNames);
return boost::none;
return std::nullopt;
}
else if (
assignment.value->type() == typeid(Identifier) ||
@@ -149,7 +149,7 @@ void WordSizeTransform::operator()(Block& _block)
std::move(newRhs[i])
}
);
return ret;
return {std::move(ret)};
}
else
yulAssert(false, "");
@@ -158,7 +158,7 @@ void WordSizeTransform::operator()(Block& _block)
return handleSwitch(boost::get<Switch>(_s));
else
visit(_s);
return boost::none;
return std::nullopt;
}
);
}
@@ -174,7 +174,7 @@ void WordSizeTransform::rewriteVarDeclList(TypedNameList& _nameList)
{
iterateReplacing(
_nameList,
[&](TypedName const& _n) -> boost::optional<TypedNameList>
[&](TypedName const& _n) -> std::optional<TypedNameList>
{
TypedNameList ret;
for (auto newName: generateU64IdentifierNames(_n.name))
@@ -188,7 +188,7 @@ void WordSizeTransform::rewriteIdentifierList(vector<Identifier>& _ids)
{
iterateReplacing(
_ids,
[&](Identifier const& _id) -> boost::optional<vector<Identifier>>
[&](Identifier const& _id) -> std::optional<vector<Identifier>>
{
vector<Identifier> ret;
for (auto newId: m_variableMapping.at(_id.name))
@@ -202,7 +202,7 @@ void WordSizeTransform::rewriteFunctionCallArguments(vector<Expression>& _args)
{
iterateReplacing(
_args,
[&](Expression& _e) -> boost::optional<vector<Expression>>
[&](Expression& _e) -> std::optional<vector<Expression>>
{
return expandValueToVector(_e);
}
+3 -3
View File
@@ -25,11 +25,11 @@
#include <libyul/YulString.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <vector>
#include <set>
#include <memory>
#include <optional>
#include <set>
#include <vector>
namespace yul
{
+3 -3
View File
@@ -26,11 +26,11 @@
#include <libyul/YulString.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <vector>
#include <set>
#include <map>
#include <optional>
#include <set>
#include <vector>
namespace yul
{
+1 -1
View File
@@ -30,7 +30,7 @@ void BlockFlattener::operator()(Block& _block)
iterateReplacing(
_block.statements,
[](Statement& _s) -> boost::optional<vector<Statement>>
[](Statement& _s) -> std::optional<vector<Statement>>
{
if (_s.type() == typeid(Block))
return std::move(boost::get<Block>(_s).statements);
+2 -3
View File
@@ -24,10 +24,9 @@
#include <libdevcore/InvertibleMap.h>
#include <boost/optional.hpp>
#include <set>
#include <map>
#include <optional>
#include <set>
namespace yul
{
+1 -1
View File
@@ -30,7 +30,7 @@ using namespace std;
using namespace dev;
using namespace yul;
using OptionalStatements = boost::optional<vector<Statement>>;
using OptionalStatements = std::optional<vector<Statement>>;
namespace
{
+1 -1
View File
@@ -354,7 +354,7 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const
return false;
}
boost::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
std::optional<pair<YulString, YulString>> DataFlowAnalyzer::isSimpleStore(
dev::eth::Instruction _store,
ExpressionStatement const& _statement
) const
+1 -1
View File
@@ -128,7 +128,7 @@ protected:
/// Returns true iff the variable is in scope.
bool inScope(YulString _variableName) const;
boost::optional<std::pair<YulString, YulString>> isSimpleStore(
std::optional<std::pair<YulString, YulString>> isSimpleStore(
dev::eth::Instruction _store,
ExpressionStatement const& _statement
) const;
+1 -1
View File
@@ -26,8 +26,8 @@
#include <libyul/optimiser/NameDispenser.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <optional>
#include <set>
namespace yul
+1 -1
View File
@@ -23,7 +23,7 @@
#include <libyul/AsmDataForward.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <optional>
#include <set>
+2 -2
View File
@@ -85,8 +85,8 @@ void ExpressionSplitter::operator()(Block& _block)
vector<Statement> saved;
swap(saved, m_statementsToPrefix);
function<boost::optional<vector<Statement>>(Statement&)> f =
[&](Statement& _statement) -> boost::optional<vector<Statement>> {
function<std::optional<vector<Statement>>(Statement&)> f =
[&](Statement& _statement) -> std::optional<vector<Statement>> {
m_statementsToPrefix.clear();
visit(_statement);
if (m_statementsToPrefix.empty())
+1 -1
View File
@@ -27,7 +27,7 @@ void ForLoopInitRewriter::operator()(Block& _block)
{
iterateReplacing(
_block.statements,
[&](Statement& _stmt) -> boost::optional<vector<Statement>>
[&](Statement& _stmt) -> std::optional<vector<Statement>>
{
if (_stmt.type() == typeid(ForLoop))
{
+2 -2
View File
@@ -147,14 +147,14 @@ bool FullInliner::recursive(FunctionDefinition const& _fun) const
void InlineModifier::operator()(Block& _block)
{
function<boost::optional<vector<Statement>>(Statement&)> f = [&](Statement& _statement) -> boost::optional<vector<Statement>> {
function<std::optional<vector<Statement>>(Statement&)> f = [&](Statement& _statement) -> std::optional<vector<Statement>> {
visit(_statement);
return tryInlineStatement(_statement);
};
iterateReplacing(_block.statements, f);
}
boost::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _statement)
std::optional<vector<Statement>> InlineModifier::tryInlineStatement(Statement& _statement)
{
// Only inline for expression statements, assignments and variable declarations.
Expression* e = boost::apply_visitor(GenericFallbackReturnsVisitor<Expression*, ExpressionStatement, Assignment, VariableDeclaration>(
+2 -2
View File
@@ -30,8 +30,8 @@
#include <liblangutil/SourceLocation.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <optional>
#include <set>
namespace yul
@@ -126,7 +126,7 @@ public:
void operator()(Block& _block) override;
private:
boost::optional<std::vector<Statement>> tryInlineStatement(Statement& _statement);
std::optional<std::vector<Statement>> tryInlineStatement(Statement& _statement);
std::vector<Statement> performInline(Statement& _statement, FunctionCall& _funCall);
YulString m_currentFunction;
+1 -1
View File
@@ -35,7 +35,7 @@ void SSAReverser::operator()(Block& _block)
walkVector(_block.statements);
iterateReplacingWindow<2>(
_block.statements,
[&](Statement& _stmt1, Statement& _stmt2) -> boost::optional<vector<Statement>>
[&](Statement& _stmt1, Statement& _stmt2) -> std::optional<vector<Statement>>
{
auto* varDecl = boost::get<VariableDeclaration>(&_stmt1);
+3 -3
View File
@@ -58,7 +58,7 @@ void IntroduceSSA::operator()(Block& _block)
{
iterateReplacing(
_block.statements,
[&](Statement& _s) -> boost::optional<vector<Statement>>
[&](Statement& _s) -> std::optional<vector<Statement>>
{
if (_s.type() == typeid(VariableDeclaration))
{
@@ -213,7 +213,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block)
iterateReplacing(
_block.statements,
[&](Statement& _s) -> boost::optional<vector<Statement>>
[&](Statement& _s) -> std::optional<vector<Statement>>
{
vector<Statement> toPrepend;
for (YulString toReassign: m_variablesToReassign)
@@ -253,7 +253,7 @@ void IntroduceControlFlowSSA::operator()(Block& _block)
else
{
toPrepend.emplace_back(std::move(_s));
return toPrepend;
return {std::move(toPrepend)};
}
}
);
+1 -1
View File
@@ -64,7 +64,7 @@ bool SimplificationRules::isInitialized() const
return !m_rules[uint8_t(dev::eth::Instruction::ADD)].empty();
}
boost::optional<std::pair<dev::eth::Instruction, vector<Expression> const*>>
std::optional<std::pair<dev::eth::Instruction, vector<Expression> const*>>
SimplificationRules::instructionAndArguments(Dialect const& _dialect, Expression const& _expr)
{
if (_expr.type() == typeid(FunctionalInstruction))
+2 -2
View File
@@ -26,9 +26,9 @@
#include <libyul/AsmData.h>
#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
#include <functional>
#include <optional>
#include <vector>
namespace yul
@@ -57,7 +57,7 @@ public:
/// by the constructor, but we had some issues with static initialization.
bool isInitialized() const;
static boost::optional<std::pair<dev::eth::Instruction, std::vector<Expression> const*>>
static std::optional<std::pair<dev::eth::Instruction, std::vector<Expression> const*>>
instructionAndArguments(Dialect const& _dialect, Expression const& _expr);
private:
+8 -8
View File
@@ -28,7 +28,7 @@ using namespace std;
using namespace dev;
using namespace yul;
using OptionalStatements = boost::optional<vector<Statement>>;
using OptionalStatements = std::optional<vector<Statement>>;
namespace {
@@ -54,7 +54,7 @@ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _const
if (matchingCaseBlock)
return make_vector<Statement>(std::move(*matchingCaseBlock));
else
return {{}};
return optional<vector<Statement>>{vector<Statement>{}};
}
}
@@ -80,8 +80,8 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
return {};
},
[&](Switch& _switchStmt) -> OptionalStatements {
if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
if (std::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
return replaceConstArgSwitch(_switchStmt, constExprVal.value());
return {};
},
[&](ForLoop& _forLoop) -> OptionalStatements {
@@ -107,7 +107,7 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
bool StructuralSimplifier::expressionAlwaysTrue(Expression const& _expression)
{
if (boost::optional<u256> value = hasLiteralValue(_expression))
if (std::optional<u256> value = hasLiteralValue(_expression))
return *value != 0;
else
return false;
@@ -115,16 +115,16 @@ bool StructuralSimplifier::expressionAlwaysTrue(Expression const& _expression)
bool StructuralSimplifier::expressionAlwaysFalse(Expression const& _expression)
{
if (boost::optional<u256> value = hasLiteralValue(_expression))
if (std::optional<u256> value = hasLiteralValue(_expression))
return *value == 0;
else
return false;
}
boost::optional<dev::u256> StructuralSimplifier::hasLiteralValue(Expression const& _expression) const
std::optional<dev::u256> StructuralSimplifier::hasLiteralValue(Expression const& _expression) const
{
if (_expression.type() == typeid(Literal))
return valueOfLiteral(boost::get<Literal>(_expression));
else
return boost::optional<u256>();
return std::optional<u256>();
}
+1 -1
View File
@@ -51,7 +51,7 @@ private:
void simplify(std::vector<Statement>& _statements);
bool expressionAlwaysTrue(Expression const& _expression);
bool expressionAlwaysFalse(Expression const& _expression);
boost::optional<dev::u256> hasLiteralValue(Expression const& _expression) const;
std::optional<dev::u256> hasLiteralValue(Expression const& _expression) const;
};
}
+1 -1
View File
@@ -29,7 +29,7 @@ void VarDeclInitializer::operator()(Block& _block)
{
ASTModifier::operator()(_block);
using OptionalStatements = boost::optional<vector<Statement>>;
using OptionalStatements = std::optional<vector<Statement>>;
GenericFallbackReturnsVisitor<OptionalStatements, VariableDeclaration> visitor{
[](VariableDeclaration& _varDecl) -> OptionalStatements
{