Suppressed unused functions should not lead to nonzero exit code (#1026) (#1078)

This is a fix of commit 97ffec8.
This commit is contained in:
Ivan Maidanski 2018-02-06 09:44:53 +03:00 committed by Daniel Marjamäki
parent 8a3c25210d
commit f487182075
6 changed files with 12 additions and 9 deletions

View File

@ -2108,7 +2108,7 @@ bool CheckBufferOverrun::analyseWholeProgram(const std::list<Check::FileInfo*> &
errors = true;
}
}
return errors;
return errors && errorLogger.hasErrors();
}
unsigned int CheckBufferOverrun::sizeOfType(const Token *type) const

View File

@ -1606,6 +1606,5 @@ bool CheckUninitVar::analyseWholeProgram(const std::list<Check::FileInfo*> &file
}
}
return foundErrors;
return foundErrors && errorLogger.hasErrors();
}

View File

@ -264,7 +264,7 @@ bool CheckUnusedFunctions::check(ErrorLogger * const errorLogger, const Settings
*/
}
}
return errors;
return errors && errorLogger->hasErrors();
}
void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,

View File

@ -191,6 +191,8 @@ private:
*/
virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
virtual bool hasErrors() const { return exitcode > 0; }
/**
* @brief Information about progress is directed here.
*

View File

@ -331,6 +331,12 @@ public:
*/
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;
/**
* Returns true if an error has been reported which should
* cause a non-zero cppcheck exit code.
*/
virtual bool hasErrors() const { return false; }
/**
* Report progress to client
* @param filename main file that is checked

View File

@ -77,11 +77,7 @@ private:
// Check for unused functions..
CheckUnusedFunctions checkUnusedFunctions(&tokenizer, &settings, this);
checkUnusedFunctions.parseTokens(tokenizer, "someFile.c", &settings);
// check() returns error if and only if errout is not empty.
if (checkUnusedFunctions.check(this, settings))
ASSERT(errout.str() != "");
else
ASSERT_EQUALS("", errout.str());
ASSERT(!checkUnusedFunctions.check(this, settings));
}
void incondition() {