CheckMemoryleaks: reduce 'use ; if return ; dealloc ;' to 'if return ; dealloc ;'. ticket: #2037
This commit is contained in:
parent
ad03c97a6e
commit
8e746ca53f
|
@ -1915,17 +1915,24 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete first part in "use ; dealloc ;"
|
// use; dealloc; => dealloc;
|
||||||
if (Token::Match(tok2, "[;{}] use ; dealloc ;"))
|
if (Token::Match(tok2, "[;{}] use ; dealloc ;"))
|
||||||
{
|
{
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use; if return; dealloc; => if return; dealloc;
|
||||||
|
if (Token::Match(tok2, "[;{}] use ; if return ; dealloc ;"))
|
||||||
|
{
|
||||||
|
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete first part in "use ; return use ;"
|
// Delete first part in "use ; return use ;"
|
||||||
if (Token::Match(tok2, "[;{}] use ; return use ;"))
|
if (Token::Match(tok2, "[;{}] use ; return use ;"))
|
||||||
{
|
{
|
||||||
Token::eraseTokens(tok2, tok2->tokAt(2));
|
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -735,6 +735,9 @@ private:
|
||||||
|
|
||||||
// dealloc; dealloc;
|
// dealloc; dealloc;
|
||||||
ASSERT_EQUALS("; alloc ; if dealloc ; dealloc ;", simplifycode("; alloc ; if { dealloc ; } dealloc ;"));
|
ASSERT_EQUALS("; alloc ; if dealloc ; dealloc ;", simplifycode("; alloc ; if { dealloc ; } dealloc ;"));
|
||||||
|
|
||||||
|
// use ; dealloc ;
|
||||||
|
ASSERT_EQUALS("; alloc ; if return ; dealloc ;", simplifycode("; alloc ; use ; if { return ; } dealloc ;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue