@@ -280,7 +280,7 @@ namespace {
280280 /* *
281281 * @brief Write the checkers report
282282 */
283- void writeCheckersReport ();
283+ void writeCheckersReport (const Suppressions& supprs );
284284
285285 bool hasCriticalErrors () const {
286286 return !mCriticalErrors .empty ();
@@ -305,7 +305,7 @@ namespace {
305305 void reportProgress (const std::string &filename, const char stage[], std::size_t value) override ;
306306
307307 /* *
308- * Pointer to current settings; set while check() is running for reportError().
308+ * Reference to current settings; set while check() is running for reportError().
309309 */
310310 const Settings& mSettings ;
311311
@@ -356,7 +356,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
356356{
357357 Settings settings;
358358 CmdLineLoggerStd logger;
359- CmdLineParser parser (logger, settings, settings.supprs );
359+ Suppressions supprs;
360+ CmdLineParser parser (logger, settings, supprs);
360361 if (!parser.fillSettingsFromArgs (argc, argv)) {
361362 return EXIT_FAILURE;
362363 }
@@ -371,22 +372,22 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
371372
372373 settings.setMisraRuleTexts (executeCommand);
373374
374- const int ret = check_wrapper (settings);
375+ const int ret = check_wrapper (settings, supprs );
375376
376377 return ret;
377378}
378379
379- int CppCheckExecutor::check_wrapper (const Settings& settings)
380+ int CppCheckExecutor::check_wrapper (const Settings& settings, Suppressions& supprs )
380381{
381382#ifdef USE_WINDOWS_SEH
382383 if (settings.exceptionHandling ) {
383- CALL_WITH_SEH_WRAPPER (check_internal (settings));
384+ CALL_WITH_SEH_WRAPPER (check_internal (settings, supprs ));
384385 }
385386#elif defined(USE_UNIX_SIGNAL_HANDLING)
386387 if (settings.exceptionHandling )
387388 register_signal_handler (settings.exceptionOutput );
388389#endif
389- return check_internal (settings);
390+ return check_internal (settings, supprs );
390391}
391392
392393bool CppCheckExecutor::reportSuppressions (const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
@@ -418,7 +419,7 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, const Suppre
418419/*
419420 * That is a method which gets called from check_wrapper
420421 * */
421- int CppCheckExecutor::check_internal (const Settings& settings) const
422+ int CppCheckExecutor::check_internal (const Settings& settings, Suppressions& supprs ) const
422423{
423424 StdLogger stdLogger (settings);
424425
@@ -439,25 +440,24 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
439440 if (!settings.checkersReportFilename .empty ())
440441 std::remove (settings.checkersReportFilename .c_str ());
441442
442- CppCheck cppcheck (stdLogger, true , executeCommand);
443+ CppCheck cppcheck (supprs, stdLogger, true , executeCommand);
443444 cppcheck.settings () = settings; // this is a copy
444- auto & suppressions = cppcheck.settings ().supprs .nomsg ;
445445
446446 unsigned int returnValue = 0 ;
447447 if (settings.useSingleJob ()) {
448448 // Single process
449- SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, suppressions , stdLogger);
449+ SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, supprs , stdLogger);
450450 returnValue = executor.check ();
451451 } else {
452452#if defined(HAS_THREADING_MODEL_THREAD)
453453 if (settings.executor == Settings::ExecutorType::Thread) {
454- ThreadExecutor executor (mFiles , mFileSettings , settings, suppressions , stdLogger, CppCheckExecutor::executeCommand);
454+ ThreadExecutor executor (mFiles , mFileSettings , settings, supprs , stdLogger, CppCheckExecutor::executeCommand);
455455 returnValue = executor.check ();
456456 }
457457#endif
458458#if defined(HAS_THREADING_MODEL_FORK)
459459 if (settings.executor == Settings::ExecutorType::Process) {
460- ProcessExecutor executor (mFiles , mFileSettings , settings, suppressions , stdLogger, CppCheckExecutor::executeCommand);
460+ ProcessExecutor executor (mFiles , mFileSettings , settings, supprs , stdLogger, CppCheckExecutor::executeCommand);
461461 returnValue = executor.check ();
462462 }
463463#endif
@@ -466,7 +466,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
466466 returnValue |= cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings , stdLogger.getCtuInfo ());
467467
468468 if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
469- const bool err = reportSuppressions (settings, suppressions , settings.checks .isEnabled (Checks::unusedFunction), mFiles , mFileSettings , stdLogger);
469+ const bool err = reportSuppressions (settings, supprs. nomsg , settings.checks .isEnabled (Checks::unusedFunction), mFiles , mFileSettings , stdLogger);
470470 if (err && returnValue == 0 )
471471 returnValue = settings.exitCode ;
472472 }
@@ -475,7 +475,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
475475 cppcheck.tooManyConfigsError (" " ,0U );
476476 }
477477
478- stdLogger.writeCheckersReport ();
478+ stdLogger.writeCheckersReport (supprs );
479479
480480 if (settings.outputFormat == Settings::OutputFormat::xml) {
481481 stdLogger.reportErr (ErrorMessage::getXMLFooter (settings.xml_version ));
@@ -489,7 +489,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
489489 return EXIT_SUCCESS;
490490}
491491
492- void StdLogger::writeCheckersReport ()
492+ void StdLogger::writeCheckersReport (const Suppressions& supprs )
493493{
494494 const bool summary = mSettings .safety || mSettings .severity .isEnabled (Severity::information);
495495 const bool xmlReport = mSettings .outputFormat == Settings::OutputFormat::xml && mSettings .xml_version == 3 ;
@@ -500,7 +500,7 @@ void StdLogger::writeCheckersReport()
500500
501501 CheckersReport checkersReport (mSettings , mActiveCheckers );
502502
503- const auto & suppressions = mSettings . supprs .nomsg .getSuppressions ();
503+ const auto & suppressions = supprs.nomsg .getSuppressions ();
504504 const bool summarySuppressed = std::any_of (suppressions.cbegin (), suppressions.cend (), [](const SuppressionList::Suppression& s) {
505505 return s.errorId == " checkersReport" ;
506506 });
0 commit comments