pass `Suppressions` separately from `const Settings` into executors (#5278)
This commit is contained in:
parent
de8b4150a8
commit
a17f6e89d1
|
@ -285,13 +285,13 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
|
|||
unsigned int returnValue = 0;
|
||||
if (settings.useSingleJob()) {
|
||||
// Single process
|
||||
SingleExecutor executor(cppcheck, mFiles, settings, *this);
|
||||
SingleExecutor executor(cppcheck, mFiles, settings, settings.nomsg, *this);
|
||||
returnValue = executor.check();
|
||||
} else {
|
||||
#if defined(THREADING_MODEL_THREAD)
|
||||
ThreadExecutor executor(mFiles, settings, *this);
|
||||
ThreadExecutor executor(mFiles, settings, settings.nomsg, *this);
|
||||
#elif defined(THREADING_MODEL_FORK)
|
||||
ProcessExecutor executor(mFiles, settings, *this);
|
||||
ProcessExecutor executor(mFiles, settings, settings.nomsg, *this);
|
||||
#endif
|
||||
returnValue = executor.check();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include <sstream> // IWYU pragma: keep
|
||||
#include <utility>
|
||||
|
||||
Executor::Executor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
||||
: mFiles(files), mSettings(settings), mErrorLogger(errorLogger)
|
||||
Executor::Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
|
||||
: mFiles(files), mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger)
|
||||
{}
|
||||
|
||||
Executor::~Executor()
|
||||
|
@ -36,7 +36,7 @@ Executor::~Executor()
|
|||
|
||||
bool Executor::hasToLog(const ErrorMessage &msg)
|
||||
{
|
||||
if (!mSettings.nomsg.isSuppressed(msg))
|
||||
if (!mSuppressions.isSuppressed(msg))
|
||||
{
|
||||
std::string errmsg = msg.toString(mSettings.verbose);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
class Settings;
|
||||
class ErrorLogger;
|
||||
class ErrorMessage;
|
||||
class Suppressions;
|
||||
|
||||
/// @addtogroup CLI
|
||||
/// @{
|
||||
|
@ -38,7 +39,7 @@ class ErrorMessage;
|
|||
*/
|
||||
class Executor {
|
||||
public:
|
||||
Executor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
||||
Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
|
||||
virtual ~Executor();
|
||||
|
||||
Executor(const Executor &) = delete;
|
||||
|
@ -65,7 +66,8 @@ protected:
|
|||
bool hasToLog(const ErrorMessage &msg);
|
||||
|
||||
const std::map<std::string, std::size_t> &mFiles;
|
||||
Settings &mSettings;
|
||||
const Settings &mSettings;
|
||||
Suppressions &mSuppressions;
|
||||
ErrorLogger &mErrorLogger;
|
||||
|
||||
private:
|
||||
|
|
|
@ -61,8 +61,8 @@ enum class Color;
|
|||
using std::memset;
|
||||
|
||||
|
||||
ProcessExecutor::ProcessExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, errorLogger)
|
||||
ProcessExecutor::ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, suppressions, errorLogger)
|
||||
{
|
||||
assert(mSettings.jobs > 1);
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
|
|||
"cppcheckError",
|
||||
Certainty::normal);
|
||||
|
||||
if (!mSettings.nomsg.isSuppressed(errmsg))
|
||||
if (!mSuppressions.isSuppressed(errmsg))
|
||||
mErrorLogger.reportErr(errmsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
class Settings;
|
||||
class ErrorLogger;
|
||||
class Suppressions;
|
||||
|
||||
/// @addtogroup CLI
|
||||
/// @{
|
||||
|
@ -37,7 +38,7 @@ class ErrorLogger;
|
|||
*/
|
||||
class ProcessExecutor : public Executor {
|
||||
public:
|
||||
ProcessExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
||||
ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
|
||||
ProcessExecutor(const ProcessExecutor &) = delete;
|
||||
~ProcessExecutor() override;
|
||||
void operator=(const ProcessExecutor &) = delete;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
|
||||
class ErrorLogger;
|
||||
|
||||
SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, errorLogger)
|
||||
SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, suppressions, errorLogger)
|
||||
, mCppcheck(cppcheck)
|
||||
{
|
||||
assert(mSettings.jobs == 1);
|
||||
|
|
|
@ -28,11 +28,12 @@
|
|||
class ErrorLogger;
|
||||
class Settings;
|
||||
class CppCheck;
|
||||
class Suppressions;
|
||||
|
||||
class SingleExecutor : public Executor
|
||||
{
|
||||
public:
|
||||
SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
||||
SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
|
||||
SingleExecutor(const SingleExecutor &) = delete;
|
||||
~SingleExecutor() override;
|
||||
void operator=(const SingleExecutor &) = delete;
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
|
||||
enum class Color;
|
||||
|
||||
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, errorLogger)
|
||||
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
|
||||
: Executor(files, settings, suppressions, errorLogger)
|
||||
{
|
||||
assert(mSettings.jobs > 1);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
class Settings;
|
||||
class ErrorLogger;
|
||||
class Suppressions;
|
||||
|
||||
/// @addtogroup CLI
|
||||
/// @{
|
||||
|
@ -37,7 +38,7 @@ class ErrorLogger;
|
|||
*/
|
||||
class ThreadExecutor : public Executor {
|
||||
public:
|
||||
ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
|
||||
ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
|
||||
ThreadExecutor(const ThreadExecutor &) = delete;
|
||||
~ThreadExecutor() override;
|
||||
void operator=(const ThreadExecutor &) = delete;
|
||||
|
|
|
@ -82,7 +82,7 @@ private:
|
|||
if (opt.plistOutput)
|
||||
settings.plistOutput = opt.plistOutput;
|
||||
// TODO: test with settings.project.fileSettings;
|
||||
ProcessExecutor executor(filemap, settings, *this);
|
||||
ProcessExecutor executor(filemap, settings, settings.nomsg, *this);
|
||||
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
|
||||
scopedfiles.reserve(filemap.size());
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)
|
||||
|
|
|
@ -117,7 +117,7 @@ private:
|
|||
filemap.clear();
|
||||
|
||||
// TODO: test with settings.project.fileSettings;
|
||||
SingleExecutor executor(cppcheck, filemap, settings, *this);
|
||||
SingleExecutor executor(cppcheck, filemap, settings, settings.nomsg, *this);
|
||||
ASSERT_EQUALS(result, executor.check());
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ private:
|
|||
if (!suppression.empty()) {
|
||||
EXPECT_EQ("", settings.nomsg.addSuppressionLine(suppression));
|
||||
}
|
||||
SingleExecutor executor(cppCheck, files, settings, *this);
|
||||
SingleExecutor executor(cppCheck, files, settings, settings.nomsg, *this);
|
||||
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
|
||||
scopedfiles.reserve(files.size());
|
||||
for (std::map<std::string, std::string>::const_iterator i = f.cbegin(); i != f.cend(); ++i)
|
||||
|
@ -233,7 +233,7 @@ private:
|
|||
if (!suppression.empty()) {
|
||||
EXPECT_EQ("", settings.nomsg.addSuppressionLine(suppression));
|
||||
}
|
||||
ThreadExecutor executor(files, settings, *this);
|
||||
ThreadExecutor executor(files, settings, settings.nomsg, *this);
|
||||
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
|
||||
scopedfiles.reserve(files.size());
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = files.cbegin(); i != files.cend(); ++i)
|
||||
|
@ -261,7 +261,7 @@ private:
|
|||
if (!suppression.empty()) {
|
||||
EXPECT_EQ("", settings.nomsg.addSuppressionLine(suppression));
|
||||
}
|
||||
ProcessExecutor executor(files, settings, *this);
|
||||
ProcessExecutor executor(files, settings, settings.nomsg, *this);
|
||||
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
|
||||
scopedfiles.reserve(files.size());
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = files.cbegin(); i != files.cend(); ++i)
|
||||
|
|
|
@ -83,7 +83,7 @@ private:
|
|||
if (opt.plistOutput)
|
||||
settings1.plistOutput = opt.plistOutput;
|
||||
// TODO: test with settings.project.fileSettings;
|
||||
ThreadExecutor executor(filemap, settings1, *this);
|
||||
ThreadExecutor executor(filemap, settings1, settings1.nomsg, *this);
|
||||
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
|
||||
scopedfiles.reserve(filemap.size());
|
||||
for (std::map<std::string, std::size_t>::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)
|
||||
|
|
Loading…
Reference in New Issue