checks if side effects happen on the variable prior to tmp
| 143 | |
| 144 | // checks if side effects happen on the variable prior to tmp |
| 145 | void CheckAssertImpl::checkVariableAssignment(const Token* assignTok, const Scope *assertionScope) |
| 146 | { |
| 147 | if (!assignTok->isAssignmentOp() && assignTok->tokType() != Token::eIncDecOp) |
| 148 | return; |
| 149 | |
| 150 | if (!assignTok->astOperand1()) |
| 151 | return; |
| 152 | const Variable* var = assignTok->astOperand1()->variable(); |
| 153 | if (!var) |
| 154 | return; |
| 155 | |
| 156 | // Variable declared in inner scope in assert => don't warn |
| 157 | if (assertionScope != var->scope()) { |
| 158 | const Scope *s = var->scope(); |
| 159 | while (s && s != assertionScope) |
| 160 | s = s->nestedIn; |
| 161 | if (s == assertionScope) |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | // assignment |
| 166 | if (assignTok->isAssignmentOp() || assignTok->tokType() == Token::eIncDecOp) { |
| 167 | if (var->isConst()) { |
| 168 | return; |
| 169 | } |
| 170 | assignmentInAssertError(assignTok, var->name()); |
| 171 | } |
| 172 | // TODO: function calls on var |
| 173 | } |
| 174 | |
| 175 | bool CheckAssertImpl::inSameScope(const Token* returnTok, const Token* assignTok) |
| 176 | { |
nothing calls this directly
no test coverage detected