Skip to content

Commit 4399bcb

Browse files
author
Leo Alt
committed
Add errorCode list to invariants report
1 parent eec277b commit 4399bcb

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

libsolidity/formal/CHC.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,16 @@ void CHC::checkVerificationTargets()
17461746
for (auto const& inv: m_invariants.at(pred))
17471747
msg += inv + "\n";
17481748
}
1749+
if (msg.find("<errorCode>") != string::npos)
1750+
{
1751+
set<unsigned> seenErrors;
1752+
for (auto const& target: verificationTargets)
1753+
if (!seenErrors.count(target.errorId))
1754+
{
1755+
seenErrors.insert(target.errorId);
1756+
msg += "<errorCode> = " + to_string(target.errorId) + " -> " + ModelCheckerTargets::targetTypeToString.at(target.type) + "\n";
1757+
}
1758+
}
17491759
if (!msg.empty())
17501760
m_errorReporter.info(1180_error, msg);
17511761
}

libsolidity/formal/ModelCheckerSettings.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ map<string, TargetType> const ModelCheckerTargets::targetStrings{
7171
{"outOfBounds", TargetType::OutOfBounds}
7272
};
7373

74+
map<TargetType, string> const ModelCheckerTargets::targetTypeToString{
75+
{TargetType::ConstantCondition, "Constant condition"},
76+
{TargetType::Underflow, "Underflow"},
77+
{TargetType::Overflow, "Overflow"},
78+
{TargetType::DivByZero, "Division by zero"},
79+
{TargetType::Balance, "Insufficient balance"},
80+
{TargetType::Assert, "Assertion failed"},
81+
{TargetType::PopEmptyArray, "Empty array pop"},
82+
{TargetType::OutOfBounds, "Out of bounds access"}
83+
};
84+
7485
std::optional<ModelCheckerTargets> ModelCheckerTargets::fromString(string const& _targets)
7586
{
7687
set<TargetType> chosenTargets;

libsolidity/formal/ModelCheckerSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ struct ModelCheckerTargets
132132

133133
static std::map<std::string, VerificationTargetType> const targetStrings;
134134

135+
static std::map<VerificationTargetType, std::string> const targetTypeToString;
136+
135137
bool operator!=(ModelCheckerTargets const& _other) const noexcept { return !(*this == _other); }
136138
bool operator==(ModelCheckerTargets const& _other) const noexcept { return targets == _other.targets; }
137139

0 commit comments

Comments
 (0)