| 1495 | } |
| 1496 | |
| 1497 | static bool if_findCompare(const Token * const tokBack, bool stdStringLike) |
| 1498 | { |
| 1499 | const Token *tok = tokBack->astParent(); |
| 1500 | if (!tok) |
| 1501 | return true; |
| 1502 | if (tok->isComparisonOp()) { |
| 1503 | if (stdStringLike) { |
| 1504 | const Token * const tokOther = tokBack->astSibling(); |
| 1505 | return !tokOther || !tokOther->hasKnownIntValue() || tokOther->getKnownIntValue() != 0; |
| 1506 | } |
| 1507 | return (!tok->astOperand1()->isNumber() && !tok->astOperand2()->isNumber()); |
| 1508 | } |
| 1509 | if (tok->isArithmeticalOp()) // result is used in some calculation |
| 1510 | return true; // TODO: check if there is a comparison of the result somewhere |
| 1511 | if (tok->str() == ".") |
| 1512 | return true; // Dereferencing is OK, the programmer might know that the element exists - TODO: An inconclusive warning might be appropriate |
| 1513 | if (tok->isAssignmentOp()) |
| 1514 | return if_findCompare(tok, stdStringLike); // Go one step upwards in the AST |
| 1515 | return false; |
| 1516 | } |
| 1517 | |
| 1518 | void CheckStlImpl::if_find() |
| 1519 | { |
no test coverage detected