Skip to content

Commit 18fd62b

Browse files
committed
added Settings::useSingleJob() and use it instead of checking jobs or jointSuppressionReport
1 parent 8148095 commit 18fd62b

6 files changed

Lines changed: 13 additions & 17 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedF
244244
return false;
245245

246246
bool err = false;
247-
if (settings.jointSuppressionReport) {
247+
if (settings.useSingleJob()) {
248248
for (std::map<std::string, std::size_t>::const_iterator i = files.cbegin(); i != files.cend(); ++i) {
249249
err |= errorLogger.reportUnmatchedSuppressions(
250250
settings.nomsg.getUnmatchedLocalSuppressions(i->first, unusedFunctionCheckEnabled));
@@ -311,10 +311,8 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
311311
}
312312

313313
unsigned int returnValue = 0;
314-
if (settings.jobs == 1) {
314+
if (settings.useSingleJob()) {
315315
// Single process
316-
settings.jointSuppressionReport = true;
317-
318316
const std::size_t totalfilesize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const std::pair<std::string, std::size_t>& f) {
319317
return v + f.second;
320318
});

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, c
361361
{
362362
if (!settings->checks.isEnabled(Checks::unusedFunction))
363363
return nullptr;
364-
if (settings->jobs == 1 && settings->buildDir.empty())
364+
if (settings->useSingleJob() && settings->buildDir.empty())
365365
instance.parseTokens(*tokenizer, tokenizer->list.getFiles().front().c_str(), settings);
366366
return nullptr;
367367
}

lib/cppcheck.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
10261026

10271027
// In jointSuppressionReport mode, unmatched suppressions are
10281028
// collected after all files are processed
1029-
if (!mSettings.jointSuppressionReport && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
1029+
if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
10301030
reportUnmatchedSuppressions(mSettings.nomsg.getUnmatchedLocalSuppressions(filename, isUnusedFunctionCheckEnabled()));
10311031
}
10321032

@@ -1111,12 +1111,12 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11111111
return;
11121112

11131113

1114-
if (mSettings.jobs == 1 || !mSettings.buildDir.empty()) {
1114+
if (mSettings.useSingleJob() || !mSettings.buildDir.empty()) {
11151115
// Analyse the tokens..
11161116

11171117
CTU::FileInfo *fi1 = CTU::getFileInfo(&tokenizer);
11181118
if (fi1) {
1119-
if (mSettings.jobs == 1)
1119+
if (mSettings.useSingleJob())
11201120
mFileInfo.push_back(fi1);
11211121
if (!mSettings.buildDir.empty())
11221122
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
@@ -1128,7 +1128,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11281128

11291129
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
11301130
if (fi != nullptr) {
1131-
if (mSettings.jobs == 1)
1131+
if (mSettings.useSingleJob())
11321132
mFileInfo.push_back(fi);
11331133
if (!mSettings.buildDir.empty())
11341134
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
@@ -1837,7 +1837,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
18371837

18381838
bool CppCheck::isUnusedFunctionCheckEnabled() const
18391839
{
1840-
return (mSettings.jobs == 1 && mSettings.checks.isEnabled(Checks::unusedFunction));
1840+
return (mSettings.useSingleJob() && mSettings.checks.isEnabled(Checks::unusedFunction));
18411841
}
18421842

18431843
void CppCheck::removeCtuInfoFiles(const std::map<std::string, std::size_t> &files)

lib/settings.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Settings::Settings()
5757
force(false),
5858
inlineSuppressions(false),
5959
jobs(1),
60-
jointSuppressionReport(false),
6160
loadAverage(0),
6261
maxConfigs(12),
6362
maxCtuDepth(2),

lib/settings.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,6 @@ class CPPCHECKLIB Settings {
216216
time. Default is 1. (-j N) */
217217
unsigned int jobs;
218218

219-
/** @brief Collect unmatched suppressions in one run.
220-
* This delays the reporting until all files are checked.
221-
* It is needed by checks that analyse the whole code base. */
222-
bool jointSuppressionReport;
223-
224219
/** @brief --library= */
225220
std::list<std::string> libraries;
226221

@@ -436,6 +431,10 @@ class CPPCHECKLIB Settings {
436431

437432
void loadSummaries();
438433

434+
bool useSingleJob() const {
435+
return jobs == 1;
436+
}
437+
439438
private:
440439
static std::string parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity::SeverityType>, SimpleEnableGroup<Checks>> &groups);
441440
std::string applyEnabled(const std::string &str, bool enable);

test/testsuppressions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class TestSuppressions : public TestFixture {
189189
if (suppression == "unusedFunction")
190190
settings.checks.setEnabled(Checks::unusedFunction, true);
191191
settings.severity.enable(Severity::information);
192-
settings.jointSuppressionReport = true;
192+
settings.jobs = 1;
193193
if (!suppression.empty()) {
194194
std::string r = settings.nomsg.addSuppressionLine(suppression);
195195
EXPECT_EQ("", r);

0 commit comments

Comments
 (0)