CheckMemoryLeakInFunction: More sensitive checking when the code calls an unknown function

This commit is contained in:
Daniel Marjamäki 2009-06-21 14:12:59 +02:00
parent f28dec1f5a
commit 8715ba1458
2 changed files with 10 additions and 2 deletions

View File

@ -1353,6 +1353,14 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
done = false;
}
// Delete "callfunc ;" that is followed by "use|if|callfunc"
// If the function doesn't throw exception or exit the application, then the "callfunc" is not needed
if (Token::Match(tok2, "callfunc ; use|if|callfunc"))
{
tok2->deleteThis();
done = false;
}
// Delete second case in "case ; case ;"
while (Token::simpleMatch(tok2, "case ; case ;"))
{

View File

@ -1960,8 +1960,8 @@ private:
" a();\n"
" if (b) return;\n"
" delete [] p;\n"
"}\n", true);
ASSERT_EQUALS("[test.cpp:5]: (all) Memory leak: p\n", errout.str());
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
}