aboutsummaryrefslogtreecommitdiffstats
path: root/libyul
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-08 19:52:51 +0800
committerGitHub <noreply@github.com>2018-11-08 19:52:51 +0800
commitcd11f7cfacc88485584ebdd8fc4beccbcaf550fe (patch)
tree22817a0c53cd48efdd816dd251762399d913ff57 /libyul
parentb801e616118a06b4cc1f2e73a9ddecc5d585b827 (diff)
parentb2b11eaa00de3174ead7dbeb77bbc315719bd79d (diff)
downloaddexon-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.cpp13
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)