increased constness of member variable _tokenizer in the Check* classes

This commit is contained in:
Daniel Marjamäki 2008-11-22 20:00:36 +00:00
parent a60dad3562
commit 0d3a99adb0
19 changed files with 358 additions and 359 deletions

View File

@ -33,7 +33,7 @@
#endif #endif
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckClass::CheckClass( Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger ) CheckClass::CheckClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger )
{ {
_tokenizer = tokenizer; _tokenizer = tokenizer;
_settings = settings; _settings = settings;

View File

@ -36,7 +36,7 @@ struct VAR
class CheckClass class CheckClass
{ {
public: public:
CheckClass( Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger ); CheckClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger );
~CheckClass(); ~CheckClass();
void CheckConstructors(); void CheckConstructors();
@ -53,7 +53,7 @@ private:
const TOKEN *FindClassFunction( const TOKEN *tok, const char classname[], const char funcname[], int &indentlevel ); const TOKEN *FindClassFunction( const TOKEN *tok, const char classname[], const char funcname[], int &indentlevel );
struct VAR *ClassChecking_GetVarList(const TOKEN *tok1); struct VAR *ClassChecking_GetVarList(const TOKEN *tok1);
Tokenizer *_tokenizer; const Tokenizer *_tokenizer;
Settings _settings; Settings _settings;
ErrorLogger *_errorLogger; ErrorLogger *_errorLogger;
}; };

View File

@ -35,7 +35,7 @@
// HEADERS - No implementation in a header // HEADERS - No implementation in a header
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckHeaders::CheckHeaders( Tokenizer *tokenizer, ErrorLogger *errorLogger ) CheckHeaders::CheckHeaders( const Tokenizer *tokenizer, ErrorLogger *errorLogger )
{ {
_tokenizer = tokenizer; _tokenizer = tokenizer;
_errorLogger = errorLogger; _errorLogger = errorLogger;

View File

@ -28,13 +28,13 @@
class CheckHeaders class CheckHeaders
{ {
public: public:
CheckHeaders( Tokenizer *tokenizer, ErrorLogger *errorLogger ); CheckHeaders( const Tokenizer *tokenizer, ErrorLogger *errorLogger );
~CheckHeaders(); ~CheckHeaders();
void WarningHeaderWithImplementation(); void WarningHeaderWithImplementation();
void WarningIncludeHeader(); void WarningIncludeHeader();
private: private:
Tokenizer *_tokenizer; const Tokenizer *_tokenizer;
ErrorLogger *_errorLogger; ErrorLogger *_errorLogger;
}; };

View File

@ -37,7 +37,7 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckMemoryLeakClass::CheckMemoryLeakClass( Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger ) CheckMemoryLeakClass::CheckMemoryLeakClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger )
{ {
_tokenizer = tokenizer; _tokenizer = tokenizer;
_settings = settings; _settings = settings;

View File

@ -34,7 +34,7 @@
class CheckMemoryLeakClass class CheckMemoryLeakClass
{ {
public: public:
CheckMemoryLeakClass( Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger ); CheckMemoryLeakClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger );
~CheckMemoryLeakClass(); ~CheckMemoryLeakClass();
void CheckMemoryLeak(); void CheckMemoryLeak();
@ -74,7 +74,7 @@ private:
AllocType GetAllocationType( const TOKEN *tok2 ); AllocType GetAllocationType( const TOKEN *tok2 );
bool isclass( const std::string &typestr ); bool isclass( const std::string &typestr );
Tokenizer *_tokenizer; const Tokenizer *_tokenizer;
ErrorLogger *_errorLogger; ErrorLogger *_errorLogger;
Settings _settings; Settings _settings;
std::list<AllocFunc> listallocfunc; std::list<AllocFunc> listallocfunc;

View File

@ -34,7 +34,7 @@
// Warning on C-Style casts.. p = (kalle *)foo; // Warning on C-Style casts.. p = (kalle *)foo;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
CheckOther::CheckOther( Tokenizer *tokenizer, ErrorLogger *errorLogger ) CheckOther::CheckOther( const Tokenizer *tokenizer, ErrorLogger *errorLogger )
{ {
_tokenizer = tokenizer; _tokenizer = tokenizer;
_errorLogger = errorLogger; _errorLogger = errorLogger;

View File

@ -29,7 +29,7 @@
class CheckOther class CheckOther
{ {
public: public:
CheckOther( Tokenizer *tokenizer, ErrorLogger *errorLogger ); CheckOther( const Tokenizer *tokenizer, ErrorLogger *errorLogger );
~CheckOther(); ~CheckOther();
// Casting // Casting
@ -76,7 +76,7 @@ public:
private: private:
void CheckVariableScope_LookupVar( const TOKEN *tok1, const char varname[] ); void CheckVariableScope_LookupVar( const TOKEN *tok1, const char varname[] );
Tokenizer *_tokenizer; const Tokenizer *_tokenizer;
ErrorLogger *_errorLogger; ErrorLogger *_errorLogger;
}; };

View File

@ -17,7 +17,7 @@
*/ */
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckBufferOverrun.h" #include "CheckBufferOverrun.h"
#include "testsuite.h" #include "testsuite.h"
@ -40,7 +40,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
tokenizer.SimplifyTokenList(); tokenizer.SimplifyTokenList();

View File

@ -17,6 +17,7 @@
*/ */
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckOther.h" #include "CheckOther.h"
#include "testsuite.h" #include "testsuite.h"
@ -44,7 +45,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );

View File

@ -18,6 +18,7 @@
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckClass.h" #include "CheckClass.h"
#include "testsuite.h" #include "testsuite.h"
@ -38,7 +39,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
tokenizer.SimplifyTokenList(); tokenizer.SimplifyTokenList();

View File

@ -21,6 +21,7 @@
// such as "svar / uvar". Treating "svar" as unsigned data is not good // such as "svar / uvar". Treating "svar" as unsigned data is not good
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckOther.h" #include "CheckOther.h"
#include "testsuite.h" #include "testsuite.h"
@ -40,7 +41,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
//SimplifyTokenList(); <- this can't be used as it removes 'unsigned' //SimplifyTokenList(); <- this can't be used as it removes 'unsigned'

View File

@ -20,6 +20,7 @@
// Check for unused variables.. // Check for unused variables..
#define UNIT_TESTING
#include "testsuite.h" #include "testsuite.h"
#include "tokenize.h" #include "tokenize.h"
#include "CheckOther.h" #include "CheckOther.h"
@ -39,7 +40,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
tokenizer.SimplifyTokenList(); tokenizer.SimplifyTokenList();

View File

@ -19,6 +19,7 @@
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckMemoryLeak.h" #include "CheckMemoryLeak.h"
#include "testsuite.h" #include "testsuite.h"
@ -38,7 +39,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
tokenizer.SimplifyTokenList(); tokenizer.SimplifyTokenList();

View File

@ -42,8 +42,6 @@ private:
TEST_CASE( inlineasm ); TEST_CASE( inlineasm );
TEST_CASE( dupfuncname ); TEST_CASE( dupfuncname );
TEST_CASE( simplifyConditions );
} }
@ -66,7 +64,7 @@ private:
// tokenize.. // tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(filedata); std::istringstream istr(filedata);
tokenizer.TokenizeCode(istr, 0); tokenizer.TokenizeCode(istr, 0);
@ -90,7 +88,7 @@ private:
// tokenize.. // tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(filedata); std::istringstream istr(filedata);
tokenizer.TokenizeCode(istr, 0); tokenizer.TokenizeCode(istr, 0);
@ -112,7 +110,7 @@ private:
// tokenize.. // tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(filedata); std::istringstream istr(filedata);
tokenizer.TokenizeCode(istr, 0); tokenizer.TokenizeCode(istr, 0);
@ -143,7 +141,7 @@ private:
"{ }\n"; "{ }\n";
// tokenize.. // tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode(istr, 0); tokenizer.TokenizeCode(istr, 0);
@ -152,12 +150,6 @@ private:
ASSERT_EQUALS( 1, tokenizer.FunctionList.size() ); ASSERT_EQUALS( 1, tokenizer.FunctionList.size() );
ASSERT_EQUALS( std::string("b"), tokenizer.FunctionList[0]->str ); ASSERT_EQUALS( std::string("b"), tokenizer.FunctionList[0]->str );
} }
void simplifyConditions()
{
// TODO Simplify various conditions..
}
}; };
REGISTER_TEST( TestTokenizer ) REGISTER_TEST( TestTokenizer )

