memory leaks: better checking of function calls. If there are statements after the function call it is unlikely the function call is noreturn
This commit is contained in:
parent
c8065506b6
commit
df44703ee9
|
@ -1462,6 +1462,13 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
tok2->deleteNext();
|
tok2->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reduce "; callfunc ; %var%"
|
||||||
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
|
{
|
||||||
|
if (Token::Match(tok2, ";|{|} callfunc ; %type%"))
|
||||||
|
tok2->deleteNext();
|
||||||
|
}
|
||||||
|
|
||||||
// remove redundant braces..
|
// remove redundant braces..
|
||||||
for (Token *start = tok; start; start = start->next())
|
for (Token *start = tok; start; start = start->next())
|
||||||
{
|
{
|
||||||
|
@ -1561,13 +1568,6 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reduce "; callfunc ; %var%"
|
|
||||||
else if (Token::Match(tok2, "; callfunc ; %type%"))
|
|
||||||
{
|
|
||||||
tok2->deleteNext();
|
|
||||||
done = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reduce "if if|callfunc" => "if"
|
// Reduce "if if|callfunc" => "if"
|
||||||
else if (Token::Match(tok2, "if if|callfunc"))
|
else if (Token::Match(tok2, "if if|callfunc"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -708,6 +708,7 @@ private:
|
||||||
|
|
||||||
// callfunc..
|
// callfunc..
|
||||||
ASSERT_EQUALS("; callfunc ;", simplifycode(";callfunc;"));
|
ASSERT_EQUALS("; callfunc ;", simplifycode(";callfunc;"));
|
||||||
|
ASSERT_EQUALS("while1 { dealloc ; alloc ; } return ; }", simplifycode("while1 { dealloc ; alloc ; } callfunc ; return ; }"));
|
||||||
|
|
||||||
// exit..
|
// exit..
|
||||||
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; exit;"));
|
ASSERT_EQUALS("; exit ;", simplifycode("; alloc; exit;"));
|
||||||
|
|
Loading…
Reference in New Issue