CheckBufferOverrun: increased constness of _tokenizer member

This commit is contained in:
Daniel Marjamäki 2008-11-22 19:47:10 +00:00
parent 07b5ebe72b
commit a60dad3562
4 changed files with 127 additions and 123 deletions

View File

@ -35,7 +35,7 @@
// CallStack used when parsing into subfunctions.
CheckBufferOverrunClass::CheckBufferOverrunClass( Tokenizer *tokenizer, ErrorLogger *errorLogger )
CheckBufferOverrunClass::CheckBufferOverrunClass( const Tokenizer *tokenizer, ErrorLogger *errorLogger )
{
_tokenizer = tokenizer;
_errorLogger = errorLogger;

View File

@ -28,7 +28,7 @@
class CheckBufferOverrunClass
{
public:
CheckBufferOverrunClass( Tokenizer *tokenizer, ErrorLogger *errorLogger );
CheckBufferOverrunClass( const Tokenizer *tokenizer, ErrorLogger *errorLogger );
~CheckBufferOverrunClass();
// Buffer overrun..
@ -43,7 +43,7 @@ private:
void CheckBufferOverrun_CheckScope( const TOKEN *tok, const char *varname[], const int size, const int total_size );
void ReportError(const TOKEN *tok, const char errmsg[]);
Tokenizer *_tokenizer;
const Tokenizer *_tokenizer;
ErrorLogger *_errorLogger;
std::list<const TOKEN *> CallStack;
};

View File

@ -225,12 +225,16 @@ void Tokenizer::combine_2tokens(TOKEN *tok, const char str1[], const char str2[]
int Tokenizer::SizeOfType(const char type[])
int Tokenizer::SizeOfType(const char type[]) const
{
if (!type)
return 0;
return TypeSize[type];
std::map<std::string, unsigned int>::const_iterator it = TypeSize.find(type);
if ( it == TypeSize.end() )
return 0;
return it->second;
}
//---------------------------------------------------------------------------
@ -1310,7 +1314,7 @@ const TOKEN *Tokenizer::findmatch(const TOKEN *tok, const char pattern[], const
//---------------------------------------------------------------------------
std::string Tokenizer::fileLine( const TOKEN *tok )
std::string Tokenizer::fileLine( const TOKEN *tok ) const
{
std::ostringstream ostr;
ostr << "[" << Files.at(tok->FileIndex) << ":" << tok->linenr << "]";

View File

@ -91,10 +91,10 @@ public:
static bool IsNumber(const char str[]);
static bool IsStandardType(const char str[]);
std::string fileLine( const TOKEN *tok );
std::string fileLine( const TOKEN *tok ) const;
// Return size.
int SizeOfType(const char type[]);
int SizeOfType(const char type[]) const;
void initTokens();