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
+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
{