|
105 | 105 | #include "valueptr.h" |
106 | 106 | #include "vfvalue.h" |
107 | 107 |
|
| 108 | +#include "vf_analyze.h" |
| 109 | + |
108 | 110 | #include <algorithm> |
109 | 111 | #include <array> |
110 | 112 | #include <cassert> |
@@ -2030,33 +2032,6 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett |
2030 | 2032 | } |
2031 | 2033 | } |
2032 | 2034 |
|
2033 | | -static void valueFlowEnumValue(SymbolDatabase & symboldatabase, const Settings & settings) |
2034 | | -{ |
2035 | | - for (Scope & scope : symboldatabase.scopeList) { |
2036 | | - if (scope.type != Scope::eEnum) |
2037 | | - continue; |
2038 | | - MathLib::bigint value = 0; |
2039 | | - bool prev_enum_is_known = true; |
2040 | | - |
2041 | | - for (Enumerator & enumerator : scope.enumeratorList) { |
2042 | | - if (enumerator.start) { |
2043 | | - Token* rhs = const_cast<Token*>(enumerator.start->previous()->astOperand2()); |
2044 | | - ValueFlow::valueFlowConstantFoldAST(rhs, settings); |
2045 | | - if (rhs && rhs->hasKnownIntValue()) { |
2046 | | - enumerator.value = rhs->values().front().intvalue; |
2047 | | - enumerator.value_known = true; |
2048 | | - value = enumerator.value + 1; |
2049 | | - prev_enum_is_known = true; |
2050 | | - } else |
2051 | | - prev_enum_is_known = false; |
2052 | | - } else if (prev_enum_is_known) { |
2053 | | - enumerator.value = value++; |
2054 | | - enumerator.value_known = true; |
2055 | | - } |
2056 | | - } |
2057 | | - } |
2058 | | -} |
2059 | | - |
2060 | 2035 | static void valueFlowGlobalConstVar(TokenList& tokenList, const Settings &settings) |
2061 | 2036 | { |
2062 | 2037 | // Get variable values... |
@@ -9607,13 +9582,13 @@ void ValueFlow::setValues(TokenList& tokenlist, |
9607 | 9582 |
|
9608 | 9583 | ValueFlowPassRunner runner{ValueFlowState{tokenlist, symboldatabase, errorLogger, settings}, timerResults}; |
9609 | 9584 | runner.run_once({ |
9610 | | - VFA(valueFlowEnumValue(symboldatabase, settings)), |
| 9585 | + VFA(analyzeEnumValue(symboldatabase, settings)), |
9611 | 9586 | VFA(valueFlowNumber(tokenlist, settings)), |
9612 | 9587 | VFA(valueFlowString(tokenlist, settings)), |
9613 | 9588 | VFA(valueFlowArray(tokenlist, settings)), |
9614 | 9589 | VFA(valueFlowUnknownFunctionReturn(tokenlist, settings)), |
9615 | 9590 | VFA(valueFlowGlobalConstVar(tokenlist, settings)), |
9616 | | - VFA(valueFlowEnumValue(symboldatabase, settings)), |
| 9591 | + VFA(analyzeEnumValue(symboldatabase, settings)), |
9617 | 9592 | VFA(valueFlowGlobalStaticVar(tokenlist, settings)), |
9618 | 9593 | VFA(valueFlowPointerAlias(tokenlist, settings)), |
9619 | 9594 | VFA(valueFlowLifetime(tokenlist, errorLogger, settings)), |
|
0 commit comments