memory leak : Minor fixes to make the unit tests work
This commit is contained in:
parent
a66a91c22a
commit
b72565bdf6
|
@ -643,6 +643,14 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce "if* ;" that is not followed by an else..
|
||||||
|
if (TOKEN::Match(tok2->next(), "if(var)|if(!var)|if(true)|if(false)|ifv ;") &&
|
||||||
|
!TOKEN::Match(tok2->tokAt(3), "else"))
|
||||||
|
{
|
||||||
|
erase(tok2, tok2->tokAt(2));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Reduce "if if" => "if"
|
// Reduce "if if" => "if"
|
||||||
if ( TOKEN::Match(tok2, "if if") )
|
if ( TOKEN::Match(tok2, "if if") )
|
||||||
{
|
{
|
||||||
|
@ -707,21 +715,20 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce "if ; else return use ;" => "if return use ;"
|
// Reduce "if ; else return use ;" => "if return use ;"
|
||||||
if ( TOKEN::Match(tok2, "if ; else %var% ;") )
|
if ( TOKEN::Match(tok2, "if ; else return use ;") )
|
||||||
{
|
{
|
||||||
erase( tok2, tok2->tokAt(3) );
|
erase( tok2, tok2->tokAt(3) );
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce "do { alloc ; } " => "alloc ;"
|
// Reduce "do { alloc ; } " => "alloc ;"
|
||||||
/* TODO : This could hide memory leaks
|
// TODO: If the loop can be executed twice reduce to "loop alloc ;" instead
|
||||||
if ( TOKEN::Match(tok2->next(), "do { alloc ; }") )
|
if ( TOKEN::Match(tok2->next(), "do { alloc ; }") )
|
||||||
{
|
{
|
||||||
erase(tok2, tok2->tokAt(3));
|
erase(tok2, tok2->tokAt(3));
|
||||||
erase(tok2->next()->next(), tok2->tokAt(4));
|
erase(tok2->next()->next(), tok2->tokAt(4));
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Reduce "loop if break ; => ";"
|
// Reduce "loop if break ; => ";"
|
||||||
if ( TOKEN::Match( tok2->next(), "loop if break|continue ; ") &&
|
if ( TOKEN::Match( tok2->next(), "loop if break|continue ; ") &&
|
||||||
|
|
Loading…
Reference in New Issue