Skip to content

Commit ce5f234

Browse files
authored
fixed checks related to unusedFunction check enablement (#6207)
This caused the `unmatchedSuppression` for an inline `unusedFunction` suppression not to be reported with `-j2` when using `--executor=thread`.
1 parent c462ab7 commit ce5f234

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
295295
cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings);
296296

297297
if (settings.severity.isEnabled(Severity::information) || settings.checkConfiguration) {
298-
const bool err = reportSuppressions(settings, suppressions, settings.isUnusedFunctionCheckEnabled(), mFiles, mFileSettings, stdLogger);
298+
const bool err = reportSuppressions(settings, suppressions, settings.checks.isEnabled(Checks::unusedFunction), mFiles, mFileSettings, stdLogger);
299299
if (err && returnValue == 0)
300300
returnValue = settings.exitCode;
301301
}

lib/cppcheck.cpp

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

657657
try {
658658
if (mSettings.library.markupFile(filename)) {
659-
if (mUnusedFunctionsCheck && mSettings.isUnusedFunctionCheckEnabled() && mSettings.buildDir.empty()) {
659+
if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) {
660660
// this is not a real source file - we just want to tokenize it. treat it as C anyways as the language needs to be determined.
661661
Tokenizer tokenizer(mSettings, this);
662662
tokenizer.list.setLang(Standards::Language::C);
@@ -1036,7 +1036,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
10361036
// In jointSuppressionReport mode, unmatched suppressions are
10371037
// collected after all files are processed
10381038
if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
1039-
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(filename, mSettings.isUnusedFunctionCheckEnabled()), *this);
1039+
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(filename, (bool)mUnusedFunctionsCheck), *this);
10401040
}
10411041

10421042
mErrorList.clear();
@@ -1107,7 +1107,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
11071107
if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mSettings.buildDir.empty()) {
11081108
unusedFunctionsChecker.parseTokens(tokenizer, mSettings);
11091109
}
1110-
if (mUnusedFunctionsCheck && mSettings.isUnusedFunctionCheckEnabled() && mSettings.buildDir.empty()) {
1110+
if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) {
11111111
mUnusedFunctionsCheck->parseTokens(tokenizer, mSettings);
11121112
}
11131113

lib/settings.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,6 @@ class CPPCHECKLIB WARN_UNUSED Settings {
456456
return jobs == 1;
457457
}
458458

459-
/** Check if the user wants to check for unused functions
460-
* and if it's possible at all */
461-
bool isUnusedFunctionCheckEnabled() const
462-
{
463-
return useSingleJob() && checks.isEnabled(Checks::unusedFunction);
464-
}
465-
466459
void setCheckLevelExhaustive();
467460
void setCheckLevelNormal();
468461

0 commit comments

Comments
 (0)