errormessage: Added the new errormessage handling to cppcheck

This commit is contained in:
Daniel Marjamäki 2009-01-08 17:32:33 +00:00
parent 1bc5740742
commit 2a2adb037a
3 changed files with 9 additions and 10 deletions

View File

@ -19,6 +19,8 @@
#include "checkmemoryleak.h"
#include "errormessage.h"
#include <stdlib.h> // free
#include <algorithm>
@ -310,17 +312,11 @@ void CheckMemoryLeakClass::MismatchError(const Token *Tok1, const std::list<cons
void CheckMemoryLeakClass::MemoryLeak(const Token *tok, const char varname[], AllocType alloctype)
{
std::ostringstream errmsg;
errmsg << _tokenizer->fileLine(tok);
if (alloctype == CheckMemoryLeakClass::FOPEN ||
alloctype == CheckMemoryLeakClass::POPEN)
errmsg << ": Resource leak: ";
_errorLogger->reportErr(ErrorMessage::resourceLeak(_tokenizer, tok, varname));
else
errmsg << ": Memory leak: ";
errmsg << varname;
_errorLogger->reportErr(errmsg.str());
_errorLogger->reportErr(ErrorMessage::memleak(_tokenizer, tok, varname));
}
//---------------------------------------------------------------------------

View File

@ -28,6 +28,8 @@
#include "checkfunctionusage.h"
#include "filelister.h"
#include "errormessage.h"
#include <algorithm>
#include <sstream>
#include <cstring>
@ -271,7 +273,8 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
// Memory leak
CheckMemoryLeakClass checkMemoryLeak(&_tokenizer, _settings, this);
checkMemoryLeak.CheckMemoryLeak();
if ( ErrorMessage::memleak(_settings) )
checkMemoryLeak.CheckMemoryLeak();
// Check that all class constructors are ok.
checkClass.constructors();

View File

@ -12,9 +12,9 @@ The "simple" tasks
- etc?
* Add unit tests
* improved error message handling
* Perhaps the parseArgs function should be moved to the class Settings instead?
New checks (bugs)
* sprintf problem with overlapping data
* CheckMemoryLeak
- Check for more resource leaks
Windows API (CreatePen, GetDC, ..)