@@ -280,7 +280,7 @@ namespace {
280
280
/* *
281
281
* @brief Write the checkers report
282
282
*/
283
- void writeCheckersReport ();
283
+ void writeCheckersReport (const Suppressions& supprs );
284
284
285
285
bool hasCriticalErrors () const {
286
286
return !mCriticalErrors .empty ();
@@ -305,7 +305,7 @@ namespace {
305
305
void reportProgress (const std::string &filename, const char stage[], std::size_t value) override ;
306
306
307
307
/* *
308
- * Pointer to current settings; set while check() is running for reportError().
308
+ * Reference to current settings; set while check() is running for reportError().
309
309
*/
310
310
const Settings& mSettings ;
311
311
@@ -356,7 +356,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
356
356
{
357
357
Settings settings;
358
358
CmdLineLoggerStd logger;
359
- CmdLineParser parser (logger, settings, settings.supprs );
359
+ Suppressions supprs;
360
+ CmdLineParser parser (logger, settings, supprs);
360
361
if (!parser.fillSettingsFromArgs (argc, argv)) {
361
362
return EXIT_FAILURE;
362
363
}
@@ -371,22 +372,22 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
371
372
372
373
settings.setMisraRuleTexts (executeCommand);
373
374
374
- const int ret = check_wrapper (settings);
375
+ const int ret = check_wrapper (settings, supprs );
375
376
376
377
return ret;
377
378
}
378
379
379
- int CppCheckExecutor::check_wrapper (const Settings& settings)
380
+ int CppCheckExecutor::check_wrapper (const Settings& settings, Suppressions& supprs )
380
381
{
381
382
#ifdef USE_WINDOWS_SEH
382
383
if (settings.exceptionHandling ) {
383
- CALL_WITH_SEH_WRAPPER (check_internal (settings));
384
+ CALL_WITH_SEH_WRAPPER (check_internal (settings, supprs ));
384
385
}
385
386
#elif defined(USE_UNIX_SIGNAL_HANDLING)
386
387
if (settings.exceptionHandling )
387
388
register_signal_handler (settings.exceptionOutput );
388
389
#endif
389
- return check_internal (settings);
390
+ return check_internal (settings, supprs );
390
391
}
391
392
392
393
bool 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
418
419
/*
419
420
* That is a method which gets called from check_wrapper
420
421
* */
421
- int CppCheckExecutor::check_internal (const Settings& settings) const
422
+ int CppCheckExecutor::check_internal (const Settings& settings, Suppressions& supprs ) const
422
423
{
423
424
StdLogger stdLogger (settings);
424
425
@@ -439,25 +440,24 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
439
440
if (!settings.checkersReportFilename .empty ())
440
441
std::remove (settings.checkersReportFilename .c_str ());
441
442
442
- CppCheck cppcheck (stdLogger, true , executeCommand);
443
+ CppCheck cppcheck (supprs, stdLogger, true , executeCommand);
443
444
cppcheck.settings () = settings; // this is a copy
444
- auto & suppressions = cppcheck.settings ().supprs .nomsg ;
445
445
446
446
unsigned int returnValue = 0 ;
447
447
if (settings.useSingleJob ()) {
448
448
// Single process
449
- SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, suppressions , stdLogger);
449
+ SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, supprs , stdLogger);
450
450
returnValue = executor.check ();
451
451
} else {
452
452
#if defined(HAS_THREADING_MODEL_THREAD)
453
453
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);
455
455
returnValue = executor.check ();
456
456
}
457
457
#endif
458
458
#if defined(HAS_THREADING_MODEL_FORK)
459
459
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);
461
461
returnValue = executor.check ();
462
462
}
463
463
#endif
@@ -466,7 +466,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
466
466
returnValue |= cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings , stdLogger.getCtuInfo ());
467
467
468
468
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);
470
470
if (err && returnValue == 0 )
471
471
returnValue = settings.exitCode ;
472
472
}
@@ -475,7 +475,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
475
475
cppcheck.tooManyConfigsError (" " ,0U );
476
476
}
477
477
478
- stdLogger.writeCheckersReport ();
478
+ stdLogger.writeCheckersReport (supprs );
479
479
480
480
if (settings.outputFormat == Settings::OutputFormat::xml) {
481
481
stdLogger.reportErr (ErrorMessage::getXMLFooter (settings.xml_version ));
@@ -489,7 +489,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
489
489
return EXIT_SUCCESS;
490
490
}
491
491
492
- void StdLogger::writeCheckersReport ()
492
+ void StdLogger::writeCheckersReport (const Suppressions& supprs )
493
493
{
494
494
const bool summary = mSettings .safety || mSettings .severity .isEnabled (Severity::information);
495
495
const bool xmlReport = mSettings .outputFormat == Settings::OutputFormat::xml && mSettings .xml_version == 3 ;
@@ -500,7 +500,7 @@ void StdLogger::writeCheckersReport()
500
500
501
501
CheckersReport checkersReport (mSettings , mActiveCheckers );
502
502
503
- const auto & suppressions = mSettings . supprs .nomsg .getSuppressions ();
503
+ const auto & suppressions = supprs.nomsg .getSuppressions ();
504
504
const bool summarySuppressed = std::any_of (suppressions.cbegin (), suppressions.cend (), [](const SuppressionList::Suppression& s) {
505
505
return s.errorId == " checkersReport" ;
506
506
});
0 commit comments