refactoring: Added a function to the Check base class that allows easier error reporting

This commit is contained in:
Daniel Marjamäki 2009-03-20 19:52:18 +01:00
parent ccfdbfca58
commit 8e4af409e7
1 changed files with 16 additions and 4 deletions

View File

@ -20,11 +20,11 @@
#ifndef checkH
#define checkH
#include <list>
#include "tokenize.h"
#include "settings.h"
#include "errorlogger.h"
class Tokenizer;
class Settings;
class ErrorLogger;
#include <list>
class Check
{
@ -60,6 +60,18 @@ protected:
const Tokenizer * const _tokenizer;
const Settings * const _settings;
ErrorLogger * const _errorLogger;
void reportError(const Token *tok, const char severity[], const char id[], const char msg[])
{
ErrorLogger::ErrorMessage::FileLocation loc;
loc.line = tok->linenr();
loc.file = _tokenizer->file(tok);
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
locationList.push_back(loc);
_errorLogger->reportErr(ErrorLogger::ErrorMessage(locationList, severity, id, msg));
}
};
#endif