Fixed #2184 (False Positive: memory leak)

This commit is contained in:
Daniel Marjamäki 2010-11-10 17:46:40 +01:00
parent 4ddf6f3b44
commit 28c53cabea
2 changed files with 5 additions and 2 deletions

View File

@ -1838,10 +1838,12 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
done = false;
}
// Reduce "while1 ;" => "use ;"
if (Token::simpleMatch(tok2, "while1 ;"))
// Reduce "while1 continue| ;" => "use ;"
if (Token::Match(tok2, "while1 continue| ;"))
{
tok2->str("use");
if (tok2->strAt(1) == "continue")
tok2->deleteNext();
done = false;
}

View File

@ -728,6 +728,7 @@ private:
ASSERT_EQUALS("; alloc ; dealloc ; return ;", simplifycode("; alloc ; while1 { if { dealloc ; return ; } }"));
ASSERT_EQUALS("; alloc ; dealloc ; return ;", simplifycode("; alloc ; while1 { if { dealloc ; return ; } if { continue ; } }"));
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while1 { if { dealloc ; return ; } if { break ; } }"));
ASSERT_EQUALS("; alloc ; use ; }", simplifycode("; alloc ; while1 { if { dealloc ; return ; } continue ; } ; }"));
ASSERT_EQUALS(";", simplifycode("; do { dealloc ; alloc ; } while(var) ;"));
ASSERT_EQUALS("dealloc ; alloc ;", simplifycode("loop { dealloc ; alloc ; }"));