@@ -305,7 +305,7 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
305305 return check_internal (cppcheck);
306306}
307307
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) {
309309 const auto & suppressions = settings.nomsg .getSuppressions ();
310310 if (std::any_of (suppressions.begin (), suppressions.end (), [](const Suppressions::Suppression& s) {
311311 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
314314
315315 bool err = false ;
316316 if (settings.useSingleJob ()) {
317+ // the two inputs may only be used exclusively
318+ assert (!(!files.empty () && !fileSettings.empty ()));
319+
317320 for (std::list<std::pair<std::string, std::size_t >>::const_iterator i = files.cbegin (); i != files.cend (); ++i) {
318321 err |= Suppressions::reportUnmatchedSuppressions (
319322 settings.nomsg .getUnmatchedLocalSuppressions (i->first , unusedFunctionCheckEnabled), errorLogger);
320323 }
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+ }
321329 }
322330 err |= Suppressions::reportUnmatchedSuppressions (settings.nomsg .getUnmatchedGlobalSuppressions (unusedFunctionCheckEnabled), errorLogger);
323331 return err;
@@ -370,7 +378,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
370378 cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings );
371379
372380 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 );
374382 if (err && returnValue == 0 )
375383 returnValue = settings.exitCode ;
376384 }
0 commit comments