Memory leaks: simplify 'use use'

This commit is contained in:
Daniel Marjamäki 2010-09-11 21:32:21 +02:00
parent 424fe064cb
commit 7aa0504692
2 changed files with 8 additions and 0 deletions

View File

@ -1919,6 +1919,13 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
done = false;
}
// use use => use
if (Token::simpleMatch(tok2, "use use"))
{
tok2->deleteThis();
done = false;
}
// use; if| use; => use;
while (Token::Match(tok2, "[;{}] use ; if| use ;"))
{

View File

@ -659,6 +659,7 @@ private:
ASSERT_EQUALS("alloc ;", simplifycode("alloc ; if ; else ;"));
// use..
ASSERT_EQUALS("; use ; }", simplifycode("; use use ; }"));
ASSERT_EQUALS("; alloc ; dealloc ; }", simplifycode("; alloc ; use ; use ; if use ; dealloc ; }"));
// if, else..