Disable all simplified checks

This commit is contained in:
Daniel Marjamäki 2019-03-16 09:17:50 +01:00
parent 0e88a17aca
commit 3dc34f1515
36 changed files with 19 additions and 213 deletions

View File

@ -68,11 +68,7 @@ public:
static std::list<Check *> &instances();
/** run checks, the token list is not simplified */
virtual void runChecks(const Tokenizer *, const Settings *, ErrorLogger *) {
}
/** run checks, the token list is simplified */
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) = 0;
virtual void runChecks(const Tokenizer *, const Settings *, ErrorLogger *) = 0;
/** get error messages */
virtual void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const = 0;

View File

@ -57,13 +57,6 @@ public:
check64BitPortability.pointerassignment();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** Check for pointer assignment */
void pointerassignment();

View File

@ -55,13 +55,6 @@ public:
checkAssert.assertWithSideEffects();
}
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
void assertWithSideEffects();
protected:

View File

@ -57,12 +57,6 @@ public:
checkAutoVariables.autoVariables();
}
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** assign function argument */
void assignFunctionArg();

View File

@ -66,13 +66,6 @@ public:
checkBool.checkBitwiseOnBoolean();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check for comparison of function returning bool*/
void checkComparisonOfFuncReturningBool();

View File

@ -57,13 +57,6 @@ public:
checkBoost.checkBoostForeachModification();
}
/** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check for container modification while using the BOOST_FOREACH macro */
void checkBoostForeachModification();

View File

@ -67,12 +67,6 @@ public:
checkBufferOverrun.stringNotZeroTerminated();
}
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
CheckBufferOverrun c(nullptr, settings, errorLogger);
c.arrayIndexError(nullptr, nullptr, nullptr);

View File

@ -81,14 +81,6 @@ public:
checkClass.checkOverride();
}
/** @brief Run checks on the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check that all class constructors are ok */
void constructors();

View File

@ -67,13 +67,6 @@ public:
checkCondition.checkModuloAlwaysTrueFalse();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** mismatching assignment / comparison */
void assignIf();

View File

@ -74,12 +74,6 @@ public:
checkExceptionSafety.unhandledExceptionSpecification();
}
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** Don't throw exceptions in destructors */
void destructors();

View File

@ -66,11 +66,6 @@ public:
// --check-library : functions with nonmatching configuration
checkFunctions.checkLibraryMatchFunctions();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckFunctions checkFunctions(tokenizer, settings, errorLogger);
checkFunctions.checkProhibitedFunctions();
checkFunctions.invalidFunctionUsage();

View File

@ -59,13 +59,6 @@ public:
checkInternal.checkStlUsage();
}
/** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check if a simple pattern is used inside Token::Match or Token::findmatch */
void checkTokenMatchPatterns();

View File

@ -54,12 +54,6 @@ public:
CheckIO checkIO(tokenizer, settings, errorLogger);
checkIO.checkWrongPrintfScanfArguments();
}
/** @brief Run checks on the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckIO checkIO(tokenizer, settings, errorLogger);
checkIO.checkCoutCerrMisusage();
checkIO.checkFileUsage();
checkIO.invalidScanf();

View File

@ -103,8 +103,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) {
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckLeakAutoVar checkLeakAutoVar(tokenizer, settings, errorLogger);
checkLeakAutoVar.check();
}

View File

@ -183,8 +183,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
}
/** @brief run all simplified checks */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakInFunction checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.checkReallocUsage();
}
@ -245,7 +244,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
}
void runSimplifiedChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) OVERRIDE {
void runChecks(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog) OVERRIDE {
if (!tokenizr->isCPP())
return;
@ -292,7 +291,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
}
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakStructMember checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.check();
}
@ -331,7 +330,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger), CheckMemoryLeak(tokenizer, errorLogger, settings) {
}
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckMemoryLeakNoVar checkMemoryLeak(tokenizer, settings, errorLogger);
checkMemoryLeak.check();
}

View File

@ -59,11 +59,6 @@ public:
CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger);
checkNullPointer.nullPointer();
checkNullPointer.arithmetic();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckNullPointer checkNullPointer(tokenizer, settings, errorLogger);
checkNullPointer.nullConstantDereference();
}

View File

@ -91,18 +91,9 @@ public:
checkOther.checkPassByReference();
checkOther.checkComparisonFunctionIsAlwaysTrueOrFalse();
checkOther.checkInvalidFree();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckOther checkOther(tokenizer, settings, errorLogger);
// Checks
checkOther.clarifyStatement();
checkOther.checkCastIntToCharAndBack();
checkOther.checkMisusedScopedObject();
checkOther.checkAccessOfMovedVariable();
}

View File

@ -57,8 +57,6 @@ public:
CheckPostfixOperator checkPostfixOperator(tokenizer, settings, errorLogger);
checkPostfixOperator.postfixOperator();
}
void runSimplifiedChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {
}
/** Check postfix operators */
void postfixOperator();

