| 163 | } |
| 164 | |
| 165 | static bool isAddressOfLocalVariable(const Token *expr) |
| 166 | { |
| 167 | if (!expr) |
| 168 | return false; |
| 169 | if (Token::Match(expr, "+|-")) |
| 170 | return isAddressOfLocalVariable(expr->astOperand1()) || isAddressOfLocalVariable(expr->astOperand2()); |
| 171 | if (expr->isCast()) |
| 172 | return isAddressOfLocalVariable(expr->astOperand2() ? expr->astOperand2() : expr->astOperand1()); |
| 173 | if (expr->isUnaryOp("&")) { |
| 174 | const Token *op = expr->astOperand1(); |
| 175 | bool deref = false; |
| 176 | while (Token::Match(op, ".|[")) { |
| 177 | if (op->originalName() == "->") |
| 178 | return false; |
| 179 | if (op->str() == "[") |
| 180 | deref = true; |
| 181 | op = op->astOperand1(); |
| 182 | } |
| 183 | return op && isAutoVar(op) && (!deref || !op->variable()->isPointer()); |
| 184 | } |
| 185 | return false; |
| 186 | } |
| 187 | |
| 188 | static bool variableIsUsedInScope(const Token* start, nonneg int varId, const Scope *scope) |
| 189 | { |
no test coverage detected