|
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> |
|
122 | 124 | #include <numeric> |
123 | 125 | #include <set> |
124 | 126 | #include <sstream> |
| 127 | +#include <stdexcept> |
125 | 128 | #include <string> |
126 | 129 | #include <type_traits> |
127 | 130 | #include <unordered_map> |
@@ -2045,33 +2048,6 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett |
2045 | 2048 | } |
2046 | 2049 | } |
2047 | 2050 |
|
2048 | | -static void valueFlowEnumValue(SymbolDatabase & symboldatabase, const Settings & settings) |
2049 | | -{ |
2050 | | - for (Scope & scope : symboldatabase.scopeList) { |
2051 | | - if (scope.type != Scope::eEnum) |
2052 | | - continue; |
2053 | | - MathLib::bigint value = 0; |
2054 | | - bool prev_enum_is_known = true; |
2055 | | - |
2056 | | - for (Enumerator & enumerator : scope.enumeratorList) { |
2057 | | - if (enumerator.start) { |
2058 | | - auto* rhs = const_cast<Token*>(enumerator.start->previous()->astOperand2()); |
2059 | | - ValueFlow::valueFlowConstantFoldAST(rhs, settings); |
2060 | | - if (rhs && rhs->hasKnownIntValue()) { |
2061 | | - enumerator.value = rhs->values().front().intvalue; |
2062 | | - enumerator.value_known = true; |
2063 | | - value = enumerator.value + 1; |
2064 | | - prev_enum_is_known = true; |
2065 | | - } else |
2066 | | - prev_enum_is_known = false; |
2067 | | - } else if (prev_enum_is_known) { |
2068 | | - enumerator.value = value++; |
2069 | | - enumerator.value_known = true; |
2070 | | - } |
2071 | | - } |
2072 | | - } |
2073 | | -} |
2074 | | - |
2075 | 2051 | static void valueFlowGlobalConstVar(TokenList& tokenList, const Settings &settings) |
2076 | 2052 | { |
2077 | 2053 | // Get variable values... |
@@ -9654,13 +9630,13 @@ void ValueFlow::setValues(TokenList& tokenlist, |
9654 | 9630 |
|
9655 | 9631 | ValueFlowPassRunner runner{ValueFlowState{tokenlist, symboldatabase, errorLogger, settings}, timerResults}; |
9656 | 9632 | runner.run_once({ |
9657 | | - VFA(valueFlowEnumValue(symboldatabase, settings)), |
| 9633 | + VFA(analyzeEnumValue(symboldatabase, settings)), |
9658 | 9634 | VFA(valueFlowNumber(tokenlist, settings)), |
9659 | 9635 | VFA(valueFlowString(tokenlist, settings)), |
9660 | 9636 | VFA(valueFlowArray(tokenlist, settings)), |
9661 | 9637 | VFA(valueFlowUnknownFunctionReturn(tokenlist, settings)), |
9662 | 9638 | VFA(valueFlowGlobalConstVar(tokenlist, settings)), |
9663 | | - VFA(valueFlowEnumValue(symboldatabase, settings)), |
| 9639 | + VFA(analyzeEnumValue(symboldatabase, settings)), |
9664 | 9640 | VFA(valueFlowGlobalStaticVar(tokenlist, settings)), |
9665 | 9641 | VFA(valueFlowPointerAlias(tokenlist, settings)), |
9666 | 9642 | VFA(valueFlowLifetime(tokenlist, errorLogger, settings)), |
|
0 commit comments