@@ -305,7 +305,7 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
305
305
return check_internal (cppcheck);
306
306
}
307
307
308
- bool CppCheckExecutor::reportSuppressions (const Settings &settings, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t >> &files, ErrorLogger& errorLogger) {
308
+ bool CppCheckExecutor::reportSuppressions (const Settings &settings, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t >> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
309
309
const auto & suppressions = settings.nomsg .getSuppressions ();
310
310
if (std::any_of (suppressions.begin (), suppressions.end (), [](const Suppressions::Suppression& s) {
311
311
return s.errorId == " unmatchedSuppression" && s.fileName .empty () && s.lineNumber == Suppressions::Suppression::NO_LINE;
@@ -314,10 +314,18 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedF
314
314
315
315
bool err = false ;
316
316
if (settings.useSingleJob ()) {
317
+ // the two inputs may only be used exclusively
318
+ assert (!(!files.empty () && !fileSettings.empty ()));
319
+
317
320
for (std::list<std::pair<std::string, std::size_t >>::const_iterator i = files.cbegin (); i != files.cend (); ++i) {
318
321
err |= Suppressions::reportUnmatchedSuppressions (
319
322
settings.nomsg .getUnmatchedLocalSuppressions (i->first , unusedFunctionCheckEnabled), errorLogger);
320
323
}
324
+
325
+ for (std::list<FileSettings>::const_iterator i = fileSettings.cbegin (); i != fileSettings.cend (); ++i) {
326
+ err |= Suppressions::reportUnmatchedSuppressions (
327
+ settings.nomsg .getUnmatchedLocalSuppressions (i->filename , unusedFunctionCheckEnabled), errorLogger);
328
+ }
321
329
}
322
330
err |= Suppressions::reportUnmatchedSuppressions (settings.nomsg .getUnmatchedGlobalSuppressions (unusedFunctionCheckEnabled), errorLogger);
323
331
return err;
@@ -370,7 +378,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
370
378
cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings );
371
379
372
380
if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
373
- const bool err = reportSuppressions (settings, cppcheck.isUnusedFunctionCheckEnabled (), mFiles , *this );
381
+ const bool err = reportSuppressions (settings, cppcheck.isUnusedFunctionCheckEnabled (), mFiles , mFileSettings , *this );
374
382
if (err && returnValue == 0 )
375
383
returnValue = settings.exitCode ;
376
384
}
0 commit comments