Tokenizer: Fix another Valgrind error in simplifyErrNoInWhile. Add more jumping patterns to simplifyIfAddBraces and simplifyDoWhileAddBraces.

This commit is contained in:
Edoardo Prezioso 2011-12-12 13:14:25 +01:00
parent 5f5c912f3f
commit 626f13ae7e
1 changed files with 4 additions and 3 deletions

View File

@ -4926,7 +4926,7 @@ bool Tokenizer::simplifyIfAddBraces()
continue; continue;
} }
if (tempToken->str() == "(") { if (tempToken->str() == "(" || tempToken->str() == "[") {
tempToken = tempToken->link(); tempToken = tempToken->link();
continue; continue;
} }
@ -4973,7 +4973,8 @@ void Tokenizer::simplifyDoWhileAddBraces()
for (Token *tok = last; tok; tok = tok->previous()) { for (Token *tok = last; tok; tok = tok->previous()) {
// fix for #988 // fix for #988
if (tok->str() == ")" || tok->str() == "]" || if (tok->str() == ")" || tok->str() == "]" ||
(tok->str() == "}" && Token::simpleMatch(tok->link()->previous(), "= {"))) (tok->str() == "}" && tok->link()->previous() &&
tok->link()->previous()->str() == "="))
tok = tok->link(); tok = tok->link();
if (!Token::Match(tok, "do !!{")) if (!Token::Match(tok, "do !!{"))
@ -9059,8 +9060,8 @@ void Tokenizer::simplifyErrNoInWhile()
tok1 = tok1->previous(); tok1 = tok1->previous();
// erase "&& errno == EINTR" // erase "&& errno == EINTR"
tok1 = tok1->previous();
Token::eraseTokens(tok1, endpar); Token::eraseTokens(tok1, endpar);
tok1->deleteThis();
// tok is invalid.. move to endpar // tok is invalid.. move to endpar
tok = endpar; tok = endpar;