| 4261 | } |
| 4262 | |
| 4263 | static void valueFlowAfterSwap(const TokenList& tokenlist, |
| 4264 | const SymbolDatabase& symboldatabase, |
| 4265 | ErrorLogger& errorLogger, |
| 4266 | const Settings& settings) |
| 4267 | { |
| 4268 | for (const Scope* scope : symboldatabase.functionScopes) { |
| 4269 | for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { |
| 4270 | if (!Token::simpleMatch(tok, "swap (")) |
| 4271 | continue; |
| 4272 | if (!Token::simpleMatch(tok->next()->astOperand2(), ",")) |
| 4273 | continue; |
| 4274 | std::vector<Token*> args = astFlatten(tok->next()->astOperand2(), ","); |
| 4275 | if (args.size() != 2) |
| 4276 | continue; |
| 4277 | if (args[0]->exprId() == 0) |
| 4278 | continue; |
| 4279 | if (args[1]->exprId() == 0) |
| 4280 | continue; |
| 4281 | for (int i = 0; i < 2; i++) { |
| 4282 | std::vector<const Variable*> vars = getVariables(args[0]); |
| 4283 | const std::list<ValueFlow::Value>& values = args[0]->values(); |
| 4284 | valueFlowForwardAssign(args[0], args[1], std::move(vars), values, false, tokenlist, errorLogger, settings); |
| 4285 | std::swap(args[0], args[1]); |
| 4286 | } |
| 4287 | } |
| 4288 | } |
| 4289 | } |
| 4290 | |
| 4291 | static void valueFlowSetConditionToKnown(const Token* tok, std::list<ValueFlow::Value>& values, bool then) |
| 4292 | { |
no test coverage detected