variable usage: The check must be made before simplifyTokenList to avoid false positives
This commit is contained in:
parent
0c06d757cc
commit
68d501db58
14
cppcheck.cpp
14
cppcheck.cpp
|
@ -237,17 +237,19 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
checkClass.noMemset();
|
checkClass.noMemset();
|
||||||
|
|
||||||
|
|
||||||
// Check for unsigned divisions where one operand is signed
|
// Coding style checks that must be run before the simplifyTokenList
|
||||||
// Very important to run it before 'SimplifyTokenList'
|
|
||||||
CheckOther checkOther( &_tokenizer, this );
|
CheckOther checkOther( &_tokenizer, this );
|
||||||
if ( _settings._checkCodingStyle )
|
if ( _settings._checkCodingStyle )
|
||||||
|
{
|
||||||
|
// Check for unsigned divisions where one operand is signed
|
||||||
checkOther.CheckUnsignedDivision();
|
checkOther.CheckUnsignedDivision();
|
||||||
|
|
||||||
// Give warning when using char variable as array index
|
// Give warning when using char variable as array index
|
||||||
// Doesn't work on simplified token list ('unsigned')
|
|
||||||
if ( _settings._checkCodingStyle )
|
|
||||||
checkOther.CheckCharVariable();
|
checkOther.CheckCharVariable();
|
||||||
|
|
||||||
|
// Usage of local variables
|
||||||
|
checkOther.functionVariableUsage();
|
||||||
|
}
|
||||||
|
|
||||||
// Including header which is not needed (too many false positives)
|
// Including header which is not needed (too many false positives)
|
||||||
// if ( _settings._checkCodingStyle )
|
// if ( _settings._checkCodingStyle )
|
||||||
|
@ -257,6 +259,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_tokenizer.simplifyTokenList();
|
_tokenizer.simplifyTokenList();
|
||||||
|
|
||||||
|
|
||||||
|
@ -336,9 +339,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
|
|
||||||
// Unreachable code below a 'return' statement
|
// Unreachable code below a 'return' statement
|
||||||
checkOther.unreachableCode();
|
checkOther.unreachableCode();
|
||||||
|
|
||||||
// Usage of local functions
|
|
||||||
checkOther.functionVariableUsage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue