|
102 | 102 | #include "valueptr.h" |
103 | 103 | #include "vfvalue.h" |
104 | 104 |
|
| 105 | +#include "vf/enumvalue.h" |
| 106 | + |
105 | 107 | #include <algorithm> |
106 | 108 | #include <array> |
107 | 109 | #include <cassert> |
@@ -1862,34 +1864,6 @@ static void valueFlowImpossibleValues(TokenList* tokenList, const Settings* sett |
1862 | 1864 | } |
1863 | 1865 | } |
1864 | 1866 |
|
1865 | | -static void valueFlowEnumValue(SymbolDatabase * symboldatabase, const Settings * settings) |
1866 | | -{ |
1867 | | - |
1868 | | - for (Scope & scope : symboldatabase->scopeList) { |
1869 | | - if (scope.type != Scope::eEnum) |
1870 | | - continue; |
1871 | | - MathLib::bigint value = 0; |
1872 | | - bool prev_enum_is_known = true; |
1873 | | - |
1874 | | - for (Enumerator & enumerator : scope.enumeratorList) { |
1875 | | - if (enumerator.start) { |
1876 | | - Token *rhs = enumerator.start->previous()->astOperand2(); |
1877 | | - ValueFlow::valueFlowConstantFoldAST(rhs, settings); |
1878 | | - if (rhs && rhs->hasKnownIntValue()) { |
1879 | | - enumerator.value = rhs->values().front().intvalue; |
1880 | | - enumerator.value_known = true; |
1881 | | - value = enumerator.value + 1; |
1882 | | - prev_enum_is_known = true; |
1883 | | - } else |
1884 | | - prev_enum_is_known = false; |
1885 | | - } else if (prev_enum_is_known) { |
1886 | | - enumerator.value = value++; |
1887 | | - enumerator.value_known = true; |
1888 | | - } |
1889 | | - } |
1890 | | - } |
1891 | | -} |
1892 | | - |
1893 | 1867 | static void valueFlowGlobalConstVar(TokenList* tokenList, const Settings *settings) |
1894 | 1868 | { |
1895 | 1869 | // Get variable values... |
@@ -8835,13 +8809,13 @@ void ValueFlow::setValues(TokenList *tokenlist, SymbolDatabase* symboldatabase, |
8835 | 8809 | for (Token *tok = tokenlist->front(); tok; tok = tok->next()) |
8836 | 8810 | tok->clearValueFlow(); |
8837 | 8811 |
|
8838 | | - valueFlowEnumValue(symboldatabase, settings); |
| 8812 | + ValueFlow::enumValue(symboldatabase, settings); |
8839 | 8813 | valueFlowNumber(tokenlist); |
8840 | 8814 | valueFlowString(tokenlist); |
8841 | 8815 | valueFlowArray(tokenlist); |
8842 | 8816 | valueFlowUnknownFunctionReturn(tokenlist, settings); |
8843 | 8817 | valueFlowGlobalConstVar(tokenlist, settings); |
8844 | | - valueFlowEnumValue(symboldatabase, settings); |
| 8818 | + ValueFlow::enumValue(symboldatabase, settings); |
8845 | 8819 | valueFlowNumber(tokenlist); |
8846 | 8820 | valueFlowGlobalStaticVar(tokenlist, settings); |
8847 | 8821 | valueFlowPointerAlias(tokenlist); |
|
0 commit comments