Memory leaks: Various improvements in "simplifycode"
This commit is contained in:
parent
d5506618b6
commit
17cb374ce2
|
@ -668,6 +668,20 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce "if ; else %var% ;" => "if %var% ;"
|
||||||
|
if ( TOKEN::Match(tok2, "if ; else %var% ;") )
|
||||||
|
{
|
||||||
|
erase( tok2, tok2->tokAt(3) );
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reduce "if ; else return use ;" => "if return use ;"
|
||||||
|
if ( TOKEN::Match(tok2, "if ; else %var% ;") )
|
||||||
|
{
|
||||||
|
erase( tok2, tok2->tokAt(3) );
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Reduce "do { alloc ; } " => "alloc ;"
|
// Reduce "do { alloc ; } " => "alloc ;"
|
||||||
if ( TOKEN::Match(tok2->next, "do { alloc ; }") )
|
if ( TOKEN::Match(tok2->next, "do { alloc ; }") )
|
||||||
{
|
{
|
||||||
|
@ -771,6 +785,13 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce "[;{}] alloc ; dealloc ;" => "[;{}]"
|
||||||
|
if ( TOKEN::Match(tok2, "[;{}] alloc ; dealloc ;") )
|
||||||
|
{
|
||||||
|
erase( tok2, tok2->tokAt(5) );
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Reduce "if* alloc ; dealloc ;" => ";"
|
// Reduce "if* alloc ; dealloc ;" => ";"
|
||||||
if ( TOKEN::Match(tok2->tokAt(2), "alloc ; dealloc ;") &&
|
if ( TOKEN::Match(tok2->tokAt(2), "alloc ; dealloc ;") &&
|
||||||
tok2->next->str().find("if") == 0 )
|
tok2->next->str().find("if") == 0 )
|
||||||
|
@ -786,6 +807,20 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete second use in "use ; use ;"
|
||||||
|
if (TOKEN::Match(tok2, "[;{}] use ; dealloc ;"))
|
||||||
|
{
|
||||||
|
erase(tok2, tok2->tokAt(3));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete first use in "use ; return use ;"
|
||||||
|
if (TOKEN::Match(tok2, "[;{}] use ; return use ;"))
|
||||||
|
{
|
||||||
|
erase(tok2, tok2->tokAt(2));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete second case in "case ; case ;"
|
// Delete second case in "case ; case ;"
|
||||||
while (TOKEN::Match(tok2, "case ; case ;"))
|
while (TOKEN::Match(tok2, "case ; case ;"))
|
||||||
{
|
{
|
||||||
|
@ -967,6 +1002,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const
|
||||||
noerr |= TOKEN::Match( first, "alloc ; dealloc ; }" );
|
noerr |= TOKEN::Match( first, "alloc ; dealloc ; }" );
|
||||||
noerr |= TOKEN::Match( first, "alloc ; return use ; }" );
|
noerr |= TOKEN::Match( first, "alloc ; return use ; }" );
|
||||||
noerr |= TOKEN::Match( first, "alloc ; use ; }" );
|
noerr |= TOKEN::Match( first, "alloc ; use ; }" );
|
||||||
|
noerr |= TOKEN::Match( first, "alloc ; use ; return ; }" );
|
||||||
noerr |= TOKEN::Match( first, "if alloc ; dealloc ; }" );
|
noerr |= TOKEN::Match( first, "if alloc ; dealloc ; }" );
|
||||||
noerr |= TOKEN::Match( first, "if alloc ; return use ; }" );
|
noerr |= TOKEN::Match( first, "if alloc ; return use ; }" );
|
||||||
noerr |= TOKEN::Match( first, "if alloc ; use ; }" );
|
noerr |= TOKEN::Match( first, "if alloc ; use ; }" );
|
||||||
|
|
Loading…
Reference in New Issue