Minor improvement to code comments.

This commit is contained in:
Reijo Tomperi 2008-12-01 22:33:21 +00:00
parent b886702d0d
commit 9b56be86c6
2 changed files with 28 additions and 17 deletions

View File

@ -283,12 +283,6 @@ bool CheckMemoryLeakClass::notvar(const TOKEN *tok, const char *varnames[])
TOKEN::Match(tok, "%var1% == 0", varnames) );
}
/**
* Extract a new tokens list that is easier to parse than the "tokens"
* tok - start parse token
* varname - name of variable
*/
TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *> callstack, const char varname[], AllocType &alloctype, AllocType &dealloctype)
{
const char *varnames[2];
@ -385,7 +379,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
TOKEN::Match(tok, "if ( 0 != %var1% )", varnames) )
{
addtoken("if(var)");
// Make sure the "use" will not be added
while ( tok->str() != ")" )
tok = tok->next;
@ -533,12 +527,6 @@ void CheckMemoryLeakClass::erase(TOKEN *begin, const TOKEN *end)
}
}
/**
* Simplify code
* \param tok first token
*/
void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
{
// reduce the code..
@ -636,14 +624,14 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok)
{
erase(tok2, tok2->tokAt(2));
done = false;
}
}
// Delete if block: "alloc; if return use ;"
if (TOKEN::Match(tok2,"alloc ; if return use ;") && !TOKEN::Match(tok2->tokAt(6),"else"))
{
erase(tok2, tok2->tokAt(5));
done = false;
}
}
// Reduce "if return ; alloc ;" => "alloc ;"

View File

@ -61,9 +61,32 @@ private:
void CheckMemoryLeak_ClassMembers();
void CheckMemoryLeak_InFunction();
void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] );
void simplifycode(TOKEN *tok);
/**
* Simplify code e.g. by replacing empty "{ }" with ";"
* @param tok first token. The tokens list can be modified.
*/
void simplifycode(TOKEN *tok);
/**
* Delete tokens between begin and end. E.g. if begin = 1
* and end = 5, tokens 2,3 and 4 would be erased.
*
* @param begin Tokens after this will be erased.
* @param end Tokens before this will be erased.
*/
void erase(TOKEN *begin, const TOKEN *end);
/**
* Extract a new tokens list that is easier to parse than the "tokens"
* @param tok start parse token
* @param callstack callstack
* @param varname name of variable
* @param alloctype
* @param dealloctype
* @return Newly allocated token array. Caller needs to release reserved
* memory by calling Tokenizer::deleteTokens(returnValue);
*/
TOKEN *getcode(const TOKEN *tok, std::list<const TOKEN *> callstack, const char varname[], AllocType &alloctype, AllocType &dealloctype);
bool notvar(const TOKEN *tok, const char *varnames[]);
void instoken(TOKEN *tok, const char str[]);