From cba11e623ea7d5dc9ddcb610395565a4eb3f2626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 11 Oct 2015 14:11:11 +0200 Subject: [PATCH] Use ValueType in astIsIntegral() --- lib/astutils.cpp | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) 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)