From 68d501db580565a07062d977516810d1286158f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 4 Jan 2009 18:28:05 +0000 Subject: [PATCH] variable usage: The check must be made before simplifyTokenList to avoid false positives --- cppcheck.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cppcheck.cpp b/cppcheck.cpp index 9468052aa..76f73e143 100644 --- a/cppcheck.cpp +++ b/cppcheck.cpp @@ -237,17 +237,19 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) checkClass.noMemset(); - // Check for unsigned divisions where one operand is signed - // Very important to run it before 'SimplifyTokenList' + // Coding style checks that must be run before the simplifyTokenList CheckOther checkOther( &_tokenizer, this ); if ( _settings._checkCodingStyle ) + { + // Check for unsigned divisions where one operand is signed checkOther.CheckUnsignedDivision(); - // Give warning when using char variable as array index - // Doesn't work on simplified token list ('unsigned') - if ( _settings._checkCodingStyle ) + // Give warning when using char variable as array index checkOther.CheckCharVariable(); + // Usage of local variables + checkOther.functionVariableUsage(); + } // Including header which is not needed (too many false positives) // if ( _settings._checkCodingStyle ) @@ -257,6 +259,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) // } + _tokenizer.simplifyTokenList(); @@ -336,9 +339,6 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) // Unreachable code below a 'return' statement checkOther.unreachableCode(); - - // Usage of local functions - checkOther.functionVariableUsage(); } } //---------------------------------------------------------------------------