Use ValueType in astIsIntegral()
This commit is contained in:
parent
be7bca385d
commit
cba11e623e
|
@ -31,42 +31,10 @@ bool astIsSignedChar(const Token *tok)
|
|||
|
||||
bool astIsIntegral(const Token *tok, bool unknown)
|
||||
{
|
||||
// TODO: handle arrays
|
||||
if (tok->isNumber())
|
||||
return MathLib::isInt(tok->str());
|
||||
|
||||
if (tok->isName()) {
|
||||
if (tok->variable())
|
||||
return tok->variable()->isIntegralType();
|
||||
|
||||
const ValueType *vt = tok ? tok->valueType() : nullptr;
|
||||
if (!vt)
|
||||
return unknown;
|
||||
}
|
||||
if (tok->str() == "(") {
|
||||
// cast
|
||||
if (Token::Match(tok, "( const| float|double )"))
|
||||
return false;
|
||||
|
||||
// Function call
|
||||
if (tok->previous() && tok->previous()->function()) {
|
||||
if (Token::Match(tok->previous()->function()->retDef, "float|double"))
|
||||
return false;
|
||||
else if (Token::Match(tok->previous()->function()->retDef, "bool|char|short|int|long"))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tok->strAt(-1) == "sizeof")
|
||||
return true;
|
||||
|
||||
return unknown;
|
||||
}
|
||||
|
||||
if (tok->astOperand2() && (tok->str() == "." || tok->str() == "::"))
|
||||
return astIsIntegral(tok->astOperand2(), unknown);
|
||||
|
||||
if (tok->astOperand1() && tok->str() != "?")
|
||||
return astIsIntegral(tok->astOperand1(), unknown);
|
||||
|
||||
return unknown;
|
||||
return vt->isIntegral() && vt->pointer == 0U;
|
||||
}
|
||||
|
||||
bool astIsFloat(const Token *tok, bool unknown)
|
||||
|
|
Loading…
Reference in New Issue