diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index cb07f3f35..06dcd5972 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -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(); } diff --git a/cli/executor.cpp b/cli/executor.cpp index 7185db07b..489d9f895 100644 --- a/cli/executor.cpp +++ b/cli/executor.cpp @@ -27,8 +27,8 @@ #include // IWYU pragma: keep #include -Executor::Executor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) - : mFiles(files), mSettings(settings), mErrorLogger(errorLogger) +Executor::Executor(const std::map &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); diff --git a/cli/executor.h b/cli/executor.h index f8f010c2d..1b7db25e7 100644 --- a/cli/executor.h +++ b/cli/executor.h @@ -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 &files, Settings &settings, ErrorLogger &errorLogger); + Executor(const std::map &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 &mFiles; - Settings &mSettings; + const Settings &mSettings; + Suppressions &mSuppressions; ErrorLogger &mErrorLogger; private: diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index e6aca40ee..445b545f8 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -61,8 +61,8 @@ enum class Color; using std::memset; -ProcessExecutor::ProcessExecutor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) - : Executor(files, settings, errorLogger) +ProcessExecutor::ProcessExecutor(const std::map &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); } diff --git a/cli/processexecutor.h b/cli/processexecutor.h index c472fe895..4b51d596a 100644 --- a/cli/processexecutor.h +++ b/cli/processexecutor.h @@ -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 &files, Settings &settings, ErrorLogger &errorLogger); + ProcessExecutor(const std::map &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); ProcessExecutor(const ProcessExecutor &) = delete; ~ProcessExecutor() override; void operator=(const ProcessExecutor &) = delete; diff --git a/cli/singleexecutor.cpp b/cli/singleexecutor.cpp index ce7476f3d..4de711a2c 100644 --- a/cli/singleexecutor.cpp +++ b/cli/singleexecutor.cpp @@ -30,8 +30,8 @@ class ErrorLogger; -SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map &files, Settings &settings, ErrorLogger &errorLogger) - : Executor(files, settings, errorLogger) +SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger) + : Executor(files, settings, suppressions, errorLogger) , mCppcheck(cppcheck) { assert(mSettings.jobs == 1); diff --git a/cli/singleexecutor.h b/cli/singleexecutor.h index 74143be7c..4ca53768b 100644 --- a/cli/singleexecutor.h +++ b/cli/singleexecutor.h @@ -28,11 +28,12 @@ class ErrorLogger; class Settings; class CppCheck; +class Suppressions; class SingleExecutor : public Executor { public: - SingleExecutor(CppCheck &cppcheck, const std::map &files, Settings &settings, ErrorLogger &errorLogger); + SingleExecutor(CppCheck &cppcheck, const std::map &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); SingleExecutor(const SingleExecutor &) = delete; ~SingleExecutor() override; void operator=(const SingleExecutor &) = delete; diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 8efdfeea7..26c3c03aa 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -40,8 +40,8 @@ enum class Color; -ThreadExecutor::ThreadExecutor(const std::map &files, Settings &settings, ErrorLogger &errorLogger) - : Executor(files, settings, errorLogger) +ThreadExecutor::ThreadExecutor(const std::map &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger) + : Executor(files, settings, suppressions, errorLogger) { assert(mSettings.jobs > 1); } diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index 5c24dfe0c..62ad8e0a8 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -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 &files, Settings &settings, ErrorLogger &errorLogger); + ThreadExecutor(const std::map &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); ThreadExecutor(const ThreadExecutor &) = delete; ~ThreadExecutor() override; void operator=(const ThreadExecutor &) = delete; diff --git a/test/testprocessexecutor.cpp b/test/testprocessexecutor.cpp index 100aaa580..f9cf2d0d9 100644 --- a/test/testprocessexecutor.cpp +++ b/test/testprocessexecutor.cpp @@ -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> scopedfiles; scopedfiles.reserve(filemap.size()); for (std::map::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i) diff --git a/test/testsingleexecutor.cpp b/test/testsingleexecutor.cpp index beb1dd78f..9208ca72e 100644 --- a/test/testsingleexecutor.cpp +++ b/test/testsingleexecutor.cpp @@ -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()); } diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 22061415b..f1c6a7d8a 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -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> scopedfiles; scopedfiles.reserve(files.size()); for (std::map::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> scopedfiles; scopedfiles.reserve(files.size()); for (std::map::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> scopedfiles; scopedfiles.reserve(files.size()); for (std::map::const_iterator i = files.cbegin(); i != files.cend(); ++i) diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index d438dfa13..8d7f11bc5 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -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> scopedfiles; scopedfiles.reserve(filemap.size()); for (std::map::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)