aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/FullInliner.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-13 22:38:14 +0800
committerchriseth <chris@ethereum.org>2018-12-13 23:51:10 +0800
commit6c6a53a439de11ebae0b09d8a18c30018b3d89b4 (patch)
tree5abf3f2a9d4f5a8778af1afb8f2fcdbd005434b4 /libyul/optimiser/FullInliner.cpp
parent11209ec48a3581419ebfa4764669c2a128f1b997 (diff)
downloaddexon-solidity-6c6a53a439de11ebae0b09d8a18c30018b3d89b4.tar.gz
dexon-solidity-6c6a53a439de11ebae0b09d8a18c30018b3d89b4.tar.zst
dexon-solidity-6c6a53a439de11ebae0b09d8a18c30018b3d89b4.zip
Do not create unassigned variables.
Diffstat (limited to 'libyul/optimiser/FullInliner.cpp')
-rw-r--r--libyul/optimiser/FullInliner.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp
index 04005847..95360dc3 100644
--- a/libyul/optimiser/FullInliner.cpp
+++ b/libyul/optimiser/FullInliner.cpp
@@ -168,6 +168,8 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
m_driver.tentativelyUpdateCodeSize(function->name, m_currentFunction);
+ static Expression const zero{Literal{{}, LiteralKind::Number, YulString{"0"}, {}}};
+
// helper function to create a new variable that is supposed to model
// an existing variable.
auto newVariable = [&](TypedName const& _existingVariable, Expression* _value) {
@@ -176,6 +178,8 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
VariableDeclaration varDecl{_funCall.location, {{_funCall.location, newName, _existingVariable.type}}, {}};
if (_value)
varDecl.value = make_shared<Expression>(std::move(*_value));
+ else
+ varDecl.value = make_shared<Expression>(zero);
newStatements.emplace_back(std::move(varDecl));
};