Fix #825 (Error with id syntaxError not in list printed with --errorlist)
http://sourceforge.net/apps/trac/cppcheck/ticket/825
This commit is contained in:
parent
4e9f4d4abc
commit
34fe032dbe
15
src/check.h
15
src/check.h
|
@ -78,6 +78,16 @@ public:
|
|||
/** get information about this class, used to generate documentation */
|
||||
virtual std::string classInfo() const = 0;
|
||||
|
||||
/**
|
||||
* Write given error to errorlogger or to out stream in xml format.
|
||||
* This is for for printout out the error list with --errorlist
|
||||
* @param errmsg Error message to write
|
||||
*/
|
||||
static void reportError(const ErrorLogger::ErrorMessage &errmsg)
|
||||
{
|
||||
std::cout << errmsg.toXML() << std::endl;
|
||||
}
|
||||
|
||||
protected:
|
||||
const Tokenizer * const _tokenizer;
|
||||
const Settings * const _settings;
|
||||
|
@ -113,13 +123,14 @@ protected:
|
|||
}
|
||||
|
||||
const ErrorLogger::ErrorMessage errmsg(locationList, Severity::stringify(severity), msg, id);
|
||||
|
||||
if (_errorLogger)
|
||||
_errorLogger->reportErr(errmsg);
|
||||
else
|
||||
std::cout << errmsg.toXML() << std::endl;
|
||||
reportError(errmsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** compare the names of Check classes, used when sorting the Check descendants */
|
||||
bool operator<(const Check *other) const
|
||||
|
|
|
@ -273,6 +273,10 @@ void CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
{
|
||||
(*it)->getErrorMessages();
|
||||
}
|
||||
|
||||
Tokenizer tokenizer(&_settings, 0);
|
||||
tokenizer.getErrorMessages();
|
||||
|
||||
std::cout << ErrorLogger::ErrorMessage::getXMLFooter() << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "mathlib.h"
|
||||
#include "settings.h"
|
||||
#include "errorlogger.h"
|
||||
#include "check.h"
|
||||
|
||||
#include <locale>
|
||||
#include <fstream>
|
||||
|
@ -3970,7 +3971,7 @@ void Tokenizer::syntaxError(const Token *tok, char c)
|
|||
_tokens->printOut();
|
||||
}
|
||||
|
||||
if (!_errorLogger)
|
||||
if (!_errorLogger && tok)
|
||||
{
|
||||
std::ostringstream err;
|
||||
err << "### Unlogged error at Tokenizer::syntaxError: Invalid number of character (" << c << ")";
|
||||
|
@ -3986,15 +3987,23 @@ void Tokenizer::syntaxError(const Token *tok, char c)
|
|||
}
|
||||
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||
loc.line = tok->linenr();
|
||||
loc.file = file(tok);
|
||||
locationList.push_back(loc);
|
||||
_errorLogger->reportErr(
|
||||
ErrorLogger::ErrorMessage(locationList,
|
||||
"error",
|
||||
std::string("Invalid number of character (") + c + "). Can't process file.",
|
||||
"syntaxError"));
|
||||
if (tok)
|
||||
{
|
||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||
loc.line = tok->linenr();
|
||||
loc.file = file(tok);
|
||||
locationList.push_back(loc);
|
||||
}
|
||||
|
||||
const ErrorLogger::ErrorMessage errmsg(locationList,
|
||||
"error",
|
||||
std::string("Invalid number of character (") + c + "). Can't process file.",
|
||||
"syntaxError");
|
||||
|
||||
if (_errorLogger)
|
||||
_errorLogger->reportErr(errmsg);
|
||||
else
|
||||
Check::reportError(errmsg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -4334,3 +4343,8 @@ std::string Tokenizer::simplifyString(const std::string &source)
|
|||
|
||||
return str;
|
||||
}
|
||||
|
||||
void Tokenizer::getErrorMessages()
|
||||
{
|
||||
syntaxError(0, ' ');
|
||||
}
|
||||
|
|
|
@ -110,6 +110,11 @@ public:
|
|||
*/
|
||||
static const Token *findClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel);
|
||||
|
||||
/**
|
||||
* get error messages
|
||||
*/
|
||||
virtual void getErrorMessages();
|
||||
|
||||
/**
|
||||
* List of classes in currently checked source code and
|
||||
* their member functions and member variables.
|
||||
|
|
Loading…
Reference in New Issue