Skip to content

Commit d0dffbe

Browse files
committed
ainfo
1 parent 9d48ba7 commit d0dffbe

3 files changed

Lines changed: 5 additions & 44 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

lib/analyzerinfo.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -293,24 +293,3 @@ std::string AnalyzerInformation::processFilesTxt(const std::string& buildDir, co
293293
// TODO: error on empty file?
294294
return "";
295295
}
296-
297-
void AnalyzerInformation::reopen(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId)
298-
{
299-
if (buildDir.empty() || sourcefile.empty())
300-
return;
301-
302-
const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir,sourcefile,cfg,fsFileId);
303-
std::ifstream ifs(analyzerInfoFile);
304-
if (!ifs.is_open())
305-
return;
306-
307-
std::ostringstream iss;
308-
iss << ifs.rdbuf();
309-
ifs.close();
310-
311-
std::string content = iss.str();
312-
content.resize(content.find("</analyzerinfo>"));
313-
314-
mOutputStream.open(analyzerInfoFile, std::ios::trunc);
315-
mOutputStream << content;
316-
}

lib/analyzerinfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class CPPCHECKLIB AnalyzerInformation {
6969
void setFileInfo(const std::string &check, const std::string &fileInfo);
7070
static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId);
7171

72-
void reopen(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t fsFileId);
73-
7472
static const char sep = ':';
7573

7674
class CPPCHECKLIB Info {

0 commit comments

Comments
 (0)