@@ -363,30 +363,31 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
363363 supprlist.addSuppression (std::move (s));
364364 }
365365
366- const auto getCfgs = [&](const std::string &sourcefile) {
367- std::vector<std::string> cfgs;
366+ using AnalyzerInfoId = std::pair<std::string, std::size_t >;
367+ const auto getAnalyzerInfoIds = [&](const std::string &sourcefile) {
368+ std::vector<AnalyzerInfoId> ids;
368369 for (const FileSettings &fs : fileSettings) {
369370 if (fs.file .spath () == Path::simplifyPath (sourcefile))
370- cfgs. push_back (fs.cfg );
371+ ids. emplace_back (fs.cfg , fs. file . fsFileId () );
371372 }
372- if (cfgs .empty ())
373- cfgs .emplace_back ();
374- return cfgs ;
373+ if (ids .empty ())
374+ ids .emplace_back (" " , 0 );
375+ return ids ;
375376 };
376377
377- const auto reportErrorsFn = [&](const std::string &sourcefile, const std::vector<std::string > &cfgs, std:: size_t fsFileId , const std::vector<ErrorMessage> &errors) -> bool {
378+ const auto reportErrorsFn = [&](const std::string &sourcefile, const std::vector<AnalyzerInfoId > &ids , const std::vector<ErrorMessage> &errors) -> bool {
378379 if (errors.empty ())
379380 return false ;
380381
381382 // TODO: what if sourcefile is empty?
382383
383- for (const std::string &cfg : cfgs ) {
384+ for (const AnalyzerInfoId &id : ids ) {
384385 AnalyzerInformation analyzerInfo;
385386 // FIXME: this is a horrible hack
386387 // we need to "re-open" the file so we can add the unmatchedSuppression findings.
387388 // we cannot keep it open conditionally because the whole program analysis reads the XML.
388389 // re-ordering the code is also not an option because the unmatched suppression reporting needs to be run after all other checks.
389- analyzerInfo.reopen (settings.buildDir , sourcefile, cfg, fsFileId );
390+ analyzerInfo.reopen (settings.buildDir , sourcefile, id. first , id. second );
390391
391392 for (const auto &errmsg : errors)
392393 analyzerInfo.reportErr (errmsg);
@@ -401,12 +402,12 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
401402
402403 for (auto i = files.cbegin (); i != files.cend (); ++i) {
403404 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (*i), settings.unmatchedSuppressionFilters );
404- err |= reportErrorsFn (i->spath (), {" " } , i->fsFileId (), errors);
405+ err |= reportErrorsFn (i->spath (), {{ " " , i->fsFileId ()}} , errors);
405406 }
406407
407408 for (auto i = fileSettings.cbegin (); i != fileSettings.cend (); ++i) {
408409 const std::vector<ErrorMessage> errors = getUnmatchedSuppressions (supprlist.getUnmatchedLocalSuppressions (i->file ), settings.unmatchedSuppressionFilters );
409- err |= reportErrorsFn (i->file .spath (), {i->cfg } , i->file .fsFileId (), errors);
410+ err |= reportErrorsFn (i->file .spath (), {{ i->cfg , i->file .fsFileId ()}} , errors);
410411 }
411412
412413 if (settings.inlineSuppressions ) {
@@ -415,7 +416,7 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
415416 std::string sourcefile;
416417 if (!errmsg.callStack .empty ())
417418 sourcefile = errmsg.callStack .cbegin ()->getfile (false ); // TODO: simplify path?
418- err |= reportErrorsFn (sourcefile, getCfgs (sourcefile), 0 , {errmsg});
419+ err |= reportErrorsFn (sourcefile, getAnalyzerInfoIds (sourcefile), {errmsg});
419420 }
420421 }
421422
@@ -424,7 +425,7 @@ bool CppCheckExecutor::reportUnmatchedSuppressions(const Settings &settings, con
424425 std::string sourcefile;
425426 if (!errmsg.callStack .empty ())
426427 sourcefile = errmsg.callStack .cbegin ()->getfile (false ); // TODO: simplify path?
427- err |= reportErrorsFn (sourcefile, getCfgs (sourcefile), 0 , {errmsg});
428+ err |= reportErrorsFn (sourcefile, getAnalyzerInfoIds (sourcefile), {errmsg});
428429 }
429430 return err;
430431}
0 commit comments