Skip to content

Commit a17f6e8

Browse files
authored
pass Suppressions separately from const Settings into executors (#5278)
1 parent de8b415 commit a17f6e8

13 files changed

Lines changed: 29 additions & 24 deletions

cli/cppcheckexecutor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
285285
unsigned int returnValue = 0;
286286
if (settings.useSingleJob()) {
287287
// Single process
288-
SingleExecutor executor(cppcheck, mFiles, settings, *this);
288+
SingleExecutor executor(cppcheck, mFiles, settings, settings.nomsg, *this);
289289
returnValue = executor.check();
290290
} else {
291291
#if defined(THREADING_MODEL_THREAD)
292-
ThreadExecutor executor(mFiles, settings, *this);
292+
ThreadExecutor executor(mFiles, settings, settings.nomsg, *this);
293293
#elif defined(THREADING_MODEL_FORK)
294-
ProcessExecutor executor(mFiles, settings, *this);
294+
ProcessExecutor executor(mFiles, settings, settings.nomsg, *this);
295295
#endif
296296
returnValue = executor.check();
297297
}

cli/executor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
#include <sstream> // IWYU pragma: keep
2828
#include <utility>
2929

30-
Executor::Executor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
31-
: mFiles(files), mSettings(settings), mErrorLogger(errorLogger)
30+
Executor::Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
31+
: mFiles(files), mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger)
3232
{}
3333

3434
Executor::~Executor()
3535
{}
3636

3737
bool Executor::hasToLog(const ErrorMessage &msg)
3838
{
39-
if (!mSettings.nomsg.isSuppressed(msg))
39+
if (!mSuppressions.isSuppressed(msg))
4040
{
4141
std::string errmsg = msg.toString(mSettings.verbose);
4242

cli/executor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
class Settings;
2929
class ErrorLogger;
3030
class ErrorMessage;
31+
class Suppressions;
3132

3233
/// @addtogroup CLI
3334
/// @{
@@ -38,7 +39,7 @@ class ErrorMessage;
3839
*/
3940
class Executor {
4041
public:
41-
Executor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
42+
Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
4243
virtual ~Executor();
4344

4445
Executor(const Executor &) = delete;
@@ -65,7 +66,8 @@ class Executor {
6566
bool hasToLog(const ErrorMessage &msg);
6667

6768
const std::map<std::string, std::size_t> &mFiles;
68-
Settings &mSettings;
69+
const Settings &mSettings;
70+
Suppressions &mSuppressions;
6971
ErrorLogger &mErrorLogger;
7072

7173
private:

cli/processexecutor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ enum class Color;
6161
using std::memset;
6262

6363

64-
ProcessExecutor::ProcessExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
65-
: Executor(files, settings, errorLogger)
64+
ProcessExecutor::ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
65+
: Executor(files, settings, suppressions, errorLogger)
6666
{
6767
assert(mSettings.jobs > 1);
6868
}
@@ -391,7 +391,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
391391
"cppcheckError",
392392
Certainty::normal);
393393

394-
if (!mSettings.nomsg.isSuppressed(errmsg))
394+
if (!mSuppressions.isSuppressed(errmsg))
395395
mErrorLogger.reportErr(errmsg);
396396
}
397397

cli/processexecutor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
class Settings;
2929
class ErrorLogger;
30+
class Suppressions;
3031

3132
/// @addtogroup CLI
3233
/// @{
@@ -37,7 +38,7 @@ class ErrorLogger;
3738
*/
3839
class ProcessExecutor : public Executor {
3940
public:
40-
ProcessExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
41+
ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
4142
ProcessExecutor(const ProcessExecutor &) = delete;
4243
~ProcessExecutor() override;
4344
void operator=(const ProcessExecutor &) = delete;

cli/singleexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
class ErrorLogger;
3232

33-
SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
34-
: Executor(files, settings, errorLogger)
33+
SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
34+
: Executor(files, settings, suppressions, errorLogger)
3535
, mCppcheck(cppcheck)
3636
{
3737
assert(mSettings.jobs == 1);

cli/singleexecutor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
class ErrorLogger;
2929
class Settings;
3030
class CppCheck;
31+
class Suppressions;
3132

3233
class SingleExecutor : public Executor
3334
{
3435
public:
35-
SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
36+
SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
3637
SingleExecutor(const SingleExecutor &) = delete;
3738
~SingleExecutor() override;
3839
void operator=(const SingleExecutor &) = delete;

cli/threadexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
enum class Color;
4242

43-
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger)
44-
: Executor(files, settings, errorLogger)
43+
ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger)
44+
: Executor(files, settings, suppressions, errorLogger)
4545
{
4646
assert(mSettings.jobs > 1);
4747
}

cli/threadexecutor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
class Settings;
2929
class ErrorLogger;
30+
class Suppressions;
3031

3132
/// @addtogroup CLI
3233
/// @{
@@ -37,7 +38,7 @@ class ErrorLogger;
3738
*/
3839
class ThreadExecutor : public Executor {
3940
public:
40-
ThreadExecutor(const std::map<std::string, std::size_t> &files, Settings &settings, ErrorLogger &errorLogger);
41+
ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
4142
ThreadExecutor(const ThreadExecutor &) = delete;
4243
~ThreadExecutor() override;
4344
void operator=(const ThreadExecutor &) = delete;

test/testprocessexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TestProcessExecutor : public TestFixture {
8282
if (opt.plistOutput)
8383
settings.plistOutput = opt.plistOutput;
8484
// TODO: test with settings.project.fileSettings;
85-
ProcessExecutor executor(filemap, settings, *this);
85+
ProcessExecutor executor(filemap, settings, settings.nomsg, *this);
8686
std::vector<std::unique_ptr<ScopedFile>> scopedfiles;
8787
scopedfiles.reserve(filemap.size());
8888
for (std::map<std::string, std::size_t>::const_iterator i = filemap.cbegin(); i != filemap.cend(); ++i)

0 commit comments

Comments
 (0)