Refactor f487182
This commit is contained in:
parent
80c2074ea7
commit
71511f3131
|
@ -2108,7 +2108,7 @@ bool CheckBufferOverrun::analyseWholeProgram(const std::list<Check::FileInfo*> &
|
|||
errors = true;
|
||||
}
|
||||
}
|
||||
return errors && errorLogger.hasErrors();
|
||||
return errors;
|
||||
}
|
||||
|
||||
unsigned int CheckBufferOverrun::sizeOfType(const Token *type) const
|
||||
|
|
|
@ -1606,5 +1606,5 @@ bool CheckUninitVar::analyseWholeProgram(const std::list<Check::FileInfo*> &file
|
|||
}
|
||||
}
|
||||
|
||||
return foundErrors && errorLogger.hasErrors();
|
||||
return foundErrors;
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ bool CheckUnusedFunctions::check(ErrorLogger * const errorLogger, const Settings
|
|||
*/
|
||||
}
|
||||
}
|
||||
return errors && errorLogger->hasErrors();
|
||||
return errors;
|
||||
}
|
||||
|
||||
void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,
|
||||
|
|
|
@ -815,7 +815,7 @@ bool CppCheck::analyseWholeProgram()
|
|||
// Analyse the tokens
|
||||
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it)
|
||||
errors |= (*it)->analyseWholeProgram(fileInfo, _settings, *this);
|
||||
return errors;
|
||||
return errors && (exitcode > 0);
|
||||
}
|
||||
|
||||
void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<std::string, std::size_t> &files)
|
||||
|
|
|
@ -191,8 +191,6 @@ private:
|
|||
*/
|
||||
virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
|
||||
|
||||
virtual bool hasErrors() const { return exitcode > 0; }
|
||||
|
||||
/**
|
||||
* @brief Information about progress is directed here.
|
||||
*
|
||||
|
|
|
@ -331,12 +331,6 @@ public:
|
|||
*/
|
||||
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;
|
||||
|
||||
/**
|
||||
* Returns true if an error has been reported which should
|
||||
* cause a non-zero cppcheck exit code.
|
||||
*/
|
||||
virtual bool hasErrors() const { return false; }
|
||||
|
||||
/**
|
||||
* Report progress to client
|
||||
* @param filename main file that is checked
|
||||
|
|
|
@ -52,6 +52,8 @@ private:
|
|||
TEST_CASE(suppressionWithRelativePaths); // #4733
|
||||
TEST_CASE(suppressingSyntaxErrors); // #7076
|
||||
TEST_CASE(suppressingSyntaxErrorsInline); // #5917
|
||||
|
||||
TEST_CASE(unusedFunction);
|
||||
}
|
||||
|
||||
void suppressionsBadId1() const {
|
||||
|
@ -149,7 +151,10 @@ private:
|
|||
|
||||
CppCheck cppCheck(*this, true);
|
||||
Settings& settings = cppCheck.settings();
|
||||
settings.exitCode = 1;
|
||||
settings.inlineSuppressions = true;
|
||||
if (suppression == "unusedFunction")
|
||||
settings.addEnabled("unusedFunction");
|
||||
settings.addEnabled("information");
|
||||
settings.jointSuppressionReport = true;
|
||||
if (!suppression.empty()) {
|
||||
|
@ -435,6 +440,10 @@ private:
|
|||
checkSuppression(files, "");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void unusedFunction() {
|
||||
ASSERT_EQUALS(0, checkSuppression("void f() {}", "unusedFunction"));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSuppressions)
|
||||
|
|
|
@ -77,7 +77,11 @@ private:
|
|||
// Check for unused functions..
|
||||
CheckUnusedFunctions checkUnusedFunctions(&tokenizer, &settings, this);
|
||||
checkUnusedFunctions.parseTokens(tokenizer, "someFile.c", &settings);
|
||||
ASSERT(!checkUnusedFunctions.check(this, settings));
|
||||
// check() returns error if and only if errout is not empty.
|
||||
if (checkUnusedFunctions.check(this, settings))
|
||||
ASSERT(errout.str() != "");
|
||||
else
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void incondition() {
|
||||
|
|
Loading…
Reference in New Issue