Skip to content

Commit

Permalink
fixed checks related to unused function check enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Mar 29, 2024
1 parent 80bff93 commit 6254379
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
cppcheck.analyseWholeProgram(settings.buildDir, mFiles, mFileSettings);

if (settings.severity.isEnabled(Severity::information) || settings.checkConfiguration) {
const bool err = reportSuppressions(settings, suppressions, settings.isUnusedFunctionCheckEnabled(), mFiles, mFileSettings, stdLogger);
const bool err = reportSuppressions(settings, suppressions, settings.checks.isEnabled(Checks::unusedFunction), mFiles, mFileSettings, stdLogger);
if (err && returnValue == 0)
returnValue = settings.exitCode;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string

try {
if (mSettings.library.markupFile(filename)) {
if (mUnusedFunctionsCheck && mSettings.isUnusedFunctionCheckEnabled() && mSettings.buildDir.empty()) {
if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) {
// 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.
Tokenizer tokenizer(mSettings, this);
tokenizer.list.setLang(Standards::Language::C);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string
// In jointSuppressionReport mode, unmatched suppressions are
// collected after all files are processed
if (!mSettings.useSingleJob() && (mSettings.severity.isEnabled(Severity::information) || mSettings.checkConfiguration)) {
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(filename, mSettings.isUnusedFunctionCheckEnabled()), *this);
SuppressionList::reportUnmatchedSuppressions(mSettings.supprs.nomsg.getUnmatchedLocalSuppressions(filename, (bool)mUnusedFunctionsCheck), *this);
}

mErrorList.clear();
Expand Down Expand Up @@ -1128,7 +1128,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mSettings.buildDir.empty()) {
unusedFunctionsChecker.parseTokens(tokenizer, mSettings);
}
if (mUnusedFunctionsCheck && mSettings.isUnusedFunctionCheckEnabled() && mSettings.buildDir.empty()) {
if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) {
mUnusedFunctionsCheck->parseTokens(tokenizer, mSettings);
}

Expand Down
7 changes: 0 additions & 7 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,6 @@ class CPPCHECKLIB WARN_UNUSED Settings {
return jobs == 1;
}

/** Check if the user wants to check for unused functions
* and if it's possible at all */
bool isUnusedFunctionCheckEnabled() const
{
return useSingleJob() && checks.isEnabled(Checks::unusedFunction);
}

void setCheckLevelExhaustive();
void setCheckLevelNormal();

Expand Down

0 comments on commit 6254379

Please sign in to comment.