|
17 | 17 | */ |
18 | 18 |
|
19 | 19 | #include "valueflow.h" |
| 20 | +#include "astutils.h" |
20 | 21 | #include "errorlogger.h" |
21 | 22 | #include "mathlib.h" |
22 | 23 | #include "settings.h" |
@@ -321,40 +322,6 @@ static bool isReturn(const Token *tok) |
321 | 322 | return false; |
322 | 323 | } |
323 | 324 |
|
324 | | -static bool isVariableChanged(const Token *start, const Token *end, const unsigned int varid) |
325 | | -{ |
326 | | - for (const Token *tok = start; tok != end; tok = tok->next()) { |
327 | | - if (tok->varId() == varid) { |
328 | | - if (Token::Match(tok, "%name% =|++|--")) |
329 | | - return true; |
330 | | - |
331 | | - if (Token::Match(tok->previous(), "++|-- %name%")) |
332 | | - return true; |
333 | | - |
334 | | - if (Token::Match(tok->tokAt(-2), "[(,] & %var% [,)]")) |
335 | | - return true; // TODO: check if function parameter is const |
336 | | - |
337 | | - if (Token::Match(tok->previous(), "[(,] %var% [,)]")) { |
338 | | - const Token *parent = tok->astParent(); |
339 | | - while (parent && parent->str() == ",") |
340 | | - parent = parent->astParent(); |
341 | | - if (parent && parent->str() == "(") { |
342 | | - if (parent->astOperand1() && parent->astOperand1()->isName() && !parent->astOperand1()->function()) |
343 | | - return true; |
344 | | - // TODO: check if function parameter is non-const reference etc.. |
345 | | - } |
346 | | - } |
347 | | - |
348 | | - const Token *parent = tok->astParent(); |
349 | | - while (Token::Match(parent, ".|::")) |
350 | | - parent = parent->astParent(); |
351 | | - if (parent && parent->tokType() == Token::eIncDecOp) |
352 | | - return true; |
353 | | - } |
354 | | - } |
355 | | - return false; |
356 | | -} |
357 | | - |
358 | 325 | /** Add token value. Return true if value is added. */ |
359 | 326 | static bool addValue(Token *tok, const ValueFlow::Value &value) |
360 | 327 | { |
|
0 commit comments