diff options
author | chriseth <chris@ethereum.org> | 2018-11-08 19:52:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-08 19:52:51 +0800 |
commit | cd11f7cfacc88485584ebdd8fc4beccbcaf550fe (patch) | |
tree | 22817a0c53cd48efdd816dd251762399d913ff57 /libyul | |
parent | b801e616118a06b4cc1f2e73a9ddecc5d585b827 (diff) | |
parent | b2b11eaa00de3174ead7dbeb77bbc315719bd79d (diff) | |
download | dexon-solidity-cd11f7cfacc88485584ebdd8fc4beccbcaf550fe.tar.gz dexon-solidity-cd11f7cfacc88485584ebdd8fc4beccbcaf550fe.tar.zst dexon-solidity-cd11f7cfacc88485584ebdd8fc4beccbcaf550fe.zip |
Merge pull request #5325 from ethereum/fixDataFlow
[Yul] Fix data flow analyzer for function definitions.
Diffstat (limited to 'libyul')
-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) |