Memory leaks: reduce 'loop { if continue ;' to 'loop {'
This commit is contained in:
parent
0a30aba2e6
commit
5a95303405
|
@ -1860,13 +1860,20 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce "loop if break ; => ";"
|
// Reduce "loop if break|continue ; !!else" => ";"
|
||||||
if (Token::Match(tok2->next(), "loop if break|continue ; !!else"))
|
if (Token::Match(tok2->next(), "loop if break|continue ; !!else"))
|
||||||
{
|
{
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(4));
|
Token::eraseTokens(tok2, tok2->tokAt(4));
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce "loop { if break|continue ; !!else" => "loop {"
|
||||||
|
if (Token::Match(tok2, "loop { if break|continue ; !!else"))
|
||||||
|
{
|
||||||
|
Token::eraseTokens(tok2->next(), tok2->tokAt(5));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Replace "do ; loop ;" with ";"
|
// Replace "do ; loop ;" with ";"
|
||||||
if (Token::simpleMatch(tok2, "; loop ;"))
|
if (Token::simpleMatch(tok2, "; loop ;"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -710,6 +710,7 @@ private:
|
||||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc ; do { } loop ; exit ;"));
|
ASSERT_EQUALS("; exit ;", simplifycode("; alloc ; do { } loop ; exit ;"));
|
||||||
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
|
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
|
||||||
ASSERT_EQUALS("; }", simplifycode("; loop { if break ; break ; } ; }"));
|
ASSERT_EQUALS("; }", simplifycode("; loop { if break ; break ; } ; }"));
|
||||||
|
ASSERT_EQUALS("; }", simplifycode("; loop { if continue ; if continue ; } ; }"));
|
||||||
|
|
||||||
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue