Refactorization: Reordered some conditions in checktype.cpp

This commit is contained in:
PKEuS 2016-02-05 19:48:30 +01:00 committed by PKEuS
parent 6215a48dc9
commit 4b3feebbcd
1 changed files with 8 additions and 8 deletions

View File

@ -58,10 +58,10 @@ void CheckType::checkTooBigBitwiseShift()
if (_tokenizer->isCPP() && Token::Match(tok, "[;{}] %name% (") && Token::simpleMatch(tok->linkAt(2), ") ;") && tok->next()->isUpperCaseName() && !tok->next()->function())
tok = tok->linkAt(2);
if (!Token::Match(tok, "<<|>>|<<=|>>="))
if (!tok->astOperand1() || !tok->astOperand2())
continue;
if (!tok->astOperand1() || !tok->astOperand2())
if (!Token::Match(tok, "<<|>>|<<=|>>="))
continue;
// get number of bits of lhs
@ -125,16 +125,16 @@ void CheckType::checkIntegerOverflow()
if (!tok->isArithmeticalOp())
continue;
// is result signed integer?
const ValueType *vt = tok->valueType();
if (!vt || vt->type != ValueType::Type::INT || vt->sign != ValueType::Sign::SIGNED)
continue;
// is there a overflow result value
const ValueFlow::Value *value = tok->getValueGE(maxint + 1, _settings);
if (!value)
value = tok->getValueLE(-maxint - 2, _settings);
if (!value)
continue;
// is result signed integer?
const ValueType *vt = tok->valueType();
if (vt && vt->type == ValueType::Type::INT && vt->sign == ValueType::Sign::SIGNED)
if (value)
integerOverflowError(tok, *value);
}
}