| 78 | } |
| 79 | |
| 80 | static std::map<nonneg int, VariableValue> getVariableValues(const Token* tok) { |
| 81 | std::map<nonneg int, VariableValue> ret; |
| 82 | if (!tok || !tok->scope()->isExecutable()) |
| 83 | return ret; |
| 84 | while (tok && tok->str() != "{") { |
| 85 | if (tok->str() == "}") { |
| 86 | if (tok->link()->isBinaryOp()) |
| 87 | tok = tok->link()->previous(); |
| 88 | else |
| 89 | break; |
| 90 | } |
| 91 | if (Token::Match(tok, "%var% =|{") && tok->next()->isBinaryOp() && tok->varId() && ret.count(tok->varId()) == 0) { |
| 92 | const Token* rhs = tok->next()->astOperand2(); |
| 93 | if (rhs && rhs->hasKnownIntValue()) |
| 94 | ret[tok->varId()] = VariableValue(rhs->getKnownIntValue()); |
| 95 | } |
| 96 | tok = tok->previous(); |
| 97 | } |
| 98 | return ret; |
| 99 | } |
| 100 | |
| 101 | bool CheckUninitVarImpl::diag(const Token* tok) |
| 102 | { |
no test coverage detected