View File

@ -64,10 +64,6 @@ public:
checkSizeof.sizeofVoid();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) OVERRIDE {
}
/** @brief %Check for 'sizeof sizeof ..' */
void sizeofsizeof();

View File

@ -72,15 +72,6 @@ public:
checkStl.string_c_str();
checkStl.uselessCalls();
checkStl.useStlAlgorithm();
}
/** Simplified checks. The token list is simplified. */
void runSimplifiedChecks(const Tokenizer* tokenizer, const Settings* settings, ErrorLogger* errorLogger) OVERRIDE {
if (!tokenizer->isCPP()) {
return;
}
CheckStl checkStl(tokenizer, settings, errorLogger);
checkStl.stlOutOfBounds();
checkStl.negativeIndex();

View File

@ -63,13 +63,6 @@ public:
checkString.checkAlwaysTrueOrFalseStringCompare();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief undefined behaviour, writing string literal */
void stringLiteralWrite();

View File

@ -59,13 +59,6 @@ public:
checkType.checkFloatToIntegerOverflow();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check for bitwise shift with too big right operand */
void checkTooBigBitwiseShift();

View File

@ -68,13 +68,6 @@ public:
checkUninitVar.valueFlowUninit();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** Check for uninitialized variables */
void check();
void checkScope(const Scope* scope, const std::set<std::string> &arrayTypeDefs);

View File

@ -83,6 +83,8 @@ private:
c.unusedFunctionError(errorLogger, emptyString, 0, "funcName");
}
void runChecks(const Tokenizer * /*tokenizer*/, const Settings * /*settings*/, ErrorLogger * /*errorLogger*/) OVERRIDE {}
/**
* Dummy implementation, just to provide error for --errorlist
*/
@ -90,12 +92,6 @@ private:
const std::string &filename, unsigned int lineNumber,
const std::string &funcname);
/**
* Dummy implementation, just to provide error for --errorlist
*/
void runSimplifiedChecks(const Tokenizer* /*tokenizer*/, const Settings* /*settings*/, ErrorLogger* /*errorLogger*/) OVERRIDE {
}
static std::string myName() {
return "Unused functions";
}

View File

@ -61,13 +61,6 @@ public:
checkUnusedVar.checkFunctionVariableUsage();
}
/** @brief Run checks against the simplified token list */
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
(void)tokenizer;
(void)settings;
(void)errorLogger;
}
/** @brief %Check for unused function variables */
void checkFunctionVariableUsage_iterateScopes(const Scope* const scope, Variables& variables);
void checkFunctionVariableUsage();

View File

@ -48,7 +48,7 @@ public:
: Check(myName(), tokenizer, settings, errorLogger) {
}
virtual void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
virtual void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
CheckVaarg check(tokenizer, settings, errorLogger);
check.va_start_argument();
check.va_list_usage();

View File

@ -610,19 +610,6 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
void CppCheck::checkSimplifiedTokens(const Tokenizer &tokenizer)
{
// call all "runSimplifiedChecks" in all registered Check classes
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) {
if (mSettings.terminated())
return;
if (tokenizer.isMaxTime())
return;
Timer timerSimpleChecks((*it)->name() + "::runSimplifiedChecks", mSettings.showtime, &S_timerResults);
(*it)->runSimplifiedChecks(&tokenizer, &mSettings, this);
timerSimpleChecks.Stop();
}
if (!mSettings.terminated())
executeRules("simple", tokenizer);
}

View File

@ -515,8 +515,6 @@ private:
CheckCondition checkCondition;
checkCondition.runChecks(&tokenizer, &settings1, this);
tokenizer.simplifyTokenList2();
checkCondition.runSimplifiedChecks(&tokenizer, &settings1, this);
}
void duplicateIf() {

View File

@ -62,7 +62,7 @@ private:
// Invalid function usage
TEST_CASE(invalidFunctionUsage1);
TEST_CASE(invalidFunctionUsageStrings);
// TODO TEST_CASE(invalidFunctionUsageStrings);
// Math function usage
TEST_CASE(mathfunctionCall_fmod);
@ -96,12 +96,6 @@ private:
CheckFunctions checkFunctions(&tokenizer, settings_, this);
checkFunctions.runChecks(&tokenizer, settings_, this);
// Simplify...
tokenizer.simplifyTokenList2();
// Check...
checkFunctions.runSimplifiedChecks(&tokenizer, settings_, this);
}
void prohibitedFunctions_posix() {

View File

@ -277,10 +277,6 @@ private:
}
tokenizer.simplifyTokenList2();
// call all "runSimplifiedChecks" in all registered Check classes
for (std::list<Check *>::const_iterator it = Check::instances().begin(); it != Check::instances().end(); ++it) {
(*it)->runSimplifiedChecks(&tokenizer, &settings, this);
}
return tokenizer.tokens()->stringifyList(false, false, false, true, false, 0, 0);
}

