diff options
author | chriseth <chris@ethereum.org> | 2018-10-28 19:57:13 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-08 03:32:55 +0800 |
commit | b2b11eaa00de3174ead7dbeb77bbc315719bd79d (patch) | |
tree | 30704b640ad5447cb5aff03e739497cf4a06f12f /libyul/optimiser | |
parent | bed0368ffac4f9e34ff14e115619ed2cd994e2f7 (diff) | |
download | dexon-solidity-b2b11eaa00de3174ead7dbeb77bbc315719bd79d.tar.gz dexon-solidity-b2b11eaa00de3174ead7dbeb77bbc315719bd79d.tar.zst dexon-solidity-b2b11eaa00de3174ead7dbeb77bbc315719bd79d.zip |
Fix data flow analyzer for function definitions.
Diffstat (limited to 'libyul/optimiser')
-rw-r--r-- | libyul/optimiser/DataFlowAnalyzer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index 1ff1d2f0..134777d0 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -84,13 +84,26 @@ void DataFlowAnalyzer::operator()(Switch& _switch) void DataFlowAnalyzer::operator()(FunctionDefinition& _fun) { + // Save all information. We might rather reinstantiate this class, + // but this could be difficult if it is subclassed. + map<YulString, Expression const*> value; + map<YulString, set<YulString>> references; + map<YulString, set<YulString>> referencedBy; + m_value.swap(value); + m_references.swap(references); + m_referencedBy.swap(referencedBy); pushScope(true); + for (auto const& parameter: _fun.parameters) m_variableScopes.back().variables.emplace(parameter.name); for (auto const& var: _fun.returnVariables) m_variableScopes.back().variables.emplace(var.name); ASTModifier::operator()(_fun); + popScope(); + m_value.swap(value); + m_references.swap(references); + m_referencedBy.swap(referencedBy); } void DataFlowAnalyzer::operator()(ForLoop& _for) |