Memory leaks: remove redundant 'if return ; else|'
This commit is contained in:
parent
aae2986361
commit
84d9282da2
|
@ -1549,6 +1549,16 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
|||
}
|
||||
}
|
||||
|
||||
if (Token::Match(tok, ";| if return ;"))
|
||||
{
|
||||
tok->deleteThis();
|
||||
tok->deleteThis();
|
||||
if (tok->str() == "return")
|
||||
tok->deleteThis();
|
||||
if (tok->strAt(1) == "else")
|
||||
tok->deleteNext();
|
||||
}
|
||||
|
||||
// simplify "while1" contents..
|
||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||
{
|
||||
|
|
|
@ -695,9 +695,9 @@ private:
|
|||
|
||||
// switch..
|
||||
ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;"));
|
||||
ASSERT_EQUALS("; if return ;", simplifycode("; switch { case ; return ; default ; break ; }"));
|
||||
ASSERT_EQUALS("; if return ;", simplifycode("; switch { case ; if { return ; } break ; default ; break ; }"));
|
||||
ASSERT_EQUALS("; if return ; else use ;", simplifycode("; switch { case ; return ; default ; use ; break ; }"));
|
||||
ASSERT_EQUALS(";", simplifycode("; switch { case ; return ; default ; break ; }"));
|
||||
ASSERT_EQUALS(";", simplifycode("; switch { case ; if { return ; } break ; default ; break ; }"));
|
||||
ASSERT_EQUALS("; use ;", simplifycode("; switch { case ; return ; default ; use ; break ; }"));
|
||||
ASSERT_EQUALS("; use ;", simplifycode("; while1 { loop { ; } switch { case ; dealloc ; return ; default ; break ; } }"));
|
||||
ASSERT_EQUALS("; { dealloc ; return ; } }", simplifycode("switch { case ; case ; dealloc ; return ; default ; dealloc ; return ; } }"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue