| 8479 | |
| 8480 | template<class F> |
| 8481 | static Result accumulateStructMembers(const Scope* scope, F f, ValueType::Accuracy accuracy) |
| 8482 | { |
| 8483 | size_t total = 0; |
| 8484 | std::set<const Scope*> anonScopes; |
| 8485 | for (const Variable& var : scope->varlist) { |
| 8486 | if (var.isStatic()) |
| 8487 | continue; |
| 8488 | const MathLib::bigint bits = var.nameToken() ? var.nameToken()->bits() : -1; |
| 8489 | if (const ValueType* vt = var.valueType()) { |
| 8490 | if (vt->type == ValueType::Type::RECORD && vt->typeScope == scope) |
| 8491 | return {0, false}; |
| 8492 | const MathLib::bigint dim = std::accumulate(var.dimensions().cbegin(), var.dimensions().cend(), MathLib::bigint(1), [](MathLib::bigint i1, const Dimension& dim) { |
| 8493 | return i1 * dim.num; |
| 8494 | }); |
| 8495 | if (var.nameToken()->scope() != scope && var.nameToken()->scope()->definedType) { // anonymous union |
| 8496 | const auto ret = anonScopes.insert(var.nameToken()->scope()); |
| 8497 | if (ret.second) |
| 8498 | total = f(total, *vt, dim, bits); |
| 8499 | } |
| 8500 | else |
| 8501 | total = f(total, *vt, dim, bits); |
| 8502 | } |
| 8503 | if (accuracy == ValueType::Accuracy::ExactOrZero && total == 0 && bits == -1) |
| 8504 | return {0, false}; |
| 8505 | } |
| 8506 | return {total, true}; |
| 8507 | } |
| 8508 | |
| 8509 | |
| 8510 | static size_t bitCeil(size_t x) |
no test coverage detected