| 1179 | } |
| 1180 | |
| 1181 | static void valueFlowEnumValue(SymbolDatabase & symboldatabase, const Settings & settings) |
| 1182 | { |
| 1183 | for (Scope & scope : symboldatabase.scopeList) { |
| 1184 | if (scope.type != ScopeType::eEnum) |
| 1185 | continue; |
| 1186 | MathLib::bigint value = 0; |
| 1187 | bool prev_enum_is_known = true; |
| 1188 | |
| 1189 | for (Enumerator & enumerator : scope.enumeratorList) { |
| 1190 | if (enumerator.start) { |
| 1191 | auto* rhs = const_cast<Token*>(enumerator.start->previous()->astOperand2()); |
| 1192 | ValueFlow::valueFlowConstantFoldAST(rhs, settings); |
| 1193 | if (rhs && rhs->hasKnownIntValue()) { |
| 1194 | enumerator.value = rhs->getKnownIntValue(); |
| 1195 | enumerator.value_known = true; |
| 1196 | value = enumerator.value + 1; |
| 1197 | prev_enum_is_known = true; |
| 1198 | } else |
| 1199 | prev_enum_is_known = false; |
| 1200 | } else if (prev_enum_is_known) { |
| 1201 | enumerator.value = value++; |
| 1202 | enumerator.value_known = true; |
| 1203 | } |
| 1204 | } |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | // trampoline to generate unique timer results entry |
| 1209 | static void valueFlowEnumValueEarly(SymbolDatabase & symboldatabase, const Settings & settings) |
no test coverage detected