@@ -137,8 +137,7 @@ void BMC::endVisit(ContractDefinition const& _contract)
137
137
inlineConstructorHierarchy (_contract);
138
138
popCallStack ();
139
139
// / Check targets created by state variable initialization.
140
- smtutil::Expression constraints = m_context.assertions ();
141
- checkVerificationTargets (constraints);
140
+ checkVerificationTargets ();
142
141
m_verificationTargets.clear ();
143
142
}
144
143
@@ -175,8 +174,7 @@ void BMC::endVisit(FunctionDefinition const& _function)
175
174
{
176
175
if (isRootFunction ())
177
176
{
178
- smtutil::Expression constraints = m_context.assertions ();
179
- checkVerificationTargets (constraints);
177
+ checkVerificationTargets ();
180
178
m_verificationTargets.clear ();
181
179
m_pathConditions.clear ();
182
180
}
@@ -534,6 +532,7 @@ pair<smtutil::Expression, smtutil::Expression> BMC::arithmeticOperation(
534
532
Expression const & _expression
535
533
)
536
534
{
535
+ // Unchecked does not disable div by 0 checks.
537
536
if (_op == Token::Div || _op == Token::Mod)
538
537
addVerificationTarget (
539
538
VerificationTarget::Type::DivByZero,
@@ -543,6 +542,9 @@ pair<smtutil::Expression, smtutil::Expression> BMC::arithmeticOperation(
543
542
544
543
auto values = SMTEncoder::arithmeticOperation (_op, _left, _right, _commonType, _expression);
545
544
545
+ if (!m_checked)
546
+ return values;
547
+
546
548
auto const * intType = dynamic_cast <IntegerType const *>(_commonType);
547
549
if (!intType)
548
550
intType = TypeProvider::uint256 ();
@@ -625,28 +627,28 @@ pair<vector<smtutil::Expression>, vector<string>> BMC::modelExpressions()
625
627
626
628
// / Verification targets.
627
629
628
- void BMC::checkVerificationTargets (smtutil::Expression const & _constraints )
630
+ void BMC::checkVerificationTargets ()
629
631
{
630
632
for (auto & target: m_verificationTargets)
631
- checkVerificationTarget (target, _constraints );
633
+ checkVerificationTarget (target);
632
634
}
633
635
634
- void BMC::checkVerificationTarget (BMCVerificationTarget& _target, smtutil::Expression const & _constraints )
636
+ void BMC::checkVerificationTarget (BMCVerificationTarget& _target)
635
637
{
636
638
switch (_target.type )
637
639
{
638
640
case VerificationTarget::Type::ConstantCondition:
639
641
checkConstantCondition (_target);
640
642
break ;
641
643
case VerificationTarget::Type::Underflow:
642
- checkUnderflow (_target, _constraints );
644
+ checkUnderflow (_target);
643
645
break ;
644
646
case VerificationTarget::Type::Overflow:
645
- checkOverflow (_target, _constraints );
647
+ checkOverflow (_target);
646
648
break ;
647
649
case VerificationTarget::Type::UnderOverflow:
648
- checkUnderflow (_target, _constraints );
649
- checkOverflow (_target, _constraints );
650
+ checkUnderflow (_target);
651
+ checkOverflow (_target);
650
652
break ;
651
653
case VerificationTarget::Type::DivByZero:
652
654
checkDivByZero (_target);
@@ -672,7 +674,7 @@ void BMC::checkConstantCondition(BMCVerificationTarget& _target)
672
674
);
673
675
}
674
676
675
- void BMC::checkUnderflow (BMCVerificationTarget& _target, smtutil::Expression const & _constraints )
677
+ void BMC::checkUnderflow (BMCVerificationTarget& _target)
676
678
{
677
679
solAssert (
678
680
_target.type == VerificationTarget::Type::Underflow ||
@@ -693,7 +695,7 @@ void BMC::checkUnderflow(BMCVerificationTarget& _target, smtutil::Expression con
693
695
intType = TypeProvider::uint256 ();
694
696
695
697
checkCondition (
696
- _target.constraints && _constraints && _target.value < smt::minValue (*intType),
698
+ _target.constraints && _target.value < smt::minValue (*intType),
697
699
_target.callStack ,
698
700
_target.modelExpressions ,
699
701
_target.expression ->location (),
@@ -705,7 +707,7 @@ void BMC::checkUnderflow(BMCVerificationTarget& _target, smtutil::Expression con
705
707
);
706
708
}
707
709
708
- void BMC::checkOverflow (BMCVerificationTarget& _target, smtutil::Expression const & _constraints )
710
+ void BMC::checkOverflow (BMCVerificationTarget& _target)
709
711
{
710
712
solAssert (
711
713
_target.type == VerificationTarget::Type::Overflow ||
@@ -726,7 +728,7 @@ void BMC::checkOverflow(BMCVerificationTarget& _target, smtutil::Expression cons
726
728
intType = TypeProvider::uint256 ();
727
729
728
730
checkCondition (
729
- _target.constraints && _constraints && _target.value > smt::maxValue (*intType),
731
+ _target.constraints && _target.value > smt::maxValue (*intType),
730
732
_target.callStack ,
731
733
_target.modelExpressions ,
732
734
_target.expression ->location (),
0 commit comments