Memory leaks: Fixed TODO test case. Ticket: #2733
This commit is contained in:
parent
b1d3d291e6
commit
a79e979ae4
|
@ -1812,6 +1812,14 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
|||
done = false;
|
||||
}
|
||||
|
||||
// outer/inner if blocks. Remove outer condition..
|
||||
else if (Token::Match(tok2->next(), "if|if(var) { if return use ; }"))
|
||||
{
|
||||
tok2->tokAt(6)->deleteNext();
|
||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||
done = false;
|
||||
}
|
||||
|
||||
else if (tok2->next() && tok2->next()->str() == "if")
|
||||
{
|
||||
// Delete empty if that is not followed by an else
|
||||
|
@ -1902,14 +1910,6 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
|||
done = false;
|
||||
}
|
||||
|
||||
// Remove outer condition..
|
||||
else if (Token::Match(tok2->next(), "if { if return use ; }"))
|
||||
{
|
||||
tok2->tokAt(6)->deleteNext();
|
||||
Token::eraseTokens(tok2, tok2->tokAt(3));
|
||||
done = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -669,9 +669,7 @@ private:
|
|||
// remove outer if (#2733)
|
||||
ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if return use ; } return ; }"));
|
||||
ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if(var) return use ; } return ; }"));
|
||||
TODO_ASSERT_EQUALS("alloc ; return ; }",
|
||||
"alloc ; if(var) { if return use ; } return ; }",
|
||||
simplifycode("alloc ; if(var) { if return use ; } return ; }"));
|
||||
ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if(var) { if return use ; } return ; }"));
|
||||
|
||||
// "if ; .."
|
||||
ASSERT_EQUALS("; if xxx ;", simplifycode("; if ; else xxx ;"));
|
||||
|
|
Loading…
Reference in New Issue