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
//---------------------------------------------------------------------------
CheckClass::CheckClass( Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger )
CheckClass::CheckClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger )
{
_tokenizer = tokenizer;
_settings = settings;

View File

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

View File

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

View File

@ -28,13 +28,13 @@
class CheckHeaders
{
public:
CheckHeaders( Tokenizer *tokenizer, ErrorLogger *errorLogger );
CheckHeaders( const Tokenizer *tokenizer, ErrorLogger *errorLogger );
~CheckHeaders();
void WarningHeaderWithImplementation();
void WarningIncludeHeader();
private:
Tokenizer *_tokenizer;
const Tokenizer *_tokenizer;
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;
_settings = settings;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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