| 4436 | } |
| 4437 | |
| 4438 | void traverseCondition(const SymbolDatabase& symboldatabase, |
| 4439 | const Settings& settings, |
| 4440 | const std::set<const Scope*>& skippedFunctions, |
| 4441 | const std::function<void(const Condition& cond, Token* tok, const Scope* scope)>& f) const |
| 4442 | { |
| 4443 | for (const Scope *scope : symboldatabase.functionScopes) { |
| 4444 | if (skippedFunctions.count(scope)) |
| 4445 | continue; |
| 4446 | for (auto *tok = const_cast<Token *>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { |
| 4447 | if (Token::Match(tok, "if|while|for (")) |
| 4448 | continue; |
| 4449 | if (Token::Match(tok, ":|;|,")) |
| 4450 | continue; |
| 4451 | |
| 4452 | const Token* top = tok->astTop(); |
| 4453 | |
| 4454 | if (!Token::Match(top->previous(), "if|while|for (") && !Token::Match(tok->astParent(), "&&|%oror%|?|!")) |
| 4455 | continue; |
| 4456 | for (const Condition& cond : parse(tok, settings)) { |
| 4457 | if (!cond.vartok) |
| 4458 | continue; |
| 4459 | if (cond.vartok->exprId() == 0) |
| 4460 | continue; |
| 4461 | if (cond.vartok->hasKnownIntValue()) |
| 4462 | continue; |
| 4463 | if (cond.true_values.empty() || cond.false_values.empty()) |
| 4464 | continue; |
| 4465 | if (!isConstExpression(cond.vartok, settings.library)) |
| 4466 | continue; |
| 4467 | f(cond, tok, scope); |
| 4468 | } |
| 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | |
| 4473 | void beforeCondition(TokenList& tokenlist, |
| 4474 | const SymbolDatabase& symboldatabase, |
nothing calls this directly
no test coverage detected