@@ -248,8 +248,9 @@ namespace {
248248 class StdLogger : public ErrorLogger
249249 {
250250 public:
251- explicit StdLogger (const Settings& settings)
251+ explicit StdLogger (const Settings& settings, const Suppressions& supprs )
252252 : mSettings(settings)
253+ , mSuppressions(supprs)
253254 , mGuidelineMapping(createGuidelineMapping(settings.reportType))
254255 {
255256 if (!mSettings .outputFile .empty ()) {
@@ -305,9 +306,10 @@ namespace {
305306 void reportProgress (const std::string &filename, const char stage[], std::size_t value) override ;
306307
307308 /* *
308- * Pointer to current settings; set while check() is running for reportError().
309+ * Reference to current settings; set while check() is running for reportError().
309310 */
310311 const Settings& mSettings ;
312+ const Suppressions& mSuppressions ;
311313
312314 /* *
313315 * Used to filter out duplicate error messages.
@@ -356,7 +358,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
356358{
357359 Settings settings;
358360 CmdLineLoggerStd logger;
359- CmdLineParser parser (logger, settings, settings.supprs );
361+ Suppressions supprs;
362+ CmdLineParser parser (logger, settings, supprs);
360363 if (!parser.fillSettingsFromArgs (argc, argv)) {
361364 return EXIT_FAILURE ;
362365 }
@@ -371,22 +374,22 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
371374
372375 settings.setMisraRuleTexts (executeCommand);
373376
374- const int ret = check_wrapper (settings);
377+ const int ret = check_wrapper (settings, supprs );
375378
376379 return ret;
377380}
378381
379- int CppCheckExecutor::check_wrapper (const Settings& settings)
382+ int CppCheckExecutor::check_wrapper (const Settings& settings, Suppressions& supprs )
380383{
381384#ifdef USE_WINDOWS_SEH
382385 if (settings.exceptionHandling ) {
383- CALL_WITH_SEH_WRAPPER (check_internal (settings));
386+ CALL_WITH_SEH_WRAPPER (check_internal (settings, supprs ));
384387 }
385388#elif defined(USE_UNIX_SIGNAL_HANDLING)
386389 if (settings.exceptionHandling )
387390 register_signal_handler (settings.exceptionOutput );
388391#endif
389- return check_internal (settings);
392+ return check_internal (settings, supprs );
390393}
391394
392395bool CppCheckExecutor::reportSuppressions (const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
@@ -418,9 +421,9 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, const Suppre
418421/*
419422 * That is a method which gets called from check_wrapper
420423 * */
421- int CppCheckExecutor::check_internal (const Settings& settings) const
424+ int CppCheckExecutor::check_internal (const Settings& settings, Suppressions& supprs ) const
422425{
423- StdLogger stdLogger (settings);
426+ StdLogger stdLogger (settings, supprs );
424427
425428 if (settings.reportProgress >= 0 )
426429 stdLogger.resetLatestProgressOutputTime ();
@@ -439,25 +442,24 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
439442 if (!settings.checkersReportFilename .empty ())
440443 std::remove (settings.checkersReportFilename .c_str ());
441444
442- CppCheck cppcheck (stdLogger, true , executeCommand);
445+ CppCheck cppcheck (supprs, stdLogger, true , executeCommand);
443446 cppcheck.settings () = settings; // this is a copy
444- auto & suppressions = cppcheck.settings ().supprs .nomsg ;
445447
446448 unsigned int returnValue = 0 ;
447449 if (settings.useSingleJob ()) {
448450 // Single process
449- SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, suppressions , stdLogger);
451+ SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, supprs , stdLogger);
450452 returnValue = executor.check ();
451453 } else {
452454#if defined(HAS_THREADING_MODEL_THREAD)
453455 if (settings.executor == Settings::ExecutorType::Thread) {
454- ThreadExecutor executor (mFiles , mFileSettings , settings, suppressions , stdLogger, CppCheckExecutor::executeCommand);
456+ ThreadExecutor executor (mFiles , mFileSettings , settings, supprs , stdLogger, CppCheckExecutor::executeCommand);
455457 returnValue = executor.check ();
456458 }
457459#endif
458460#if defined(HAS_THREADING_MODEL_FORK)
459461 if (settings.executor == Settings::ExecutorType::Process) {
460- ProcessExecutor executor (mFiles , mFileSettings , settings, suppressions , stdLogger, CppCheckExecutor::executeCommand);
462+ ProcessExecutor executor (mFiles , mFileSettings , settings, supprs , stdLogger, CppCheckExecutor::executeCommand);
461463 returnValue = executor.check ();
462464 }
463465#endif
@@ -466,7 +468,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
466468 returnValue |= cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings , stdLogger.getCtuInfo ());
467469
468470 if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
469- const bool err = reportSuppressions (settings, suppressions , settings.checks .isEnabled (Checks::unusedFunction), mFiles , mFileSettings , stdLogger);
471+ const bool err = reportSuppressions (settings, supprs. nomsg , settings.checks .isEnabled (Checks::unusedFunction), mFiles , mFileSettings , stdLogger);
470472 if (err && returnValue == 0 )
471473 returnValue = settings.exitCode ;
472474 }
@@ -500,7 +502,7 @@ void StdLogger::writeCheckersReport()
500502
501503 CheckersReport checkersReport (mSettings , mActiveCheckers );
502504
503- const auto & suppressions = mSettings . supprs .nomsg .getSuppressions ();
505+ const auto & suppressions = mSuppressions .nomsg .getSuppressions ();
504506 const bool summarySuppressed = std::any_of (suppressions.cbegin (), suppressions.cend (), [](const SuppressionList::Suppression& s) {
505507 return s.errorId == " checkersReport" ;
506508 });
0 commit comments