refactoring: Added a function to the Check base class that allows easier error reporting
This commit is contained in:
parent
ccfdbfca58
commit
8e4af409e7
20
src/check.h
20
src/check.h
|
@ -20,11 +20,11 @@
|
||||||
#ifndef checkH
|
#ifndef checkH
|
||||||
#define checkH
|
#define checkH
|
||||||
|
|
||||||
#include <list>
|
#include "tokenize.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "errorlogger.h"
|
||||||
|
|
||||||
class Tokenizer;
|
#include <list>
|
||||||
class Settings;
|
|
||||||
class ErrorLogger;
|
|
||||||
|
|
||||||
class Check
|
class Check
|
||||||
{
|
{
|
||||||
|
@ -60,6 +60,18 @@ protected:
|
||||||
const Tokenizer * const _tokenizer;
|
const Tokenizer * const _tokenizer;
|
||||||
const Settings * const _settings;
|
const Settings * const _settings;
|
||||||
ErrorLogger * const _errorLogger;
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue