| 1397 | } |
| 1398 | |
| 1399 | void CheckStlImpl::erase() |
| 1400 | { |
| 1401 | logChecker("CheckStl::erase"); |
| 1402 | |
| 1403 | const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 1404 | |
| 1405 | for (const Scope &scope : symbolDatabase->scopeList) { |
| 1406 | if (scope.type == ScopeType::eFor && Token::simpleMatch(scope.classDef, "for (")) { |
| 1407 | const Token *tok = scope.classDef->linkAt(1); |
| 1408 | if (!Token::Match(tok->tokAt(-3), "; ++| %var% ++| ) {")) |
| 1409 | continue; |
| 1410 | tok = tok->previous(); |
| 1411 | if (!tok->isName()) |
| 1412 | tok = tok->previous(); |
| 1413 | eraseCheckLoopVar(scope, tok->variable()); |
| 1414 | } else if (scope.type == ScopeType::eWhile && Token::Match(scope.classDef, "while ( %var% !=")) { |
| 1415 | eraseCheckLoopVar(scope, scope.classDef->tokAt(2)->variable()); |
| 1416 | } |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | void CheckStlImpl::eraseCheckLoopVar(const Scope &scope, const Variable *var) |
| 1421 | { |