Some smaller issues found by Covertiy Scan

This commit is contained in:
Alex Beregszaszi 2017-08-22 13:55:28 +01:00
parent f38429fef8
commit f2d6226718
4 changed files with 6 additions and 6 deletions

View File

@ -220,6 +220,7 @@ void CSECodeGenerator::addDependencies(Id _c)
if (m_neededBy.count(_c)) if (m_neededBy.count(_c))
return; // we already computed the dependencies for _c return; // we already computed the dependencies for _c
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c); ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
assertThrow(expr.item, OptimizerException, "");
if (expr.item->type() == UndefinedItem) if (expr.item->type() == UndefinedItem)
BOOST_THROW_EXCEPTION( BOOST_THROW_EXCEPTION(
// If this exception happens, we need to find a different way to generate the // If this exception happens, we need to find a different way to generate the

View File

@ -147,7 +147,7 @@ private:
AssemblyItems m_generatedItems; AssemblyItems m_generatedItems;
/// Current height of the stack relative to the start. /// Current height of the stack relative to the start.
int m_stackHeight; int m_stackHeight = 0;
/// If (b, a) is in m_requests then b is needed to compute a. /// If (b, a) is in m_requests then b is needed to compute a.
std::multimap<Id, Id> m_neededBy; std::multimap<Id, Id> m_neededBy;
/// Current content of the stack. /// Current content of the stack.

View File

@ -188,7 +188,6 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::inter
{ {
if (!m_interfaceFunctionList) if (!m_interfaceFunctionList)
{ {
set<string> functionsSeen;
set<string> signaturesSeen; set<string> signaturesSeen;
m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, FunctionTypePointer>>()); m_interfaceFunctionList.reset(new vector<pair<FixedHash<4>, FunctionTypePointer>>());
for (ContractDefinition const* contract: annotation().linearizedBaseContracts) for (ContractDefinition const* contract: annotation().linearizedBaseContracts)

View File

@ -739,18 +739,18 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{ {
if (_convertTo.category() == Category::Integer) if (_convertTo.category() == Category::Integer)
{ {
auto targetType = dynamic_cast<IntegerType const*>(&_convertTo);
if (m_value == rational(0)) if (m_value == rational(0))
return true; return true;
if (isFractional()) if (isFractional())
return false; return false;
int forSignBit = (targetType->isSigned() ? 1 : 0); IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo);
int forSignBit = (targetType.isSigned() ? 1 : 0);
if (m_value > rational(0)) if (m_value > rational(0))
{ {
if (m_value.numerator() <= (u256(-1) >> (256 - targetType->numBits() + forSignBit))) if (m_value.numerator() <= (u256(-1) >> (256 - targetType.numBits() + forSignBit)))
return true; return true;
} }
else if (targetType->isSigned() && -m_value.numerator() <= (u256(1) << (targetType->numBits() - forSignBit))) else if (targetType.isSigned() && -m_value.numerator() <= (u256(1) << (targetType.numBits() - forSignBit)))
return true; return true;
return false; return false;
} }