Minor optimizations and fixes

This commit is contained in:
Nicolas Le Cam 2008-12-21 11:43:05 +00:00
parent d44523144a
commit cbf9067de0
3 changed files with 9 additions and 6 deletions

View File

@ -193,6 +193,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
// Goto the end of the for loop..
while (tok2 && !TOKEN::Match(tok2,")"))
tok2 = tok2->next();
if (!tok2 || !(tok2->tokAt(5)))
if (!(tok2->tokAt(5)))
break;
@ -200,7 +201,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
pattern << "%var1% [ " << strindex << " ]";
int indentlevel2 = 0;
while (tok2)
while (tok2 = tok2->next())
{
if ( (tok2->str() == ";") && indentlevel2 == 0 )
break;
@ -221,7 +222,6 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope( const TOKEN *tok, c
break;
}
tok2 = tok2->next();
}
continue;
}
@ -361,6 +361,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
unsigned int size = 0;
const char *type = 0;
unsigned int varid = 0;
int nextTok = 0;
if (TOKEN::Match(tok, "%type% %var% [ %num% ] ;"))
{
@ -368,13 +369,15 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
size = strtoul(tok->strAt(3), NULL, 10);
type = tok->aaaa();
varid = tok->tokAt(1)->varId();
nextTok = 6;
}
else if (indentlevel > 0 && TOKEN::Match(tok, "[*;{}] %var% = new %type% [ %num% ]"))
else if (TOKEN::Match(tok, "[*;{}] %var% = new %type% [ %num% ]"))
{
varname[0] = tok->strAt(1);
size = strtoul(tok->strAt(6), NULL, 10);
type = tok->strAt(4);
varid = tok->tokAt(1)->varId();
nextTok = 8;
}
else
{
@ -387,7 +390,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_LocalVariable()
// The callstack is empty
_callStack.clear();
CheckBufferOverrun_CheckScope( tok->tokAt(5), varname, size, total_size, varid );
CheckBufferOverrun_CheckScope( tok->tokAt(nextTok), varname, size, total_size, varid );
}
}
}

View File

@ -1139,7 +1139,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_InFunction()
if ( TOKEN::Match(tok, ") {") )
infunc = true;
if ( TOKEN::Match(tok, "[;}]") )
else if ( TOKEN::Match(tok, "[;}]") )
infunc = false;
}

View File

@ -1294,7 +1294,7 @@ void Tokenizer::fillFunctionList()
else if (TOKEN::Match(tok, "%var% ("))
{
// Check if this is the first token of a function implementation..
for ( const TOKEN *tok2 = tok; tok2; tok2 = tok2->next() )
for ( const TOKEN *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next() )
{
if ( tok2->str() == ";" )
{