Refactor CheckType::checkTooBigBitwiseShift. Use ValueType.
This commit is contained in:
parent
1de21a8356
commit
67435af06a
|
@ -131,19 +131,17 @@ void CheckType::checkTooBigBitwiseShift()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// get number of bits of lhs
|
// get number of bits of lhs
|
||||||
const Variable *var = tok->astOperand1()->variable();
|
const ValueType *lhstype = tok->astOperand1()->valueType();
|
||||||
if (!var)
|
if (!lhstype || !lhstype->isIntegral() || lhstype->pointer >= 1U)
|
||||||
continue;
|
continue;
|
||||||
int lhsbits = 0;
|
int lhsbits = 0;
|
||||||
for (const Token *type = var->typeStartToken(); type; type = type->next()) {
|
if (lhstype->type <= ValueType::Type::INT)
|
||||||
if (Token::Match(type,"char|short|int") && !type->isLong()) {
|
lhsbits = 8 * _settings->sizeof_int;
|
||||||
lhsbits = _settings->sizeof_int * 8;
|
else if (lhstype->type == ValueType::Type::LONG)
|
||||||
break;
|
lhsbits = 8 * _settings->sizeof_long;
|
||||||
}
|
else if (lhstype->type == ValueType::Type::LONGLONG)
|
||||||
if (type == var->typeEndToken() || type->str() == "<")
|
lhsbits = 8 * _settings->sizeof_long_long;
|
||||||
break;
|
else
|
||||||
}
|
|
||||||
if (lhsbits == 0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get biggest rhs value. preferably a value which doesn't have 'condition'.
|
// Get biggest rhs value. preferably a value which doesn't have 'condition'.
|
||||||
|
|
Loading…
Reference in New Issue