From b2b11eaa00de3174ead7dbeb77bbc315719bd79d Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 28 Oct 2018 12:57:13 +0100 Subject: Fix data flow analyzer for function definitions. --- libyul/optimiser/DataFlowAnalyzer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libyul/optimiser') 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 value; + map> references; + map> 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) -- cgit