Added Cppcheck::terminate function that will terminate the checking ASAP
This commit is contained in:
parent
cd31cd9298
commit
53d036fadf
|
@ -436,7 +436,10 @@ unsigned int CppCheck::check()
|
|||
for (unsigned int c = 0; c < _filenames.size(); c++)
|
||||
{
|
||||
_errout.str("");
|
||||
std::string fname = _filenames[c];
|
||||
const std::string fname = _filenames[c];
|
||||
|
||||
if (_settings.terminated())
|
||||
break;
|
||||
|
||||
if (_settings._errorsOnly == false)
|
||||
_errorLogger.reportOut(std::string("Checking ") + fname + std::string("..."));
|
||||
|
@ -519,6 +522,9 @@ unsigned int CppCheck::check()
|
|||
|
||||
void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||
{
|
||||
if (_settings.terminated())
|
||||
return;
|
||||
|
||||
Tokenizer _tokenizer(&_settings, this);
|
||||
|
||||
// Tokenize the file
|
||||
|
@ -542,6 +548,9 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
// call all "runChecks" in all registered Check classes
|
||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
{
|
||||
if (_settings.terminated())
|
||||
return;
|
||||
|
||||
TIMER_START();
|
||||
(*it)->runChecks(&_tokenizer, &_settings, this);
|
||||
TIMER_END((*it)->name() << "::runChecks");
|
||||
|
@ -567,6 +576,9 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
// call all "runSimplifiedChecks" in all registered Check classes
|
||||
for (std::list<Check *>::iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
{
|
||||
if (_settings.terminated())
|
||||
return;
|
||||
|
||||
TIMER_START();
|
||||
(*it)->runSimplifiedChecks(&_tokenizer, &_settings, this);
|
||||
TIMER_END((*it)->name() << "::runSimplifiedChecks");
|
||||
|
|
|
@ -116,6 +116,14 @@ public:
|
|||
|
||||
virtual void reportStatus(unsigned int index, unsigned int max);
|
||||
|
||||
/**
|
||||
* Terminate checking. The checking will be terminated ASAP.
|
||||
*/
|
||||
void terminate()
|
||||
{
|
||||
_settings.terminate();
|
||||
}
|
||||
|
||||
private:
|
||||
void checkFile(const std::string &code, const char FileName[]);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ Settings::Settings()
|
|||
_exitCode = 0;
|
||||
_showtime = false;
|
||||
_append = "";
|
||||
_terminate = false;
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
|
|
|
@ -45,6 +45,9 @@ private:
|
|||
|
||||
/** enable extra checks by id */
|
||||
std::map<std::string, bool> _enabled;
|
||||
|
||||
/** terminate checking */
|
||||
bool _terminate;
|
||||
public:
|
||||
Settings();
|
||||
virtual ~Settings();
|
||||
|
@ -56,6 +59,18 @@ public:
|
|||
bool _inlineSuppressions;
|
||||
bool _verbose;
|
||||
|
||||
/** Request termination of checking */
|
||||
void terminate()
|
||||
{
|
||||
_terminate = true;
|
||||
}
|
||||
|
||||
/** termination? */
|
||||
bool terminated() const
|
||||
{
|
||||
return _terminate;
|
||||
}
|
||||
|
||||
/** Force checking t he files with "too many" configurations. */
|
||||
bool _force;
|
||||
|
||||
|
|
Loading…
Reference in New Issue