Code cleanup
This commit is contained in:
parent
7d12951da0
commit
9b685ba3c3
|
@ -136,8 +136,11 @@ void CheckAssignIf::multiCondition()
|
||||||
if (!_settings->isEnabled("style"))
|
if (!_settings->isEnabled("style"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
if (Token::Match(tok, "if ( %var% & %num% ) {")) {
|
|
||||||
|
for (std::list<Scope>::const_iterator i = symbolDatabase->scopeList.begin(); i != symbolDatabase->scopeList.end(); ++i) {
|
||||||
|
if (i->type == Scope::eIf && Token::Match(i->classDef, "if ( %var% & %num% ) {")) {
|
||||||
|
const Token* const tok = i->classDef;
|
||||||
const unsigned int varid(tok->tokAt(2)->varId());
|
const unsigned int varid(tok->tokAt(2)->varId());
|
||||||
if (varid == 0)
|
if (varid == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -51,7 +51,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check char variable usage..
|
// Check char variable usage..
|
||||||
Check64BitPortability check64BitPortability(&tokenizer, &settings, this);
|
Check64BitPortability check64BitPortability(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -49,7 +49,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Check char variable usage..
|
// Check char variable usage..
|
||||||
|
|
|
@ -51,9 +51,6 @@ private:
|
||||||
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Assign variable ids
|
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check auto variables
|
// Check auto variables
|
||||||
checkAutoVariables.autoVariables();
|
checkAutoVariables.autoVariables();
|
||||||
checkAutoVariables.returnPointerToLocalArray();
|
checkAutoVariables.returnPointerToLocalArray();
|
||||||
|
|
|
@ -54,7 +54,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check char variable usage..
|
// Check char variable usage..
|
||||||
CheckOther checkOther(&tokenizer, &settings, this);
|
CheckOther checkOther(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -48,7 +48,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
return ((const CheckMemoryLeak *)0)->functionReturnType(tokenizer.tokens());
|
return ((const CheckMemoryLeak *)0)->functionReturnType(tokenizer.tokens());
|
||||||
}
|
}
|
||||||
|
@ -132,7 +131,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
|
@ -3077,7 +3075,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
|
@ -3784,7 +3781,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
|
|
|
@ -51,9 +51,6 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Assign variable ids
|
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check for non reentrant functions..
|
// Check for non reentrant functions..
|
||||||
CheckNonReentrantFunctions checkNonReentrantFunctions(&tokenizer, &settings, this);
|
CheckNonReentrantFunctions checkNonReentrantFunctions(&tokenizer, &settings, this);
|
||||||
checkNonReentrantFunctions.nonReentrantFunctions();
|
checkNonReentrantFunctions.nonReentrantFunctions();
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
TEST_CASE(testgethostbyaddr);
|
TEST_CASE(testgethostbyaddr);
|
||||||
TEST_CASE(testusleep);
|
TEST_CASE(testusleep);
|
||||||
TEST_CASE(testindex);
|
TEST_CASE(testindex);
|
||||||
TEST_CASE(test_qt_index); // FP when using the Qt function 'index'?
|
TEST_CASE(test_qt_index); // FP when using the Qt function 'index'?
|
||||||
TEST_CASE(testrindex);
|
TEST_CASE(testrindex);
|
||||||
|
|
||||||
// no false positives for variables
|
// no false positives for variables
|
||||||
|
@ -83,9 +83,6 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Assign variable ids
|
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check for obsolete functions..
|
// Check for obsolete functions..
|
||||||
CheckObsoleteFunctions checkObsoleteFunctions(&tokenizer, &settings, this);
|
CheckObsoleteFunctions checkObsoleteFunctions(&tokenizer, &settings, this);
|
||||||
checkObsoleteFunctions.obsoleteFunctions();
|
checkObsoleteFunctions.obsoleteFunctions();
|
||||||
|
|
|
@ -371,7 +371,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
//tokenizer.tokens()->printOut( "tokens" );
|
//tokenizer.tokens()->printOut( "tokens" );
|
||||||
|
|
||||||
|
@ -437,7 +436,6 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check for redundant code..
|
// Check for redundant code..
|
||||||
CheckOther checkOther(&tokenizer, &settings, this);
|
CheckOther checkOther(&tokenizer, &settings, this);
|
||||||
|
@ -718,12 +716,10 @@ private:
|
||||||
Tokenizer tokenizerCpp(&settings, this);
|
Tokenizer tokenizerCpp(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizerCpp.tokenize(istr, "test.cpp");
|
tokenizerCpp.tokenize(istr, "test.cpp");
|
||||||
tokenizerCpp.setVarId();
|
|
||||||
|
|
||||||
Tokenizer tokenizerC(&settings, this);
|
Tokenizer tokenizerC(&settings, this);
|
||||||
std::istringstream istr2(code);
|
std::istringstream istr2(code);
|
||||||
tokenizerC.tokenize(istr2, "test.c");
|
tokenizerC.tokenize(istr2, "test.c");
|
||||||
tokenizerC.setVarId();
|
|
||||||
|
|
||||||
CheckOther checkOtherCpp(&tokenizerCpp, &settings, this);
|
CheckOther checkOtherCpp(&tokenizerCpp, &settings, this);
|
||||||
checkOtherCpp.warningOldStylePointerCast();
|
checkOtherCpp.warningOldStylePointerCast();
|
||||||
|
|
|
@ -48,9 +48,6 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
// Assign variable ids
|
|
||||||
tokenizer.setVarId();
|
|
||||||
|
|
||||||
// Check for postfix operators..
|
// Check for postfix operators..
|
||||||
CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this);
|
CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this);
|
||||||
checkPostfixOperator.postfixOperator();
|
checkPostfixOperator.postfixOperator();
|
||||||
|
|
|
@ -873,7 +873,6 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.setVarId();
|
|
||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
|
|
|
@ -1048,7 +1048,6 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyKnownVariables();
|
tokenizer.simplifyKnownVariables();
|
||||||
|
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
|
@ -4151,7 +4150,6 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
|
@ -4178,7 +4176,6 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.setVarId();
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
|
|
Loading…
Reference in New Issue