Memory leaks: fixed try/catch and nested loops simplifications
This commit is contained in:
parent
4064712baa
commit
d4e045cee5
|
@ -1855,10 +1855,9 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace "loop callfunc ;" with ";"
|
// Replace "loop loop .." with "loop .."
|
||||||
if (Token::simpleMatch(tok2, "loop callfunc ;"))
|
if (Token::simpleMatch(tok2, "loop loop"))
|
||||||
{
|
{
|
||||||
tok2->deleteThis();
|
|
||||||
tok2->deleteThis();
|
tok2->deleteThis();
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
@ -1945,10 +1944,11 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// callfunc callfunc
|
// try/catch
|
||||||
while (Token::simpleMatch(tok2, "callfunc callfunc"))
|
if (Token::simpleMatch(tok2, "try ; catch exit ;"))
|
||||||
{
|
{
|
||||||
tok2->deleteNext();
|
Token::eraseTokens(tok2, tok2->tokAt(4));
|
||||||
|
tok2->deleteThis();
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -707,6 +707,7 @@ private:
|
||||||
ASSERT_EQUALS("; loop alloc ;", simplifycode("; loop { alloc ; }"));
|
ASSERT_EQUALS("; loop alloc ;", simplifycode("; loop { alloc ; }"));
|
||||||
ASSERT_EQUALS("; alloc ; alloc ;", simplifycode("; alloc ; do { alloc ; } loop ;"));
|
ASSERT_EQUALS("; alloc ; alloc ;", simplifycode("; alloc ; do { alloc ; } loop ;"));
|
||||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc ; do { } loop ; exit ;"));
|
ASSERT_EQUALS("; exit ;", simplifycode("; alloc ; do { } loop ; exit ;"));
|
||||||
|
ASSERT_EQUALS("; loop use ;", simplifycode("; loop { loop loop use ; } ;"));
|
||||||
|
|
||||||
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
ASSERT_EQUALS("; alloc ;", simplifycode("; alloc ; while(!var) alloc ;"));
|
||||||
|
|
||||||
|
@ -740,6 +741,9 @@ private:
|
||||||
TODO_ASSERT_EQUALS(";", simplifycode("; alloc ; if(var) { exit; }"));
|
TODO_ASSERT_EQUALS(";", simplifycode("; alloc ; if(var) { exit; }"));
|
||||||
TODO_ASSERT_EQUALS(";\n; alloc ;", simplifycode("; alloc ; ifv { exit; }"));
|
TODO_ASSERT_EQUALS(";\n; alloc ;", simplifycode("; alloc ; ifv { exit; }"));
|
||||||
|
|
||||||
|
// try-catch
|
||||||
|
ASSERT_EQUALS("; }", simplifycode("; try ; catch exit ; }"));
|
||||||
|
|
||||||
// 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 ;"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue