expose number of variables found by Tokenizer

This commit is contained in:
Robert Reif 2011-02-26 08:42:19 -05:00
parent a80a38e25c
commit 3529014924
2 changed files with 19 additions and 1 deletions

View File

@ -58,6 +58,9 @@ Tokenizer::Tokenizer()
// symbol database // symbol database
_symbolDatabase = NULL; _symbolDatabase = NULL;
// variable count
_varId = 0;
} }
Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger)
@ -75,6 +78,9 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger)
// symbol database // symbol database
_symbolDatabase = NULL; _symbolDatabase = NULL;
// variable count
_varId = 0;
} }
Tokenizer::~Tokenizer() Tokenizer::~Tokenizer()
@ -3271,7 +3277,7 @@ void Tokenizer::setVarId()
tok->varId(0); tok->varId(0);
// Set variable ids.. // Set variable ids..
unsigned int _varId = 0; _varId = 0;
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())
{ {
if (tok != _tokens && !Token::Match(tok, "[;{}(,] %type%")) if (tok != _tokens && !Token::Match(tok, "[;{}(,] %type%"))

View File

@ -650,6 +650,15 @@ public:
Token *deleteInvalidTypedef(Token *typeDef); Token *deleteInvalidTypedef(Token *typeDef);
/**
* Get variable count.
* @return number of variables
*/
unsigned int varIdCount() const
{
return _varId;
}
private: private:
/** Disable copy constructor, no implementation */ /** Disable copy constructor, no implementation */
Tokenizer(const Tokenizer &); Tokenizer(const Tokenizer &);
@ -684,6 +693,9 @@ private:
/** Symbol database that all checks etc can use */ /** Symbol database that all checks etc can use */
mutable SymbolDatabase *_symbolDatabase; mutable SymbolDatabase *_symbolDatabase;
/** variable count */
unsigned int _varId;
}; };
/// @} /// @}