errormessage: Added the new errormessage handling to cppcheck
This commit is contained in:
parent
1bc5740742
commit
2a2adb037a
|
@ -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));
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "checkfunctionusage.h"
|
||||
#include "filelister.h"
|
||||
|
||||
#include "errormessage.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
@ -271,6 +273,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
|
||||
// Memory leak
|
||||
CheckMemoryLeakClass checkMemoryLeak(&_tokenizer, _settings, this);
|
||||
if ( ErrorMessage::memleak(_settings) )
|
||||
checkMemoryLeak.CheckMemoryLeak();
|
||||
|
||||
// Check that all class constructors are ok.
|
||||
|
|
|
@ -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, ..)
|
||||
|
|
Loading…
Reference in New Issue