Memory leaks: simplify 'loop { use ; callfunc ; }' to 'use ;'
This commit is contained in:
parent
c185f34947
commit
9c4a05a3bd
|
@ -1890,6 +1890,16 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
|||
done = false;
|
||||
}
|
||||
|
||||
// loop { use ; callfunc ; } => use ;
|
||||
// assume that the "callfunc" is not noreturn
|
||||
if (Token::simpleMatch(tok2, "loop { use ; callfunc ; }"))
|
||||
{
|
||||
Token::eraseTokens(tok2, tok2->tokAt(7));
|
||||
tok2->str("use");
|
||||
tok2->insertToken(";");
|
||||
done = false;
|
||||
}
|
||||
|
||||
// Delete if block in "alloc ; if(!var) return ;"
|
||||
if (Token::Match(tok2, "alloc ; if(!var) return ;"))
|
||||
{
|
||||
|
|
|
@ -720,6 +720,7 @@ private:
|
|||
ASSERT_EQUALS(";", simplifycode("; do { dealloc ; alloc ; } while(var) ;"));
|
||||
ASSERT_EQUALS("dealloc ; alloc ;", simplifycode("loop { dealloc ; alloc ; }"));
|
||||
ASSERT_EQUALS("dealloc ; alloc ;", simplifycode("while1 { dealloc ; alloc ; }"));
|
||||
ASSERT_EQUALS("use ; }", simplifycode("loop { use ; callfunc ; } }"));
|
||||
|
||||
// scope..
|
||||
// current result - ok
|
||||
|
|
Loading…
Reference in New Issue