src/checkstl.cpp(iterators): reduce indentation.

No functional change.
This commit is contained in:
Slava Semushin 2009-07-29 01:05:00 +07:00
parent f50aa1e188
commit 524b0cd9b8
1 changed files with 26 additions and 26 deletions

View File

@ -47,34 +47,34 @@ void CheckStl::iterators()
{
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
if (Token::Match(tok, "%var% = %var% . begin ( ) ;|+"))
{
const unsigned int iteratorId(tok->varId());
const unsigned int containerId(tok->tokAt(2)->varId());
if (iteratorId == 0 || containerId == 0)
continue;
if (!Token::Match(tok, "%var% = %var% . begin ( ) ;|+"))
continue;
bool validIterator = true;
for (const Token *tok2 = tok->tokAt(6); tok2; tok2 = tok2->next())
const unsigned int iteratorId(tok->varId());
const unsigned int containerId(tok->tokAt(2)->varId());
if (iteratorId == 0 || containerId == 0)
continue;
bool validIterator = true;
for (const Token *tok2 = tok->tokAt(6); tok2; tok2 = tok2->next())
{
if (tok2->str() == "}")
break;
if (tok2->varId() == iteratorId)
{
if (tok2->str() == "}")
break;
if (tok2->varId() == iteratorId)
{
if (Token::Match(tok2->next(), "!= %var% . end ( )") && tok2->tokAt(2)->varId() != containerId)
iteratorsError(tok2, tok->strAt(2), tok2->strAt(2));
}
else if (Token::Match(tok2, "%var% . insert|erase ( %varid%", iteratorId))
{
if (tok2->varId() != containerId)
iteratorsError(tok2, tok->strAt(2), tok2->str());
else if (tok2->strAt(2) == std::string("erase"))
validIterator = false;
}
else if (!validIterator && tok2->Match(tok2, "* %varid%", iteratorId))
{
dereferenceErasedError(tok2, tok2->strAt(1));
}
if (Token::Match(tok2->next(), "!= %var% . end ( )") && tok2->tokAt(2)->varId() != containerId)
iteratorsError(tok2, tok->strAt(2), tok2->strAt(2));
}
else if (Token::Match(tok2, "%var% . insert|erase ( %varid%", iteratorId))
{
if (tok2->varId() != containerId)
iteratorsError(tok2, tok->strAt(2), tok2->str());
else if (tok2->strAt(2) == std::string("erase"))
validIterator = false;
}
else if (!validIterator && tok2->Match(tok2, "* %varid%", iteratorId))
{
dereferenceErasedError(tok2, tok2->strAt(1));
}
}
}