| 1039 | } |
| 1040 | |
| 1041 | bool updateScope(const Token* endBlock, bool /*modified*/) const override { |
| 1042 | const Scope* scope = endBlock->scope(); |
| 1043 | if (!scope) |
| 1044 | return false; |
| 1045 | if (scope->type == ScopeType::eLambda) { |
| 1046 | return std::all_of(values.cbegin(), values.cend(), [](const std::pair<nonneg int, ValueFlow::Value>& p) { |
| 1047 | return p.second.isLifetimeValue(); |
| 1048 | }); |
| 1049 | } |
| 1050 | if (scope->type == ScopeType::eIf || scope->type == ScopeType::eElse || scope->type == ScopeType::eWhile || |
| 1051 | scope->type == ScopeType::eFor) { |
| 1052 | auto pred = [](const ValueFlow::Value& value) { |
| 1053 | if (value.isKnown()) |
| 1054 | return true; |
| 1055 | if (value.isImpossible()) |
| 1056 | return true; |
| 1057 | if (value.isLifetimeValue()) |
| 1058 | return true; |
| 1059 | return false; |
| 1060 | }; |
| 1061 | if (std::all_of(values.cbegin(), values.cend(), std::bind(pred, std::bind(SelectMapValues{}, std::placeholders::_1)))) |
| 1062 | return true; |
| 1063 | if (isConditional()) |
| 1064 | return false; |
| 1065 | const Token* condTok = getCondTokFromEnd(endBlock); |
| 1066 | std::set<nonneg int> varids; |
| 1067 | std::transform(getVars().cbegin(), getVars().cend(), std::inserter(varids, varids.begin()), SelectMapKeys{}); |
| 1068 | return bifurcate(condTok, varids, getSettings()); |
| 1069 | } |
| 1070 | |
| 1071 | return false; |
| 1072 | } |
| 1073 | |
| 1074 | bool match(const Token* tok) const override { |
| 1075 | return values.count(tok->varId()) > 0; |
no test coverage detected