Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions cli/cppcheckexecutor.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -259,6 +259,9 @@ namespace {
if (!mSettings.outputFile.empty()) {
mErrorOutput = new std::ofstream(settings.outputFile);
}
if (!mSettings.buildDir.empty()) {
mCheckersFile = Path::join(settings.buildDir, "checkers.txt");
}
}

~StdLogger() override {
Expand DownExpand Up@@ -311,6 +314,25 @@ namespace {
return mCtuInfo;
}

void readActiveCheckers() {
if (mCheckersFile.empty())
return;

std::ifstream fin(mCheckersFile);
if (fin.is_open())
{
std::set<std::string> activeCheckers;
std::string line;
// cppcheck-suppress accessMoved - FP
while (std::getline(fin, line))
{
// cppcheck-suppress accessMoved - FP
activeCheckers.emplace(std::move(line));
Comment on lines +326 to +330

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was copied and the false positives are already being tracked in https://trac.cppcheck.net/ticket/11300.

}
mActiveCheckers = std::move(activeCheckers);
}
}

private:
/**
* Information about progress is directed here. This should be
Expand DownExpand Up@@ -375,6 +397,11 @@ namespace {
* File metrics
*/
std::vector<std::string> mFileMetrics;

/**
* The file the cached active checkers are stored in
*/
std::string mCheckersFile;
};
}

Expand DownExpand Up@@ -465,6 +492,8 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup
for (auto i = mFiles.cbegin(); i != mFiles.cend(); ++i)
fileNames.emplace_back(i->path());
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings);

stdLogger.readActiveCheckers();
}

if (!settings.checkersReportFilename.empty())
Expand DownExpand Up@@ -522,6 +551,15 @@ int CppCheckExecutor::check_internal(const Settings& settings, Suppressions& sup

void StdLogger::writeCheckersReport(const Suppressions& supprs)
{
if (!mCheckersFile.empty())
{
std::ofstream fout(mCheckersFile);
for (const auto& c : mActiveCheckers)
{
fout << c << std::endl;
}
}

const bool summary = mSettings.safety || mSettings.severity.isEnabled(Severity::information);
const bool xmlReport = mSettings.outputFormat == Settings::OutputFormat::xml && mSettings.xml_version == 3;
const bool textReport = !mSettings.checkersReportFilename.empty();
Expand Down
Loading