@@ -299,7 +299,7 @@ int CppCheckExecutor::check_wrapper(const Settings& settings, Suppressions& supp
299299 * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)
300300 * @return true is returned if errors are reported
301301 */
302- static bool reportUnmatchedSuppressions (const std::list<SuppressionList::Suppression> &unmatched, ErrorLogger &errorLogger, const std::vector<std::string>& filters)
302+ static bool reportUnmatchedSuppressions (const std::list<SuppressionList::Suppression> &unmatched, ErrorLogger &errorLogger, AnalyzerInformation* analyzerInfo, const std::vector<std::string>& filters)
303303{
304304 bool err = false ;
305305 // Report unmatched suppressions
@@ -329,13 +329,16 @@ static bool reportUnmatchedSuppressions(const std::list<SuppressionList::Suppres
329329 if (!s.fileName .empty ()) {
330330 callStack.emplace_back (s.fileName , s.lineNumber , 0 );
331331 }
332- errorLogger.reportErr (::ErrorMessage (std::move (callStack), " " , Severity::information, " Unmatched suppression: " + s.errorId , " unmatchedSuppression" , Certainty::normal));
332+ const auto errmsg = ::ErrorMessage (std::move (callStack), " " , Severity::information, " Unmatched suppression: " + s.errorId , " unmatchedSuppression" , Certainty::normal);
333+ if (analyzerInfo)
334+ analyzerInfo->reportErr (errmsg);
335+ errorLogger.reportErr (errmsg);
333336 err = true ;
334337 }
335338 return err;
336339}
337340
338- bool CppCheckExecutor::reportUnmatchedSuppressions (const Settings &settings, const SuppressionList& suppressions, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
341+ bool CppCheckExecutor::reportUnmatchedSuppressions (const Settings &settings, const SuppressionList& suppressions, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger, AnalyzerInformation* analyzerInfo ) {
339342 // the two inputs may only be used exclusively
340343 assert (!(!files.empty () && !fileSettings.empty ()));
341344
@@ -361,18 +364,18 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
361364 bool err = false ;
362365
363366 for (auto i = files.cbegin (); i != files.cend (); ++i) {
364- err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (*i), errorLogger, settings.unmatchedSuppressionFilters );
367+ err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (*i), errorLogger, analyzerInfo, settings.unmatchedSuppressionFilters );
365368 }
366369
367370 for (auto i = fileSettings.cbegin (); i != fileSettings.cend (); ++i) {
368- err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (i->file ), errorLogger, settings.unmatchedSuppressionFilters );
371+ err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (i->file ), errorLogger, analyzerInfo, settings.unmatchedSuppressionFilters );
369372 }
370373
371374 if (settings.inlineSuppressions ) {
372- err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedInlineSuppressions (), errorLogger, settings.unmatchedSuppressionFilters );
375+ err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedInlineSuppressions (), errorLogger, analyzerInfo, settings.unmatchedSuppressionFilters );
373376 }
374377
375- err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedGlobalSuppressions (), errorLogger, settings.unmatchedSuppressionFilters );
378+ err |= ::reportUnmatchedSuppressions (supprlist.getUnmatchedGlobalSuppressions (), errorLogger, analyzerInfo, settings.unmatchedSuppressionFilters );
376379 return err;
377380}
378381
@@ -424,10 +427,13 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
424427#endif
425428 }
426429
430+ // TODO: is this run again instead of using previously cached results?
427431 returnValue |= cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings , stdLogger.getCtuInfo ());
428432
429433 if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
430- const bool err = reportUnmatchedSuppressions (settings, supprs.nomsg , mFiles , mFileSettings , stdLogger);
434+ AnalyzerInformation analyzerInfo (true );
435+ const bool err = reportUnmatchedSuppressions (settings, supprs.nomsg , mFiles , mFileSettings , stdLogger, &analyzerInfo);
436+ analyzerInfo.close ();
431437 if (err && returnValue == 0 )
432438 returnValue = settings.exitCode ;
433439 }
0 commit comments