diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 8a3dbdb9f..0a2900372 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -58,6 +58,9 @@ Tokenizer::Tokenizer() // symbol database _symbolDatabase = NULL; + + // variable count + _varId = 0; } Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) @@ -75,6 +78,9 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) // symbol database _symbolDatabase = NULL; + + // variable count + _varId = 0; } Tokenizer::~Tokenizer() @@ -3271,7 +3277,7 @@ void Tokenizer::setVarId() tok->varId(0); // Set variable ids.. - unsigned int _varId = 0; + _varId = 0; for (Token *tok = _tokens; tok; tok = tok->next()) { if (tok != _tokens && !Token::Match(tok, "[;{}(,] %type%")) diff --git a/lib/tokenize.h b/lib/tokenize.h index d5faa0812..a9b5c556d 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -650,6 +650,15 @@ public: Token *deleteInvalidTypedef(Token *typeDef); + /** + * Get variable count. + * @return number of variables + */ + unsigned int varIdCount() const + { + return _varId; + } + private: /** Disable copy constructor, no implementation */ Tokenizer(const Tokenizer &); @@ -684,6 +693,9 @@ private: /** Symbol database that all checks etc can use */ mutable SymbolDatabase *_symbolDatabase; + + /** variable count */ + unsigned int _varId; }; /// @}