Memory leaks: Reverted the sensitive checking in r536. And improved the

simplifycode function.
This commit is contained in:
Daniel Marjamäki 2008-11-27 07:27:50 +00:00
parent 997f4e6165
commit 6fcbbf21ee
2 changed files with 21 additions and 23 deletions

View File

@ -225,12 +225,10 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
while ( func_ && func_->str() == ";" )
func_ = func_->next;
/*
for (const TOKEN *t = func_; t; t = t->next)
for (const TOKEN *t = func; t; t = t->next)
{
std::cout << t->str() << "\n";
}
*/
const char *ret = 0;
if (TOKEN::findmatch(func_, "goto"))
@ -240,11 +238,12 @@ const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list<const
ret = "dealloc";
else if ( TOKEN::findmatch(func_, "use") )
ret = "use";
}
else if (TOKEN::Match(func_, "dealloc"))
ret = "dealloc";
else if (TOKEN::Match(func_, "use"))
ret = "use";
}
else if ( TOKEN::findmatch(func_, "dealloc") )
ret = "dealloc";
else if ( TOKEN::findmatch(func_, "use") )
ret = "use";
Tokenizer::deleteTokens(func);
return ret;
}
@ -318,6 +317,11 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
rethead = newtok; \
rettail=newtok; \
}
// The first token should be ";"
addtoken(";");
bool isloop = false;
@ -616,20 +620,14 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
done = false;
}
// Delete empty if that is not followed by an else
if ( TOKEN::Match(tok2,"[;{}] if ;") ||
TOKEN::Match(tok2,"[;{}] if(var) ;") ||
TOKEN::Match(tok2,"[;{}] if(!var) ;") ||
TOKEN::Match(tok2,"[;{}] if(true) ;") ||
TOKEN::Match(tok2,"[;{}] if(false) ;") ||
TOKEN::Match(tok2,"[;{}] ifv ;") )
{
if ( ! TOKEN::Match(tok2->tokAt(3), "else") )
{
erase(tok2, tok2->tokAt(3));
done = false;
continue;
}
// Delete empty if that is not followed by an else
if (tok2->tokAt(2) &&
(tok2->next->str().find("if") == 0) &&
TOKEN::Match(tok2->tokAt(2), ";") &&
!TOKEN::Match(tok2->tokAt(3), "else"))
{
erase(tok2, tok2->tokAt(2));
done = false;
}
// Delete "if ; else ;"

View File

@ -112,7 +112,7 @@ private:
TEST_CASE( func4 );
TEST_CASE( func5 );
TEST_CASE( func6 );
TEST_CASE( func7 );
// TODO TEST_CASE( func7 );
TEST_CASE( class1 );
TEST_CASE( class2 );