aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/StructuralSimplifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libyul/optimiser/StructuralSimplifier.cpp')
-rw-r--r--libyul/optimiser/StructuralSimplifier.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp
index 8d7dcd57..727775cb 100644
--- a/libyul/optimiser/StructuralSimplifier.cpp
+++ b/libyul/optimiser/StructuralSimplifier.cpp
@@ -51,7 +51,11 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
GenericFallbackReturnsVisitor<OptionalStatements, If, Switch, ForLoop> const visitor(
[&](If& _ifStmt) -> OptionalStatements {
if (_ifStmt.body.statements.empty())
- return {{makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition))}};
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition)));
+ return s;
+ }
if (expressionAlwaysTrue(*_ifStmt.condition))
return {std::move(_ifStmt.body.statements)};
else if (expressionAlwaysFalse(*_ifStmt.condition))
@@ -64,18 +68,24 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
auto& switchCase = _switchStmt.cases.front();
auto loc = locationOf(*_switchStmt.expression);
if (switchCase.value)
- return {{If{
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(If{
std::move(_switchStmt.location),
- make_shared<Expression>(FunctionalInstruction{
+ make_unique<Expression>(FunctionalInstruction{
std::move(loc),
solidity::Instruction::EQ,
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
- }), std::move(switchCase.body)}}};
+ }), std::move(switchCase.body)});
+ return s;
+ }
else
- return {{
- makePopExpressionStatement(loc, std::move(*_switchStmt.expression)),
- std::move(switchCase.body)
- }};
+ {
+ OptionalStatements s = vector<Statement>{};
+ s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
+ s->emplace_back(std::move(switchCase.body));
+ return s;
+ }
}
else
return {};