42
42
#endif
43
43
44
44
#include < algorithm>
45
+ #include < cassert>
45
46
#include < cstdio>
46
47
#include < cstdlib> // EXIT_SUCCESS and EXIT_FAILURE
47
48
#include < ctime>
@@ -217,7 +218,7 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
217
218
return check_internal (cppcheck);
218
219
}
219
220
220
- bool CppCheckExecutor::reportSuppressions (const Settings &settings, bool unusedFunctionCheckEnabled, const std::list<std::pair<std::string, std::size_t >> &files, ErrorLogger& errorLogger) {
221
+ 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) {
221
222
const auto & suppressions = settings.nomsg .getSuppressions ();
222
223
if (std::any_of (suppressions.begin (), suppressions.end (), [](const Suppressions::Suppression& s) {
223
224
return s.errorId == " unmatchedSuppression" && s.fileName .empty () && s.lineNumber == Suppressions::Suppression::NO_LINE;
@@ -226,10 +227,18 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedF
226
227
227
228
bool err = false ;
228
229
if (settings.useSingleJob ()) {
230
+ // the two inputs may only be used exclusively
231
+ assert (!(!files.empty () && !fileSettings.empty ()));
232
+
229
233
for (std::list<std::pair<std::string, std::size_t >>::const_iterator i = files.cbegin (); i != files.cend (); ++i) {
230
234
err |= Suppressions::reportUnmatchedSuppressions (
231
235
settings.nomsg .getUnmatchedLocalSuppressions (i->first , unusedFunctionCheckEnabled), errorLogger);
232
236
}
237
+
238
+ for (std::list<FileSettings>::const_iterator i = fileSettings.cbegin (); i != fileSettings.cend (); ++i) {
239
+ err |= Suppressions::reportUnmatchedSuppressions (
240
+ settings.nomsg .getUnmatchedLocalSuppressions (i->filename , unusedFunctionCheckEnabled), errorLogger);
241
+ }
233
242
}
234
243
err |= Suppressions::reportUnmatchedSuppressions (settings.nomsg .getUnmatchedGlobalSuppressions (unusedFunctionCheckEnabled), errorLogger);
235
244
return err;
@@ -277,7 +286,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) const
277
286
cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings );
278
287
279
288
if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
280
- const bool err = reportSuppressions (settings, cppcheck.isUnusedFunctionCheckEnabled (), mFiles , *mStdLogger );
289
+ const bool err = reportSuppressions (settings, cppcheck.isUnusedFunctionCheckEnabled (), mFiles , mFileSettings , *mStdLogger );
281
290
if (err && returnValue == 0 )
282
291
returnValue = settings.exitCode ;
283
292
}
0 commit comments