Removing false positives

This commit is contained in:
Daniel Marjamäki 2007-08-31 04:23:09 +00:00
parent 2b3f362dfd
commit 8d116542ab
8 changed files with 33 additions and 6 deletions

View File

@ -74,6 +74,7 @@ static struct VAR *ClassChecking_GetVarList(const char classname[])
// Member variable?
if ((indentlevel == 1) &&
(tok->next->str[0] == ';') &&
(strchr(tok->str,':')==0) &&
(IsName(tok->str)) &&
(strcmp(tok->str,"const") != 0 ))
{
@ -240,6 +241,16 @@ void CheckConstructors()
// Check if any variables are uninitialized
for (struct VAR *var = varlist; var; var = var->next)
{
// Is it a static member variable?
const char *pattern[] = {"","::","","=",NULL};
pattern[0] = classname;
pattern[2] = var->name;
// Locate member function implementation..
TOKEN *ftok = findtoken(tokens, pattern);
if (ftok)
continue;
if (!var->init && (var->is_pointer || !var->is_class))
{
std::ostringstream ostr;

View File

@ -247,9 +247,10 @@ static void _InFunction()
var->value = _variable::Any;
}
else if (var->value==_variable::New ||
var->value==_variable::NewA ||
var->value==_variable::Malloc )
else if (var->dealloc_level != indentlevel &&
(var->value==_variable::New ||
var->value==_variable::NewA ||
var->value==_variable::Malloc ) )
{
std::ostringstream ostr;
ostr << FileLine(it->Token) << ": Memory leak:" << VariableNames[varlist[i]->varindex];

View File

@ -510,7 +510,7 @@ void CheckCaseWithoutBreak()
if (strcmp(tok2->str,"case")==0)
{
std::ostringstream ostr;
ostr << FileLine(tok) << ": Possible bug. 'case' without 'break'.";
ostr << FileLine(tok) << ": Found 'case' without 'break'.";
ReportErr(ostr.str());
break;
}

View File

@ -1 +1 @@
[testcasebreak\testcasebreak.cpp:9]: Possible bug. 'case' without 'break'.
[testcasebreak\testcasebreak.cpp:9]: Found 'case' without 'break'.

View File

@ -1 +1 @@
[testmemleak3\testmemleak3.cpp:9]: Memory leak:str
[testmemleak3\testmemleak3.cpp:11]: Memory leak:str

0
testmemleak4/err.msg Normal file
View File

View File

@ -0,0 +1,15 @@
bool f()
{
TStringList *StringList = new TStringList;
if (asd)
{
delete StringList;
return false;
}
delete StringList;
return true;
}

0
testmemleak4/warn.msg Normal file
View File