Refactoring; use range for loop
This commit is contained in:
parent
4d52949be6
commit
435888f82e
|
@ -293,9 +293,7 @@ void CheckType::checkLongCast()
|
||||||
|
|
||||||
// Return..
|
// Return..
|
||||||
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
for (const Scope * scope : symbolDatabase->functionScopes) {
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
|
||||||
|
|
||||||
// function must return long data
|
// function must return long data
|
||||||
const Token * def = scope->classDef;
|
const Token * def = scope->classDef;
|
||||||
|
@ -385,15 +383,15 @@ void CheckType::checkFloatToIntegerOverflow()
|
||||||
if (!vtfloat || !vtfloat->isFloat())
|
if (!vtfloat || !vtfloat->isFloat())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (std::list<ValueFlow::Value>::const_iterator it = floatValues->begin(); it != floatValues->end(); ++it) {
|
for (const ValueFlow::Value &f : *floatValues) {
|
||||||
if (it->valueType != ValueFlow::Value::FLOAT)
|
if (f.valueType != ValueFlow::Value::FLOAT)
|
||||||
continue;
|
continue;
|
||||||
if (!mSettings->isEnabled(&(*it), false))
|
if (!mSettings->isEnabled(&f, false))
|
||||||
continue;
|
continue;
|
||||||
if (it->floatValue > ~0ULL)
|
if (f.floatValue > ~0ULL)
|
||||||
floatToIntegerOverflowError(tok, *it);
|
floatToIntegerOverflowError(tok, f);
|
||||||
else if ((-it->floatValue) > (1ULL<<62))
|
else if ((-f.floatValue) > (1ULL<<62))
|
||||||
floatToIntegerOverflowError(tok, *it);
|
floatToIntegerOverflowError(tok, f);
|
||||||
else if (mSettings->platformType != Settings::Unspecified) {
|
else if (mSettings->platformType != Settings::Unspecified) {
|
||||||
int bits = 0;
|
int bits = 0;
|
||||||
if (vtint->type == ValueType::Type::CHAR)
|
if (vtint->type == ValueType::Type::CHAR)
|
||||||
|
@ -408,8 +406,8 @@ void CheckType::checkFloatToIntegerOverflow()
|
||||||
bits = mSettings->long_long_bit;
|
bits = mSettings->long_long_bit;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
if (bits < MathLib::bigint_bits && it->floatValue >= (((MathLib::biguint)1) << bits))
|
if (bits < MathLib::bigint_bits && f.floatValue >= (((MathLib::biguint)1) << bits))
|
||||||
floatToIntegerOverflowError(tok, *it);
|
floatToIntegerOverflowError(tok, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue