diff --git a/lib/astutils.cpp b/lib/astutils.cpp index e51433dca..90748fccc 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -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)