View File

@ -54,14 +54,14 @@ private:
TEST_CASE(assign10);
TEST_CASE(assign11); // #3942: x = a(b(p));
TEST_CASE(assign12); // #4236: FP. bar(&x);
TEST_CASE(assign13); // #4237: FP. char*&ref=p; p=malloc(10); free(ref);
// TODO TEST_CASE(assign13); // #4237: FP. char*&ref=p; p=malloc(10); free(ref);
TEST_CASE(assign14);
TEST_CASE(deallocuse1);
TEST_CASE(deallocuse2);
TEST_CASE(deallocuse3);
TEST_CASE(deallocuse4);
TEST_CASE(deallocuse5); // #4018: FP. free(p), p = 0;
// TODO TEST_CASE(deallocuse5); // #4018: FP. free(p), p = 0;
TEST_CASE(deallocuse6); // #4034: FP. x = p = f();
TEST_CASE(deallocuse7); // #6467, #6469, #6473
@ -157,13 +157,12 @@ private:
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, cpp?"test.cpp":"test.c");
tokenizer.simplifyTokenList2();
// Check for leaks..
CheckLeakAutoVar c;
settings.checkLibrary = true;
settings.addEnabled("information");
c.runSimplifiedChecks(&tokenizer, &settings, this);
c.runChecks(&tokenizer, &settings, this);
}
void assign1() {
@ -1649,11 +1648,10 @@ private:
Tokenizer tokenizer(&settings, this);
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.c");
tokenizer.simplifyTokenList2();
// Check for leaks..
CheckLeakAutoVar checkLeak;
checkLeak.runSimplifiedChecks(&tokenizer, &settings, this);
checkLeak.runChecks(&tokenizer, &settings, this);
}
void run() OVERRIDE {

View File

@ -128,10 +128,6 @@ private:
// Check for null pointer dereferences..
CheckNullPointer checkNullPointer;
checkNullPointer.runChecks(&tokenizer, &settings, this);
tokenizer.simplifyTokenList2();
checkNullPointer.runSimplifiedChecks(&tokenizer, &settings, this);
}
void checkP(const char code[]) {
@ -158,10 +154,6 @@ private:
// Check for null pointer dereferences..
CheckNullPointer checkNullPointer;
checkNullPointer.runChecks(&tokenizer, &settings, this);
tokenizer.simplifyTokenList2();
checkNullPointer.runSimplifiedChecks(&tokenizer, &settings, this);
}
@ -1433,8 +1425,7 @@ private:
" }\n"
" return p;\n"
"}", true);
ASSERT_EQUALS("[test.cpp:7]: (warning) Possible null pointer dereference: p\n"
"[test.cpp:7]: (error) Null pointer dereference\n", errout.str());
ASSERT_EQUALS("[test.cpp:7]: (warning) Possible null pointer dereference: p\n", errout.str());
}
void nullpointer_cast() { // #4692

View File

@ -254,10 +254,7 @@ private:
CheckOther checkOther(&tokenizer, settings, this);
checkOther.runChecks(&tokenizer, settings, this);
if (runSimpleChecks) {
tokenizer.simplifyTokenList2();
checkOther.runSimplifiedChecks(&tokenizer, settings, this);
}
(void)runSimpleChecks; // TODO Remove this
}
void check(const char code[], Settings *s) {
@ -296,8 +293,6 @@ private:
// Check..
CheckOther checkOther(&tokenizer, settings, this);
checkOther.runChecks(&tokenizer, settings, this);
tokenizer.simplifyTokenList2();
checkOther.runSimplifiedChecks(&tokenizer, settings, this);
}
void checkposix(const char code[]) {

View File

@ -174,12 +174,8 @@ private:
tokenizer.tokenize(istr, "test.cpp");
checkStl.runChecks(&tokenizer, &settings, this);
tokenizer.simplifyTokenList2();
// Check..
checkStl.runSimplifiedChecks(&tokenizer, &settings, this);
}
void check(const std::string &code, const bool inconclusive=false) {
check(code.c_str(), inconclusive);
}

View File

@ -67,9 +67,6 @@ private:
// Check char variable usage..
CheckString checkString(&tokenizer, &settings, this);
checkString.runChecks(&tokenizer, &settings, this);
tokenizer.simplifyTokenList2();
checkString.runSimplifiedChecks(&tokenizer, &settings, this);
}
void stringLiteralWrite() {

View File

@ -40,8 +40,8 @@ private:
tokenizer.tokenize(istr, "test.cpp");
// Check..
CheckVaarg checkVaarg(&tokenizer, &settings, this);
checkVaarg.runSimplifiedChecks(&tokenizer, &settings, this);
CheckVaarg checkVaarg;
checkVaarg.runChecks(&tokenizer, &settings, this);
}
void run() OVERRIDE {