@@ -361,21 +361,11 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
361361 supprlist.addSuppression (std::move (s));
362362 }
363363
364- const auto reportErrorsFn = [&](const std::string& sourcefile, std:: size_t fsFileId, const std:: vector<ErrorMessage>& errors) -> bool {
364+ const auto reportErrorsFn = [&](const std::vector<ErrorMessage>& errors) -> bool {
365365 if (errors.empty ())
366366 return false ;
367367
368- // TODO: what if sourcefile is empty?
369-
370- AnalyzerInformation analyzerInfo;
371- // FIXME: this is a horrible hack
372- // we need to "re-open" the file so we can add the unmatchedSuppression findings.
373- // we cannot keep it open conditionally because the whole program analysis reads the XML.
374- // re-ordering the code is also not an option because the unmatched suppression reporting needs to be run after all other checks.
375- analyzerInfo.reopen (settings.buildDir , sourcefile, /* cfgname*/ " " , fsFileId);
376-
377368 for (const auto & errmsg : errors) {
378- analyzerInfo.reportErr (errmsg);
379369 errorLogger.reportErr (errmsg);
380370 }
381371 return true ;
@@ -385,30 +375,24 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
385375
386376 for (auto i = files.cbegin (); i != files.cend (); ++i) {
387377 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (*i), settings.unmatchedSuppressionFilters );
388- err |= reportErrorsFn (i-> spath (), i-> fsFileId (), errors);
378+ err |= reportErrorsFn (errors);
389379 }
390380
391381 for (auto i = fileSettings.cbegin (); i != fileSettings.cend (); ++i) {
392382 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (i->file ), settings.unmatchedSuppressionFilters );
393- err |= reportErrorsFn (i-> file . spath (), i-> file . fsFileId (), errors);
383+ err |= reportErrorsFn (errors);
394384 }
395385
396386 if (settings.inlineSuppressions ) {
397387 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedInlineSuppressions (), settings.unmatchedSuppressionFilters );
398388 for (const auto & errmsg : errors) {
399- std::string sourcefile;
400- if (!errmsg.callStack .empty ())
401- sourcefile = errmsg.callStack .cbegin ()->getfile (false ); // TODO: simplify path?
402- err |= reportErrorsFn (sourcefile, 0 , {errmsg});
389+ err |= reportErrorsFn ({errmsg});
403390 }
404391 }
405392
406393 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedGlobalSuppressions (), settings.unmatchedSuppressionFilters );
407394 for (const auto & errmsg : errors) {
408- std::string sourcefile;
409- if (!errmsg.callStack .empty ())
410- sourcefile = errmsg.callStack .cbegin ()->getfile (false ); // TODO: simplify path?
411- err |= reportErrorsFn (sourcefile, 0 , {errmsg});
395+ err |= reportErrorsFn ({errmsg});
412396 }
413397 return err;
414398}
0 commit comments