mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Implement support for memory allocation
This commit is contained in:
@@ -663,6 +663,9 @@ void SMTEncoder::endVisit(FunctionCall const& _funCall)
|
||||
case FunctionType::Kind::Event:
|
||||
// These can be safely ignored.
|
||||
break;
|
||||
case FunctionType::Kind::ObjectCreation:
|
||||
visitObjectCreation(_funCall);
|
||||
return;
|
||||
default:
|
||||
m_errorReporter.warning(
|
||||
4588_error,
|
||||
@@ -735,6 +738,25 @@ void SMTEncoder::visitGasLeft(FunctionCall const& _funCall)
|
||||
m_context.addAssertion(symbolicVar->currentValue() <= symbolicVar->valueAtIndex(index - 1));
|
||||
}
|
||||
|
||||
void SMTEncoder::visitObjectCreation(FunctionCall const& _funCall)
|
||||
{
|
||||
auto const& args = _funCall.arguments();
|
||||
solAssert(args.size() >= 1, "");
|
||||
auto argType = args.front()->annotation().type->category();
|
||||
solAssert(argType == Type::Category::Integer || argType == Type::Category::RationalNumber, "");
|
||||
|
||||
smtutil::Expression arraySize = expr(*args.front());
|
||||
setSymbolicUnknownValue(arraySize, TypeProvider::uint256(), m_context);
|
||||
|
||||
auto symbArray = dynamic_pointer_cast<smt::SymbolicArrayVariable>(m_context.expression(_funCall));
|
||||
solAssert(symbArray, "");
|
||||
smt::setSymbolicZeroValue(*symbArray, m_context);
|
||||
auto zeroElements = symbArray->elements();
|
||||
symbArray->increaseIndex();
|
||||
m_context.addAssertion(symbArray->length() == arraySize);
|
||||
m_context.addAssertion(symbArray->elements() == zeroElements);
|
||||
}
|
||||
|
||||
void SMTEncoder::endVisit(Identifier const& _identifier)
|
||||
{
|
||||
if (auto decl = identifierToVariable(_identifier))
|
||||
|
||||
@@ -137,6 +137,7 @@ protected:
|
||||
void visitAssert(FunctionCall const& _funCall);
|
||||
void visitRequire(FunctionCall const& _funCall);
|
||||
void visitGasLeft(FunctionCall const& _funCall);
|
||||
void visitObjectCreation(FunctionCall const& _funCall);
|
||||
void visitTypeConversion(FunctionCall const& _funCall);
|
||||
void visitFunctionIdentifier(Identifier const& _identifier);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user