@@ -107,7 +107,7 @@ void CheckCondition::assignIf()
107107
108108 if (Token::Match (tok->next (), " %num% [&|]" )) {
109109 bitop = tok->strAt (2 ).at (0 );
110- num = MathLib::toBigNumber (tok->strAt (1 ));
110+ num = MathLib::toBigNumber (tok->tokAt (1 ));
111111 } else {
112112 const Token *endToken = Token::findsimplematch (tok, " ;" );
113113
@@ -117,7 +117,7 @@ void CheckCondition::assignIf()
117117
118118 if (endToken && Token::Match (endToken->tokAt (-2 ), " [&|] %num% ;" )) {
119119 bitop = endToken->strAt (-2 ).at (0 );
120- num = MathLib::toBigNumber (endToken->strAt (-1 ));
120+ num = MathLib::toBigNumber (endToken->tokAt (-1 ));
121121 }
122122 }
123123
@@ -170,15 +170,15 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok,
170170
171171 for (const Token *tok2 = startTok; tok2; tok2 = tok2->next ()) {
172172 if ((bitop == ' &' ) && Token::Match (tok2->tokAt (2 ), " %varid% %cop% %num% ;" , varid) && tok2->strAt (3 ) == std::string (1U , bitop)) {
173- const MathLib::bigint num2 = MathLib::toBigNumber (tok2->strAt (4 ));
173+ const MathLib::bigint num2 = MathLib::toBigNumber (tok2->tokAt (4 ));
174174 if (0 == (num & num2))
175175 mismatchingBitAndError (assignTok, num, tok2, num2);
176176 }
177177 if (Token::Match (tok2, " %varid% =" , varid)) {
178178 return true ;
179179 }
180180 if (bitop == ' &' && Token::Match (tok2, " %varid% &= %num% ;" , varid)) {
181- const MathLib::bigint num2 = MathLib::toBigNumber (tok2->strAt (2 ));
181+ const MathLib::bigint num2 = MathLib::toBigNumber (tok2->tokAt (2 ));
182182 if (0 == (num & num2))
183183 mismatchingBitAndError (assignTok, num, tok2, num2);
184184 }
@@ -213,7 +213,7 @@ bool CheckCondition::assignIfParseScope(const Token * const assignTok,
213213 }
214214 if (Token::Match (tok2," &&|%oror%|( %varid% ==|!= %num% &&|%oror%|)" , varid)) {
215215 const Token *vartok = tok2->next ();
216- const MathLib::bigint num2 = MathLib::toBigNumber (vartok->strAt (2 ));
216+ const MathLib::bigint num2 = MathLib::toBigNumber (vartok->tokAt (2 ));
217217 if ((num & num2) != ((bitop==' &' ) ? num2 : num)) {
218218 const std::string& op (vartok->strAt (1 ));
219219 const bool alwaysTrue = op == " !=" ;
@@ -267,11 +267,11 @@ void CheckCondition::mismatchingBitAndError(const Token *tok1, const MathLib::bi
267267static void getnumchildren (const Token *tok, std::list<MathLib::bigint> &numchildren)
268268{
269269 if (tok->astOperand1 () && tok->astOperand1 ()->isNumber ())
270- numchildren.push_back (MathLib::toBigNumber (tok->astOperand1 ()-> str () ));
270+ numchildren.push_back (MathLib::toBigNumber (tok->astOperand1 ()));
271271 else if (tok->astOperand1 () && tok->str () == tok->astOperand1 ()->str ())
272272 getnumchildren (tok->astOperand1 (), numchildren);
273273 if (tok->astOperand2 () && tok->astOperand2 ()->isNumber ())
274- numchildren.push_back (MathLib::toBigNumber (tok->astOperand2 ()-> str () ));
274+ numchildren.push_back (MathLib::toBigNumber (tok->astOperand2 ()));
275275 else if (tok->astOperand2 () && tok->str () == tok->astOperand2 ()->str ())
276276 getnumchildren (tok->astOperand2 (), numchildren);
277277}
@@ -464,8 +464,8 @@ bool CheckCondition::isOverlappingCond(const Token * const cond1, const Token *
464464 if (!isSameExpression (true , expr1, expr2, *mSettings , pure, false ))
465465 return false ;
466466
467- const MathLib::bigint value1 = MathLib::toBigNumber (num1-> str () );
468- const MathLib::bigint value2 = MathLib::toBigNumber (num2-> str () );
467+ const MathLib::bigint value1 = MathLib::toBigNumber (num1);
468+ const MathLib::bigint value2 = MathLib::toBigNumber (num2);
469469 if (cond2->str () == " &" )
470470 return ((value1 & value2) == value2);
471471 return ((value1 & value2) > 0 );
@@ -1267,14 +1267,14 @@ void CheckCondition::checkIncorrectLogicOperator()
12671267 if (isfloat && (op1 == " ==" || op1 == " !=" || op2 == " ==" || op2 == " !=" ))
12681268 continue ;
12691269
1270-
1270+ // the expr are not the token of the value but they provide better context
12711271 const double d1 = (isfloat) ? MathLib::toDoubleNumber (value1) : 0 ;
12721272 const double d2 = (isfloat) ? MathLib::toDoubleNumber (value2) : 0 ;
1273- const MathLib::bigint i1 = (isfloat) ? 0 : MathLib::toBigNumber (value1);
1274- const MathLib::bigint i2 = (isfloat) ? 0 : MathLib::toBigNumber (value2);
1273+ const MathLib::bigint i1 = (isfloat) ? 0 : MathLib::toBigNumber (value1, expr1 );
1274+ const MathLib::bigint i2 = (isfloat) ? 0 : MathLib::toBigNumber (value2, expr2 );
12751275 const bool useUnsignedInt = (std::numeric_limits<MathLib::bigint>::max ()==i1) || (std::numeric_limits<MathLib::bigint>::max ()==i2);
1276- const MathLib::biguint u1 = (useUnsignedInt) ? MathLib::toBigUNumber (value1) : 0 ;
1277- const MathLib::biguint u2 = (useUnsignedInt) ? MathLib::toBigUNumber (value2) : 0 ;
1276+ const MathLib::biguint u1 = (useUnsignedInt) ? MathLib::toBigUNumber (value1, expr1 ) : 0 ;
1277+ const MathLib::biguint u2 = (useUnsignedInt) ? MathLib::toBigUNumber (value2, expr2 ) : 0 ;
12781278 // evaluate if expression is always true/false
12791279 bool alwaysTrue = true , alwaysFalse = true ;
12801280 bool firstTrue = true , secondTrue = true ;
0 commit comments