Replace tok->next()->next() call to tok->tokAt(2).
Done by command: git grep -l 'next()->next()' | xargs sed -i 's|next()->next()|tokAt(2)|' No functional change.
This commit is contained in:
parent
ab0a1973e8
commit
4245047674
|
@ -935,7 +935,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
if (Token::Match(tok2->next(), "{ %var% ; }"))
|
||||
{
|
||||
Token::eraseTokens(tok2, tok2->tokAt(2));
|
||||
Token::eraseTokens(tok2->next()->next(), tok2->tokAt(4));
|
||||
Token::eraseTokens(tok2->tokAt(2), tok2->tokAt(4));
|
||||
done = false;
|
||||
}
|
||||
if (Token::Match(tok2->next(), "{ %var% %var% ; }"))
|
||||
|
@ -1135,7 +1135,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
if (Token::simpleMatch(tok2->next(), "do { alloc ; }"))
|
||||
{
|
||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||
Token::eraseTokens(tok2->next()->next(), tok2->tokAt(4));
|
||||
Token::eraseTokens(tok2->tokAt(2), tok2->tokAt(4));
|
||||
done = false;
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
if (Token::Match(tok2->next(), "loop { %var% ; break ; }"))
|
||||
{
|
||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||
Token::eraseTokens(tok2->next()->next(), tok2->tokAt(6));
|
||||
Token::eraseTokens(tok2->tokAt(2), tok2->tokAt(6));
|
||||
done = false;
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
// Reduce "[;{}] return ; %var%" => "[;{}] return ;"
|
||||
if (Token::Match(tok2, "[;{}] return ; %var%"))
|
||||
{
|
||||
Token::eraseTokens(tok2->next()->next(), tok2->tokAt(4));
|
||||
Token::eraseTokens(tok2->tokAt(2), tok2->tokAt(4));
|
||||
done = false;
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
|
|||
if (Token::simpleMatch(tok2, "break ;"))
|
||||
{
|
||||
tok2->str(";");
|
||||
tok2 = tok2->next()->next();
|
||||
tok2 = tok2->tokAt(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -831,7 +831,7 @@ void Tokenizer::setVarId()
|
|||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->varId() == tok->varId() && Token::simpleMatch(tok2->next(), pattern.c_str()))
|
||||
tok2->next()->next()->varId(_varId);
|
||||
tok2->tokAt(2)->varId(_varId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ void Tokenizer::simplifyTokenList()
|
|||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "case %any% : %var%"))
|
||||
tok->next()->next()->insertToken(";");
|
||||
tok->tokAt(2)->insertToken(";");
|
||||
if (Token::Match(tok, "default : %var%"))
|
||||
tok->next()->insertToken(";");
|
||||
}
|
||||
|
@ -1775,7 +1775,7 @@ bool Tokenizer::simplifyConditions()
|
|||
if (Token::Match(tok, "if|while ( %num%") &&
|
||||
(tok->tokAt(3)->str() == ")" || tok->tokAt(3)->str() == "||" || tok->tokAt(3)->str() == "&&"))
|
||||
{
|
||||
tok->next()->next()->str((tok->tokAt(2)->str() != "0") ? "true" : "false");
|
||||
tok->tokAt(2)->str((tok->tokAt(2)->str() != "0") ? "true" : "false");
|
||||
ret = true;
|
||||
}
|
||||
Token *tok2 = tok->tokAt(2);
|
||||
|
@ -2149,7 +2149,7 @@ bool Tokenizer::simplifyVarDecl()
|
|||
|
||||
else if (Token::Match(tok2, "%type% * %var% ,|="))
|
||||
{
|
||||
if (tok2->next()->next()->str() != "operator")
|
||||
if (tok2->tokAt(2)->str() != "operator")
|
||||
tok2 = tok2->tokAt(3); // The ',' token
|
||||
else
|
||||
tok2 = NULL;
|
||||
|
@ -2359,7 +2359,7 @@ bool Tokenizer::simplifyNot()
|
|||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "if|while ( not %var%"))
|
||||
tok->next()->next()->str("!");
|
||||
tok->tokAt(2)->str("!");
|
||||
if (Token::Match(tok, "&& not %var%"))
|
||||
tok->next()->str("!");
|
||||
if (Token::Match(tok, "|| not %var%"))
|
||||
|
|
|
@ -42,10 +42,10 @@ private:
|
|||
token->str("1");
|
||||
token->insertToken("2");
|
||||
token->next()->insertToken("3");
|
||||
Token *last = token->next()->next();
|
||||
Token *last = token->tokAt(2);
|
||||
ASSERT_EQUALS(token->str(), "1");
|
||||
ASSERT_EQUALS(token->next()->str(), "2");
|
||||
ASSERT_EQUALS(token->next()->next()->str(), "3");
|
||||
ASSERT_EQUALS(token->tokAt(2)->str(), "3");
|
||||
if (last->next())
|
||||
ASSERT_EQUALS("Null was expected", "");
|
||||
|
||||
|
|
Loading…
Reference in New Issue