Memory leaks: Fixed TODO test case. Ticket: #2733

This commit is contained in:
Daniel Marjamäki 2011-04-20 17:16:09 +02:00
parent b1d3d291e6
commit a79e979ae4
2 changed files with 9 additions and 11 deletions

View File

@ -1812,6 +1812,14 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
done = false; 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") else if (tok2->next() && tok2->next()->str() == "if")
{ {
// Delete empty if that is not followed by an else // Delete empty if that is not followed by an else
@ -1902,14 +1910,6 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
done = false; 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; continue;
} }

View File

@ -669,9 +669,7 @@ private:
// remove outer if (#2733) // remove outer if (#2733)
ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if return use ; } return ; }")); ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if return use ; } return ; }"));
ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if(var) return use ; } return ; }")); ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if { if(var) return use ; } return ; }"));
TODO_ASSERT_EQUALS("alloc ; return ; }", ASSERT_EQUALS("alloc ; return ; }", simplifycode("alloc ; if(var) { if return use ; } return ; }"));
"alloc ; if(var) { if return use ; } return ; }",
simplifycode("alloc ; if(var) { if return use ; } return ; }"));
// "if ; .." // "if ; .."
ASSERT_EQUALS("; if xxx ;", simplifycode("; if ; else xxx ;")); ASSERT_EQUALS("; if xxx ;", simplifycode("; if ; else xxx ;"));