Memory leaks: Improved the simplifycode for 'use ; if| use ;'
This commit is contained in:
parent
e48592c644
commit
73122c3e8a
|
@ -1925,6 +1925,17 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use; if| use; => use;
|
||||||
|
while (Token::Match(tok2, "[;{}] use ; if| use ;"))
|
||||||
|
{
|
||||||
|
Token *t = tok2->tokAt(2);
|
||||||
|
t->deleteNext();
|
||||||
|
t->deleteNext();
|
||||||
|
if (t->strAt(1) == ";")
|
||||||
|
t->deleteNext();
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// use; if return; dealloc; => if return; dealloc;
|
// use; if return; dealloc; => if return; dealloc;
|
||||||
if (Token::Match(tok2, "[;{}] use ; if return ; dealloc ;"))
|
if (Token::Match(tok2, "[;{}] use ; if return ; dealloc ;"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -658,6 +658,9 @@ private:
|
||||||
ASSERT_EQUALS("alloc ;", simplifycode("alloc ; if ; if(var) ; ifv ; if(!var) ;"));
|
ASSERT_EQUALS("alloc ;", simplifycode("alloc ; if ; if(var) ; ifv ; if(!var) ;"));
|
||||||
ASSERT_EQUALS("alloc ;", simplifycode("alloc ; if ; else ;"));
|
ASSERT_EQUALS("alloc ;", simplifycode("alloc ; if ; else ;"));
|
||||||
|
|
||||||
|
// use..
|
||||||
|
ASSERT_EQUALS("; alloc ; dealloc ; }", simplifycode("; alloc ; use ; use ; if use ; dealloc ; }"));
|
||||||
|
|
||||||
// if, else..
|
// if, else..
|
||||||
ASSERT_EQUALS("; alloc ; if break ; dealloc ;", simplifycode("; alloc ; if { break; } dealloc ;"));
|
ASSERT_EQUALS("; alloc ; if break ; dealloc ;", simplifycode("; alloc ; if { break; } dealloc ;"));
|
||||||
ASSERT_EQUALS("; alloc ; if continue ; dealloc ;", simplifycode("; alloc ; if { continue; } dealloc ;"));
|
ASSERT_EQUALS("; alloc ; if continue ; dealloc ;", simplifycode("; alloc ; if { continue; } dealloc ;"));
|
||||||
|
|
Loading…
Reference in New Issue