mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Only clear for assignment.
This commit is contained in:
parent
3e5396598b
commit
21c35924df
@ -82,7 +82,7 @@ void DataFlowAnalyzer::operator()(Assignment& _assignment)
|
||||
assertThrow(_assignment.value, OptimizerException, "");
|
||||
clearKnowledgeIfInvalidated(*_assignment.value);
|
||||
visit(*_assignment.value);
|
||||
handleAssignment(names, _assignment.value.get());
|
||||
handleAssignment(names, _assignment.value.get(), false);
|
||||
}
|
||||
|
||||
void DataFlowAnalyzer::operator()(VariableDeclaration& _varDecl)
|
||||
@ -98,7 +98,7 @@ void DataFlowAnalyzer::operator()(VariableDeclaration& _varDecl)
|
||||
visit(*_varDecl.value);
|
||||
}
|
||||
|
||||
handleAssignment(names, _varDecl.value.get());
|
||||
handleAssignment(names, _varDecl.value.get(), true);
|
||||
}
|
||||
|
||||
void DataFlowAnalyzer::operator()(If& _if)
|
||||
@ -161,7 +161,7 @@ void DataFlowAnalyzer::operator()(FunctionDefinition& _fun)
|
||||
for (auto const& var: _fun.returnVariables)
|
||||
{
|
||||
m_variableScopes.back().variables.emplace(var.name);
|
||||
handleAssignment({var.name}, nullptr);
|
||||
handleAssignment({var.name}, nullptr, true);
|
||||
}
|
||||
ASTModifier::operator()(_fun);
|
||||
|
||||
@ -220,8 +220,9 @@ void DataFlowAnalyzer::operator()(Block& _block)
|
||||
assertThrow(numScopes == m_variableScopes.size(), OptimizerException, "");
|
||||
}
|
||||
|
||||
void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expression* _value)
|
||||
void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expression* _value, bool _isDeclaration)
|
||||
{
|
||||
if (!_isDeclaration)
|
||||
clearValues(_variables);
|
||||
|
||||
MovableChecker movableChecker{m_dialect, &m_functionSideEffects};
|
||||
@ -244,6 +245,8 @@ void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expres
|
||||
for (auto const& name: _variables)
|
||||
{
|
||||
m_references.set(name, referencedVariables);
|
||||
if (!_isDeclaration)
|
||||
{
|
||||
// assignment to slot denoted by "name"
|
||||
m_storage.eraseKey(name);
|
||||
// assignment to slot contents denoted by "name"
|
||||
@ -253,6 +256,7 @@ void DataFlowAnalyzer::handleAssignment(set<YulString> const& _variables, Expres
|
||||
// assignment to slot contents denoted by "name"
|
||||
m_memory.eraseValue(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (_value && _variables.size() == 1)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
|
||||
protected:
|
||||
/// Registers the assignment.
|
||||
void handleAssignment(std::set<YulString> const& _names, Expression* _value);
|
||||
void handleAssignment(std::set<YulString> const& _names, Expression* _value, bool _isDeclaration);
|
||||
|
||||
/// Creates a new inner scope.
|
||||
void pushScope(bool _functionScope);
|
||||
|
Loading…
Reference in New Issue
Block a user