[SMTChecker] New VariableUsage flag to inline functions

This commit is contained in:
Leonardo Alt 2019-07-08 11:15:15 +02:00
parent 035fde2932
commit 96b0c4c148
3 changed files with 10 additions and 4 deletions

View File

@ -50,6 +50,7 @@ void BMC::analyze(SourceUnit const& _source, shared_ptr<Scanner> const& _scanner
m_scanner = _scanner;
m_context.clear();
m_variableUsage.setFunctionInlining(true);
_source.accept(*this);

View File

@ -57,10 +57,10 @@ void VariableUsage::endVisit(IndexAccess const& _indexAccess)
void VariableUsage::endVisit(FunctionCall const& _funCall)
{
/// TODO this should run only in the BMC case, not for Horn.
if (auto const& funDef = BMC::inlinedFunctionCallToDefinition(_funCall))
if (find(m_callStack.begin(), m_callStack.end(), funDef) == m_callStack.end())
funDef->accept(*this);
if (m_inlineFunctionCalls)
if (auto const& funDef = BMC::inlinedFunctionCallToDefinition(_funCall))
if (find(m_callStack.begin(), m_callStack.end(), funDef) == m_callStack.end())
funDef->accept(*this);
}
bool VariableUsage::visit(FunctionDefinition const& _function)

View File

@ -38,6 +38,9 @@ public:
/// @param _outerCallstack the current callstack in the callers context.
std::set<VariableDeclaration const*> touchedVariables(ASTNode const& _node, std::vector<CallableDeclaration const*> const& _outerCallstack);
/// Sets whether to inline function calls.
void setFunctionInlining(bool _inlineFunction) { m_inlineFunctionCalls = _inlineFunction; }
private:
void endVisit(Identifier const& _node) override;
void endVisit(IndexAccess const& _node) override;
@ -53,6 +56,8 @@ private:
std::set<VariableDeclaration const*> m_touchedVariables;
std::vector<CallableDeclaration const*> m_callStack;
CallableDeclaration const* m_lastCall = nullptr;
bool m_inlineFunctionCalls = false;
};
}