Memory leaks: simplify 'if break ; break ;'
This commit is contained in:
parent
7aa0504692
commit
ceeef847ef
|
@ -1811,6 +1811,13 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if break ; break ; => break ;
|
||||||
|
if (Token::Match(tok2->previous(), "[;{}] if break ; break ;"))
|
||||||
|
{
|
||||||
|
Token::eraseTokens(tok2, tok2->tokAt(4));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Reduce "do { dealloc ; alloc ; } while(var) ;" => ";"
|
// Reduce "do { dealloc ; alloc ; } while(var) ;" => ";"
|
||||||
if (Token::simpleMatch(tok2->next(), "do { dealloc ; alloc ; } while(var) ;"))
|
if (Token::simpleMatch(tok2->next(), "do { dealloc ; alloc ; } while(var) ;"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -709,6 +709,7 @@ private:
|
||||||
ASSERT_EQUALS("; alloc ; alloc ;", simplifycode("; alloc ; do { alloc ; } loop ;"));
|
ASSERT_EQUALS("; alloc ; alloc ;", simplifycode("; alloc ; do { alloc ; } loop ;"));
|
||||||
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("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue