Replace tok->previous()->previous() call to tok->tokAt(-2).

Done by command:
git grep -l 'previous()->previous()' | xargs sed -i 's|previous()->previous()|tokAt(-2)|'

No functional change.
This commit is contained in:
Slava Semushin 2009-06-14 13:26:20 +07:00
parent 57f1a6d2b7
commit bc32d04efa
2 changed files with 5 additions and 5 deletions

View File

@ -1865,10 +1865,10 @@ bool Tokenizer::simplifyQuestionMark()
if (tok->str() != "?")
continue;
if (!tok->previous() || !tok->previous()->previous())
if (!tok->previous() || !tok->tokAt(-2))
continue;
if (!Token::Match(tok->previous()->previous(), "[=,(]"))
if (!Token::Match(tok->tokAt(-2), "[=,(]"))
continue;
if (!Token::Match(tok->previous(), "%bool%") &&
@ -1884,7 +1884,7 @@ bool Tokenizer::simplifyQuestionMark()
continue;
end = end->next();
tok = tok->previous()->previous();
tok = tok->tokAt(-2);
while (tok->next() != end)
{
tok->deleteNext();
@ -2564,7 +2564,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
// We have "(( *something* ))", remove the inner
// paranthesis
tok->deleteNext();
tok->link()->previous()->previous()->deleteNext();
tok->link()->tokAt(-2)->deleteNext();
ret = true;
}

View File

@ -51,7 +51,7 @@ private:
ASSERT_EQUALS(last->str(), "3");
ASSERT_EQUALS(last->previous()->str(), "2");
ASSERT_EQUALS(last->previous()->previous()->str(), "1");
ASSERT_EQUALS(last->tokAt(-2)->str(), "1");
if (token->previous())
ASSERT_EQUALS("Null was expected", "");