View File

@ -17,6 +17,7 @@
*/ */
#define UNIT_TESTING
#include "tokenize.h" #include "tokenize.h"
#include "CheckClass.h" #include "CheckClass.h"
#include "testsuite.h" #include "testsuite.h"
@ -45,7 +46,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );

View File

@ -20,6 +20,7 @@
// Check for unused variables.. // Check for unused variables..
#define UNIT_TESTING
#include "testsuite.h" #include "testsuite.h"
#include "tokenize.h" #include "tokenize.h"
#include "CheckOther.h" #include "CheckOther.h"
@ -38,7 +39,7 @@ private:
{ {
// Tokenize.. // Tokenize..
Tokenizer tokenizer; Tokenizer tokenizer;
tokenizer.getFiles()->push_back( "test.cpp" ); tokenizer.Files.push_back( "test.cpp" );
std::istringstream istr(code); std::istringstream istr(code);
tokenizer.TokenizeCode( istr ); tokenizer.TokenizeCode( istr );
tokenizer.SimplifyTokenList(); tokenizer.SimplifyTokenList();

View File

@ -87,7 +87,7 @@ const TOKEN *Tokenizer::tokens() const
std::vector<std::string> *Tokenizer::getFiles() const std::vector<std::string> *Tokenizer::getFiles() const
{ {
return &Files; return &Files;
} }

View File

@ -98,7 +98,7 @@ public:
void initTokens(); void initTokens();
std::vector<std::string> *getFiles(); const std::vector<std::string> *getFiles() const;
void FillFunctionList(const unsigned int file_id); void FillFunctionList(const unsigned int file_id);
const TOKEN *GetFunctionTokenByName( const char funcname[] ) const; const TOKEN *GetFunctionTokenByName( const char funcname[] ) const;