|
103 | 103 | #include "vfvalue.h" |
104 | 104 |
|
105 | 105 | #include "vf/enumvalue.h" |
| 106 | +#include "vf/number.h" |
106 | 107 |
|
107 | 108 | #include <algorithm> |
108 | 109 | #include <array> |
@@ -576,10 +577,10 @@ static ValueFlow::Value truncateImplicitConversion(Token* parent, const ValueFlo |
576 | 577 | } |
577 | 578 |
|
578 | 579 | /** set ValueFlow value and perform calculations if possible */ |
579 | | -static void setTokenValue(Token* tok, |
580 | | - ValueFlow::Value value, |
581 | | - const Settings* settings, |
582 | | - SourceLocation loc = SourceLocation::current()) |
| 580 | +void ValueFlow::setTokenValue(Token* tok, |
| 581 | + ValueFlow::Value value, |
| 582 | + const Settings* settings, |
| 583 | + SourceLocation loc) |
583 | 584 | { |
584 | 585 | // Skip setting values that are too big since its ambiguous |
585 | 586 | if (!value.isImpossible() && value.isIntValue() && value.intvalue < 0 && astIsUnsigned(tok) && |
@@ -1090,7 +1091,7 @@ size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings *settings) |
1090 | 1091 | static bool getMinMaxValues(const ValueType* vt, const cppcheck::Platform& platform, MathLib::bigint* minValue, MathLib::bigint* maxValue); |
1091 | 1092 |
|
1092 | 1093 | // Handle various constants.. |
1093 | | -static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, bool cpp) |
| 1094 | +Token * ValueFlow::valueFlowSetConstantValue(Token *tok, const Settings *settings, bool cpp) |
1094 | 1095 | { |
1095 | 1096 | if ((tok->isNumber() && MathLib::isInt(tok->str())) || (tok->tokType() == Token::eChar)) { |
1096 | 1097 | try { |
@@ -1290,31 +1291,6 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b |
1290 | 1291 | return tok->next(); |
1291 | 1292 | } |
1292 | 1293 |
|
1293 | | -static void valueFlowNumber(TokenList *tokenlist) |
1294 | | -{ |
1295 | | - for (Token *tok = tokenlist->front(); tok;) { |
1296 | | - tok = valueFlowSetConstantValue(tok, tokenlist->getSettings(), tokenlist->isCPP()); |
1297 | | - } |
1298 | | - |
1299 | | - if (tokenlist->isCPP()) { |
1300 | | - for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { |
1301 | | - if (tok->isName() && !tok->varId() && Token::Match(tok, "false|true")) { |
1302 | | - ValueFlow::Value value(tok->str() == "true"); |
1303 | | - if (!tok->isTemplateArg()) |
1304 | | - value.setKnown(); |
1305 | | - setTokenValue(tok, value, tokenlist->getSettings()); |
1306 | | - } else if (Token::Match(tok, "[(,] NULL [,)]")) { |
1307 | | - // NULL function parameters are not simplified in the |
1308 | | - // normal tokenlist |
1309 | | - ValueFlow::Value value(0); |
1310 | | - if (!tok->isTemplateArg()) |
1311 | | - value.setKnown(); |
1312 | | - setTokenValue(tok->next(), value, tokenlist->getSettings()); |
1313 | | - } |
1314 | | - } |
1315 | | - } |
1316 | | -} |
1317 | | - |
1318 | 1294 | static void valueFlowString(TokenList *tokenlist) |
1319 | 1295 | { |
1320 | 1296 | for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { |
@@ -8810,13 +8786,13 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase, |
8810 | 8786 | tok->clearValueFlow(); |
8811 | 8787 |
|
8812 | 8788 | ValueFlow::enumValue(symboldatabase, settings); |
8813 | | - valueFlowNumber(tokenlist); |
| 8789 | + ValueFlow::number(tokenlist); |
8814 | 8790 | valueFlowString(tokenlist); |
8815 | 8791 | valueFlowArray(tokenlist); |
8816 | 8792 | valueFlowUnknownFunctionReturn(tokenlist, settings); |
8817 | 8793 | valueFlowGlobalConstVar(tokenlist, settings); |
8818 | 8794 | ValueFlow::enumValue(symboldatabase, settings); |
8819 | | - valueFlowNumber(tokenlist); |
| 8795 | + ValueFlow::number(tokenlist); |
8820 | 8796 | valueFlowGlobalStaticVar(tokenlist, settings); |
8821 | 8797 | valueFlowPointerAlias(tokenlist); |
8822 | 8798 | valueFlowLifetime(tokenlist, symboldatabase, errorLogger, settings); |
|
0 commit comments