Created an undocumented command line flag "--errorlist" that prints all messages
This commit is contained in:
parent
cfb4e91986
commit
5193a36a6a
|
@ -24,6 +24,7 @@
|
|||
#include "errorlogger.h"
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
class Check
|
||||
{
|
||||
|
@ -78,6 +79,13 @@ protected:
|
|||
/** report an error */
|
||||
void reportError(const std::list<const Token *> &callstack, const std::string &severity, const std::string &id, const std::string &msg)
|
||||
{
|
||||
// No errorLogger => just report the message to stdout
|
||||
if (_errorLogger == NULL)
|
||||
{
|
||||
std::cout << "(" << severity << ") " << msg << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> locationList;
|
||||
for (std::list<const Token *>::const_iterator it = callstack.begin(); it != callstack.end(); ++it)
|
||||
{
|
||||
|
|
|
@ -207,6 +207,16 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
_settings.autoDealloc(f);
|
||||
}
|
||||
|
||||
// print all possible error messages..
|
||||
else if (strcmp(argv[i], "--errorlist") == 0)
|
||||
{
|
||||
// call all "getErrorMessages" in all registered Check classes
|
||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
{
|
||||
(*it)->getErrorMessages();
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], "-", 1) == 0 || strncmp(argv[i], "--", 2) == 0)
|
||||
{
|
||||
return "cppcheck: error: unrecognized command line option \"" + std::string(argv[i]) + "\"\n";
|
||||
|
|
Loading…
Reference in New Issue